diff --git a/api/v1alpha1/gitrepository_types.go b/api/v1alpha1/gitrepository_types.go index d3ac32af..978087c4 100644 --- a/api/v1alpha1/gitrepository_types.go +++ b/api/v1alpha1/gitrepository_types.go @@ -5,12 +5,13 @@ import ( ) const ( - GitProviderGitea = "gitea" - GitProviderGitHub = "github" - GiteaAdminUserName = "giteaAdmin" - SourceTypeLocal = "local" - SourceTypeRemote = "remote" - SourceTypeEmbedded = "embedded" + GitProviderGitea = "gitea" + GitProviderGitHub = "github" + GiteaAdminUserName = "giteaAdmin" + GiteaDeveloperUserName = "developer" + SourceTypeLocal = "local" + SourceTypeRemote = "remote" + SourceTypeEmbedded = "embedded" ) type GitRepositorySpec struct { diff --git a/pkg/controllers/localbuild/gitea.go b/pkg/controllers/localbuild/gitea.go index 0afbd19a..9fb39211 100644 --- a/pkg/controllers/localbuild/gitea.go +++ b/pkg/controllers/localbuild/gitea.go @@ -25,6 +25,7 @@ import ( const ( giteaDevModePassword = "developer" + // hardcoded values from what we have in the yaml installation file. giteaNamespace = "gitea" giteaAdminSecret = "gitea-credential" @@ -58,19 +59,22 @@ func giteaAdminSecretObject() corev1.Secret { } func newGiteaAdminSecret(devMode bool) (corev1.Secret, error) { - // Use a default password when dev mode is enabled to avoid to recreate a new one each time pass := giteaDevModePassword + userName := v1alpha1.GiteaDeveloperUserName + if !devMode { var err error pass, err = util.GeneratePassword() if err != nil { return corev1.Secret{}, err } + + userName = v1alpha1.GiteaAdminUserName } obj := giteaAdminSecretObject() obj.StringData = map[string]string{ - "username": v1alpha1.GiteaAdminUserName, + "username": userName, "password": pass, } return obj, nil