diff --git a/api/v1alpha1/localbuild_types.go b/api/v1alpha1/localbuild_types.go index 0cc114f9..cb27b30d 100644 --- a/api/v1alpha1/localbuild_types.go +++ b/api/v1alpha1/localbuild_types.go @@ -47,13 +47,13 @@ type PackageConfigsSpec struct { // BuildCustomizationSpec fields cannot change once a cluster is created type BuildCustomizationSpec struct { - Protocol string `json:"protocol,omitempty"` - Host string `json:"host,omitempty"` - IngressHost string `json:"ingressHost,omitempty"` - Port string `json:"port,omitempty"` - UsePathRouting bool `json:"usePathRouting,omitempty"` - SelfSignedCert string `json:"selfSignedCert,omitempty"` - DevMode bool `json:"devMode,omitempty"` + Protocol string `json:"protocol,omitempty"` + Host string `json:"host,omitempty"` + IngressHost string `json:"ingressHost,omitempty"` + Port string `json:"port,omitempty"` + UsePathRouting bool `json:"usePathRouting,omitempty"` + SelfSignedCert string `json:"selfSignedCert,omitempty"` + StaticPasswords bool `json:"staticPasswords,omitempty"` } type LocalbuildSpec struct { diff --git a/pkg/build/build.go b/pkg/build/build.go index f30a82db..2a49f8dd 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -280,5 +280,5 @@ func isBuildCustomizationSpecEqual(s1, s2 v1alpha1.BuildCustomizationSpec) bool s1.Port == s2.Port && s1.UsePathRouting == s2.UsePathRouting && s1.SelfSignedCert == s2.SelfSignedCert && - s1.DevMode == s2.DevMode + s1.StaticPasswords == s2.StaticPasswords } diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index abad45c8..05f0d806 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -20,7 +20,7 @@ import ( const ( recreateClusterUsage = "Delete cluster first if it already exists." buildNameUsage = "Name for build (Prefix for kind cluster name, pod names, etc)." - devModeUsage = "When enabled, the platform will run the core packages with developer password." + staticPasswordsUsage = "Set a static password: developer to the applications: argocd and gitea." kubeVersionUsage = "Version of the kind kubernetes cluster to create." extraPortsMappingUsage = "List of extra ports to expose on the docker container and kubernetes cluster as nodePort " + "(e.g. \"22:32222,9090:39090,etc\")." @@ -41,7 +41,7 @@ var ( // Flags recreateCluster bool buildName string - devMode bool + staticPasswords bool kubeVersion string extraPortsMapping string kindConfigPath string @@ -69,7 +69,7 @@ func init() { CreateCmd.PersistentFlags().StringVar(&buildName, "build-name", "localdev", buildNameUsage) CreateCmd.PersistentFlags().MarkDeprecated("build-name", "use --name instead.") CreateCmd.PersistentFlags().StringVar(&buildName, "name", "localdev", buildNameUsage) - CreateCmd.PersistentFlags().BoolVar(&devMode, "dev-mode", false, devModeUsage) + CreateCmd.PersistentFlags().BoolVar(&staticPasswords, "static-passwords", false, staticPasswordsUsage) CreateCmd.PersistentFlags().StringVar(&kubeVersion, "kube-version", "v1.30.3", kubeVersionUsage) CreateCmd.PersistentFlags().StringVar(&extraPortsMapping, "extra-ports", "", extraPortsMappingUsage) CreateCmd.PersistentFlags().StringVar(&kindConfigPath, "kind-config", "", kindConfigPathUsage) @@ -141,12 +141,12 @@ func create(cmd *cobra.Command, args []string) error { ExtraPortsMapping: extraPortsMapping, TemplateData: v1alpha1.BuildCustomizationSpec{ - Protocol: protocol, - Host: host, - IngressHost: ingressHost, - Port: port, - UsePathRouting: pathRouting, - DevMode: devMode, + Protocol: protocol, + Host: host, + IngressHost: ingressHost, + Port: port, + UsePathRouting: pathRouting, + StaticPasswords: staticPasswords, }, CustomPackageDirs: absDirPaths, diff --git a/pkg/cmd/get/secrets.go b/pkg/cmd/get/secrets.go index 01ad2757..8a646d57 100644 --- a/pkg/cmd/get/secrets.go +++ b/pkg/cmd/get/secrets.go @@ -210,12 +210,12 @@ func secretToTemplateData(s v1.Secret) TemplateData { // TODO: The following code should be reviewed and improved as the secret containing the developer username/password is argocd-secret // where the password has been bcrypted and by consequence we cannot get and decode it from the secret - // This is why we are going to add it here BUT it will be displayed every time no matter if --dev-mode has been used or not + // This is why we are going to add it here BUT it will be displayed every time no matter if --static-passwords has been used or not if strings.Contains(s.Name, "gitea") { data.Data["username-developer"] = "giteAdmin" data.Data["password-developer"] = "developer" } else if strings.Contains(s.Name, "argocd") { - data.Data["username-developer"] = "developer" + data.Data["username-developer"] = "admin" data.Data["password-developer"] = "developer" } diff --git a/pkg/controllers/gitrepository/controller.go b/pkg/controllers/gitrepository/controller.go index f9a08ff2..829ec657 100644 --- a/pkg/controllers/gitrepository/controller.go +++ b/pkg/controllers/gitrepository/controller.go @@ -143,7 +143,7 @@ func (r *RepositoryReconciler) reconcileGitRepo(ctx context.Context, repo *v1alp return ctrl.Result{}, fmt.Errorf("getting git provider credentials: %w", err) } - if r.Config.DevMode { + if r.Config.StaticPasswords { creds.password = "developer" } diff --git a/pkg/controllers/localbuild/controller.go b/pkg/controllers/localbuild/controller.go index 98b0111a..8c3b1ca8 100644 --- a/pkg/controllers/localbuild/controller.go +++ b/pkg/controllers/localbuild/controller.go @@ -104,8 +104,8 @@ func (r *LocalbuildReconciler) Reconcile(ctx context.Context, req ctrl.Request) } } - if r.Config.DevMode { - logger.V(1).Info("DevMode is enabled") + if r.Config.StaticPasswords { + logger.V(1).Info("StaticPasswords is enabled") // Check if the Argocd Initial admin secret exists argocdInitialAdminPassword, err := r.extractArgocdInitialAdminSecret(ctx) @@ -683,7 +683,7 @@ func (r *LocalbuildReconciler) updateGiteaDevPassword(ctx context.Context, admin resp, err := client.AdminEditUser("giteaAdmin", opts) if err != nil { - return fmt.Errorf("cannot update gitea admin user: %w", resp.StatusCode, err), "failed" + return fmt.Errorf("cannot update gitea admin user. status: %d error : %w", resp.StatusCode, err), "failed" } return nil, "succeeded" } @@ -731,7 +731,7 @@ func (r *LocalbuildReconciler) updateArgocdDevPassword(ctx context.Context, admi err := json.Unmarshal([]byte(body), &argocdSession) if err != nil { - fmt.Errorf("Error unmarshalling JSON: %v", err) + return fmt.Errorf("Error unmarshalling JSON: %v", err), "failed" } payload := map[string]string{ @@ -794,7 +794,6 @@ func (r *LocalbuildReconciler) updateArgocdDevPassword(ctx context.Context, admi } else { return fmt.Errorf("HTTP Error: %d", resp.StatusCode), "failed" } - return nil, "failed" } func (r *LocalbuildReconciler) applyArgoCDAnnotation(ctx context.Context, obj client.Object, argoCDType, annotationKey, annotationValue string) error { diff --git a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml index ba9e7ab1..98c37c03 100644 --- a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml +++ b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml @@ -41,8 +41,6 @@ spec: description: BuildCustomizationSpec fields cannot change once a cluster is created properties: - devMode: - type: boolean host: type: string ingressHost: @@ -53,6 +51,8 @@ spec: type: string selfSignedCert: type: string + staticPasswords: + type: boolean usePathRouting: type: boolean type: object