Skip to content

Commit

Permalink
feat: add token flag to gitlab release command
Browse files Browse the repository at this point in the history
  • Loading branch information
corang committed Oct 16, 2024
1 parent 2870a16 commit b868ffd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/spf13/cobra"
)

var tokenVarName string

// gitlabCmd represents the gitlab command
var gitlabCmd = &cobra.Command{
Use: "gitlab flavor",
Expand All @@ -39,7 +41,7 @@ var gitlabCmd = &cobra.Command{

rootCmd.SilenceUsage = true

return gitlab.TagAndRelease(currentFlavor)
return gitlab.TagAndRelease(currentFlavor, tokenVarName)
},
}

Expand All @@ -52,4 +54,5 @@ var releaseCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(releaseCmd)
releaseCmd.AddCommand(gitlabCmd)
gitlabCmd.Flags().StringVarP(&tokenVarName, "token-var-name", "t", "GITLAB_RELEASE_TOKEN", "Environment variable name for GitLab token")
}
4 changes: 2 additions & 2 deletions src/gitlab/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var openRepo = utils.OpenRepo

var getPackageName = utils.GetPackageName

func TagAndRelease(flavor types.Flavor) error {
func TagAndRelease(flavor types.Flavor, tokenVarName string) error {
repo, err := openRepo()
if err != nil {
return err
Expand Down Expand Up @@ -47,7 +47,7 @@ func TagAndRelease(flavor types.Flavor) error {
fmt.Printf("Default branch: %s\n", defaultBranch)

// Create a new GitLab client
gitlabClient, err := newGitlabClient(os.Getenv("GITLAB_RELEASE_TOKEN"), gitlab.WithBaseURL(gitlabBaseURL))
gitlabClient, err := newGitlabClient(os.Getenv(tokenVarName), gitlab.WithBaseURL(gitlabBaseURL))
if err != nil {
return err
}
Expand Down

0 comments on commit b868ffd

Please sign in to comment.