// createClusters is a helper function that creates N clusters in a given namespace with a common name prefix
createClusters is a helper function that creates N clusters in a given namespace with a common name prefix
// createClusters is a helper function that creates N clusters in a given namespace with a common name prefix
func createClusters(ctx context.Context, targets []Target) ([]corev1.Secret, error) {
	var clusters []corev1.Secret
	for _, t := range targets {
		cluster := corev1.Secret{
			ObjectMeta: metav1.ObjectMeta{
				Name:      t.Name,
				Namespace: t.Namespace,
				Labels: map[string]string{
					consts.ArgoCDSecretTypeLabel: consts.ArgoCDSecretTypeCluster,
					"area":                       t.Area,
					"region":                     t.Region,
					"az":                         t.AZ,
					"cluster":                    t.Name,
				}},
			Data: map[string][]byte{
				"server": []byte(fmt.Sprintf("https://%s.kubernetes.io", t.Name)),
			},
		}
		err := k8sClient.Create(ctx, &cluster)
		if err != nil {
			return nil, err
		}
		clusters = append(clusters, cluster)
	}
	return clusters, nil
}
func createClusters ( ctx context . Context , targets [ ] Target ) ( [ ] corev1 . Secret , error ) { var clusters [ ] corev1 . Secret for _ , t := range targets { cluster := corev1 . Secret { ObjectMeta : metav1 . ObjectMeta { Name : t . Name , Namespace : t . Namespace , Labels : map [ string ] string { consts . ArgoCDSecretTypeLabel : consts . ArgoCDSecretTypeCluster , " " : t . Area , " " : t . Region , " " : t . AZ , " " : t . Name , } } , Data : map [ string ] [ ] byte { " " : [ ] byte ( fmt . Sprintf ( " " , t . Name ) ) , } , } err := k8sClient . Create ( ctx , & cluster ) if err != nil { return nil , err } clusters = append ( clusters , cluster ) } return clusters , nil }
createClusters is a helper function that creates N clusters in a given namespace with a common name prefix
createClusters is a helper function that creates N clusters in a given namespace with a common name prefix