rancher/k3k

Possible wrong data of virtual and shared configuration

Closed

#229 opened on Feb 4, 2025

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Go (77 forks)auto 404
good first issueteam/collie

Repository metrics

Stars
 (886 stars)
PR merge metrics
 (PR metrics pending)

Description

Since we are using a simple fmt.Sprintf to create the configration yaml for the virtual and shared agents, without checking the values this could lead to some possible misconfiguration:

func virtualAgentData(serviceIP, token string) string {
	return fmt.Sprintf(`server: https://%s:6443
token: %s
with-node-id: true`, serviceIP, token)
}

func sharedAgentData(cluster *v1alpha1.Cluster, serviceName, token, ip string) string {
	version := cluster.Spec.Version
	if cluster.Spec.Version == "" {
		version = cluster.Status.HostVersion
	}
	return fmt.Sprintf(`clusterName: %s
clusterNamespace: %s
serverIP: %s
serviceName: %s
token: %s
version: %s`,
		cluster.Name, cluster.Namespace, ip, serviceName, token, version)
}

Contributor guide