From 3d884da55b38b169bd1bf7145e7f4ae8815f26b5 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Tue, 12 Nov 2024 11:27:35 +0100 Subject: [PATCH] Change the gitea user from giteaAdmin to developer for a user's developer Signed-off-by: cmoulliard --- api/v1alpha1/gitrepository_types.go | 13 +++++++------ pkg/controllers/localbuild/gitea.go | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) 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