Skip to content

Commit

Permalink
Change the gitea user from giteaAdmin to developer for a user's devel…
Browse files Browse the repository at this point in the history
…oper

Signed-off-by: cmoulliard <[email protected]>
  • Loading branch information
cmoulliard committed Nov 12, 2024
1 parent 1e1b980 commit 3d884da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 7 additions & 6 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions pkg/controllers/localbuild/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

const (
giteaDevModePassword = "developer"

// hardcoded values from what we have in the yaml installation file.
giteaNamespace = "gitea"
giteaAdminSecret = "gitea-credential"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3d884da

Please sign in to comment.