package main

import (
	"github.com/giolekva/pcloud/core/installer"
	"github.com/giolekva/pcloud/core/installer/kube"
	"github.com/giolekva/pcloud/core/installer/status"
)

func newNSCreator() (installer.NamespaceCreator, error) {
	return installer.NewNamespaceCreator(kube.KubeConfigOpts{
		KubeConfigPath: rootFlags.kubeConfig,
	})
}

func newZoneFetcher() (installer.ZoneStatusFetcher, error) {
	return installer.NewZoneStatusFetcher(rootFlags.kubeConfig)
}

func newHelmReleaseMonitor() (status.ResourceMonitor, error) {
	return status.NewHelmReleaseMonitor(rootFlags.kubeConfig)
}

func newInstanceMonitor() (*status.InstanceMonitor, error) {
	m, err := status.NewDelegatingMonitor(rootFlags.kubeConfig)
	if err != nil {
		return nil, err
	}
	return status.NewInstanceMonitor(m), nil
}

func newJobCreator() (installer.JobCreator, error) {
	clientset, err := kube.NewKubeClient(kube.KubeConfigOpts{
		KubeConfigPath: rootFlags.kubeConfig,
	})
	if err != nil {
		return nil, err
	}
	return installer.NewJobCreator(clientset.BatchV1()), nil
}
