Files
k3k/pkg/controller/cluster/agent/agent.go
T
2024-11-01 21:27:03 +02:00

29 lines
725 B
Go

package agent
import (
"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
"github.com/rancher/k3k/pkg/controller"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
)
const (
configName = "agent-config"
)
type Agent interface {
Name() string
Config() (ctrlruntimeclient.Object, error)
Resources() []ctrlruntimeclient.Object
}
func New(cluster *v1alpha1.Cluster, serviceIP, sharedAgentImage, token string) Agent {
if cluster.Spec.Mode == VirtualNodeMode {
return NewVirtualAgent(cluster, serviceIP, token)
}
return NewSharedAgent(cluster, serviceIP, sharedAgentImage, token)
}
func configSecretName(clusterName string) string {
return controller.SafeConcatNameWithPrefix(clusterName, configName)
}