Skip to content

Commit

Permalink
Allow setting OBS_USERNAME for a specific user
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Sep 14, 2023
1 parent aaaaaf3 commit dad915c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/obs/obs.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ const (
// OBSPasswordKey is name of the environment variable with password for
// Kubernetes Release Bot account.
OBSPasswordKey = "OBS_PASSWORD"

// OBSUsernameKey is name of the environment variable containing the
// username for the OBS account. If empty, obsK8sUsername will be used.
OBSUsernameKey = "OBS_USERNAME"
)

// Options are settings which will be used by `StageOptions` as well as
Expand Down
7 changes: 6 additions & 1 deletion pkg/obs/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ func (d *DefaultRelease) InitOBSRoot() error {
return fmt.Errorf("%s environment variable not set", OBSPasswordKey)
}

if err := d.impl.CreateOBSConfigFile(obsK8sUsername, password); err != nil {
username := os.Getenv(OBSUsernameKey)
if username == "" {
username = obsK8sUsername
}

if err := d.impl.CreateOBSConfigFile(username, password); err != nil {
return fmt.Errorf("creating obs config file: %w", err)
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/obs/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ func (d *DefaultStage) InitOBSRoot() error {
return fmt.Errorf("%s environment variable not set", OBSPasswordKey)
}

if err := d.impl.CreateOBSConfigFile(obsK8sUsername, password); err != nil {
username := os.Getenv(OBSUsernameKey)
if username == "" {
username = obsK8sUsername
}

if err := d.impl.CreateOBSConfigFile(username, password); err != nil {
return fmt.Errorf("creating obs config file: %w", err)
}

Expand Down

0 comments on commit dad915c

Please sign in to comment.