// createSyncedAndHealthyApplications is a helper function that creates an ArgoCD application given a prefix and a cluster
createSyncedAndHealthyApplications is a helper function that creates an ArgoCD application given a prefix and a cluster
// createSyncedAndHealthyApplications is a helper function that creates an ArgoCD application given a prefix and a cluster
func createSyncedAndHealthyApplications(ctx context.Context, targets []Target) ([]argov1alpha1.Application, error) {
	var apps []argov1alpha1.Application
	for _, t := range targets {
		app := argov1alpha1.Application{
			ObjectMeta: metav1.ObjectMeta{
				Name:      t.Name,
				Namespace: t.Namespace,
				OwnerReferences: []metav1.OwnerReference{{
					APIVersion: consts.AppSetAPIGroup,
					Kind:       consts.AppSetKind,
					Name:       t.ApplicationSet,
					UID:        uuid.NewUUID(),
				}},
			},
			Spec: argov1alpha1.ApplicationSpec{
				Destination: argov1alpha1.ApplicationDestination{
					Server:    fmt.Sprintf("https://%s.kubernetes.io", t.Name),
					Namespace: t.Namespace,
					Name:      t.Name,
				}},
			Status: argov1alpha1.ApplicationStatus{
				Sync: argov1alpha1.SyncStatus{
					Status: argov1alpha1.SyncStatusCodeSynced,
				},
				Health: argov1alpha1.HealthStatus{
					Status: health.HealthStatusHealthy,
				},
			},
		}
		err := k8sClient.Create(ctx, &app)
		if err != nil {
			return nil, err
		}
		apps = append(apps, app)
	}
	return apps, nil
}
func createSyncedAndHealthyApplications ( ctx context . Context , targets [ ] Target ) ( [ ] argov1alpha1 . Application , error ) { var apps [ ] argov1alpha1 . Application for _ , t := range targets { app := argov1alpha1 . Application { ObjectMeta : metav1 . ObjectMeta { Name : t . Name , Namespace : t . Namespace , OwnerReferences : [ ] metav1 . OwnerReference { { APIVersion : consts . AppSetAPIGroup , Kind : consts . AppSetKind , Name : t . ApplicationSet , UID : uuid . NewUUID ( ) , } } , } , Spec : argov1alpha1 . ApplicationSpec { Destination : argov1alpha1 . ApplicationDestination { Server : fmt . Sprintf ( " " , t . Name ) , Namespace : t . Namespace , Name : t . Name , } } , Status : argov1alpha1 . ApplicationStatus { Sync : argov1alpha1 . SyncStatus { Status : argov1alpha1 . SyncStatusCodeSynced , } , Health : argov1alpha1 . HealthStatus { Status : health . HealthStatusHealthy , } , } , } err := k8sClient . Create ( ctx , & app ) if err != nil { return nil , err } apps = append ( apps , app ) } return apps , nil }
createSyncedAndHealthyApplications is a helper function that creates an ArgoCD application given a prefix and a cluster
createSyncedAndHealthyApplications is a helper function that creates an ArgoCD application given a prefix and a cluster