@@ -24,6 +24,7 @@ import (
2424 "strings"
2525 "time"
2626
27+ "github.com/fluxcd/go-git-providers/gitprovider"
2728 "github.com/fluxcd/pkg/git"
2829 "github.com/fluxcd/pkg/git/gogit"
2930 "github.com/spf13/cobra"
@@ -58,14 +59,14 @@ the bootstrap command will perform an upgrade if needed.`,
5859 # Run bootstrap for a repository path
5960 flux bootstrap gitlab --owner=<group> --repository=<repository name> --path=dev-cluster
6061
61- # Run bootstrap for a public repository on a personal account
62- flux bootstrap gitlab --owner=<user > --repository=<repository name> --private=false --personal --token-auth
62+ # Run bootstrap for a public repository
63+ flux bootstrap gitlab --owner=<group > --repository=<repository name> --visibility=public --token-auth
6364
6465 # Run bootstrap for a private repository hosted on a GitLab server
65- flux bootstrap gitlab --owner=<group> --repository=<repository name> --hostname=<domain > --token-auth
66+ flux bootstrap gitlab --owner=<group> --repository=<repository name> --hostname=<gitlab_url > --token-auth
6667
6768 # Run bootstrap for an existing repository with a branch named main
68- flux bootstrap gitlab --owner=<organization > --repository=<repository name> --branch=main --token-auth
69+ flux bootstrap gitlab --owner=<group > --repository=<repository name> --branch=main --token-auth
6970
7071 # Run bootstrap for a private repository using Deploy Token authentication
7172 flux bootstrap gitlab --owner=<group> --repository=<repository name> --deploy-token-auth
@@ -85,6 +86,7 @@ type gitlabFlags struct {
8586 repository string
8687 interval time.Duration
8788 personal bool
89+ visibility flags.GitLabVisibility
8890 private bool
8991 hostname string
9092 path flags.SafeRelativePath
@@ -94,14 +96,22 @@ type gitlabFlags struct {
9496 deployTokenAuth bool
9597}
9698
97- var gitlabArgs gitlabFlags
99+ func NewGitlabFlags () gitlabFlags {
100+ return gitlabFlags {
101+ visibility : flags .GitLabVisibility (gitprovider .RepositoryVisibilityPrivate ),
102+ }
103+ }
104+
105+ var gitlabArgs = NewGitlabFlags ()
98106
99107func init () {
100108 bootstrapGitLabCmd .Flags ().StringVar (& gitlabArgs .owner , "owner" , "" , "GitLab user or group name" )
101109 bootstrapGitLabCmd .Flags ().StringVar (& gitlabArgs .repository , "repository" , "" , "GitLab repository name" )
102110 bootstrapGitLabCmd .Flags ().StringSliceVar (& gitlabArgs .teams , "team" , []string {}, "GitLab teams to be given maintainer access (also accepts comma-separated values)" )
103111 bootstrapGitLabCmd .Flags ().BoolVar (& gitlabArgs .personal , "personal" , false , "if true, the owner is assumed to be a GitLab user; otherwise a group" )
104112 bootstrapGitLabCmd .Flags ().BoolVar (& gitlabArgs .private , "private" , true , "if true, the repository is setup or configured as private" )
113+ bootstrapGitLabCmd .Flags ().MarkDeprecated ("private" , "use --visibility instead" )
114+ bootstrapGitLabCmd .Flags ().Var (& gitlabArgs .visibility , "visibility" , gitlabArgs .visibility .Description ())
105115 bootstrapGitLabCmd .Flags ().DurationVar (& gitlabArgs .interval , "interval" , time .Minute , "sync interval" )
106116 bootstrapGitLabCmd .Flags ().StringVar (& gitlabArgs .hostname , "hostname" , glDefaultDomain , "GitLab hostname" )
107117 bootstrapGitLabCmd .Flags ().Var (& gitlabArgs .path , "path" , "path relative to the repository root, when specified the cluster sync will be scoped to this path" )
@@ -133,6 +143,11 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
133143 return fmt .Errorf ("--token-auth and --deploy-token-auth cannot be set both." )
134144 }
135145
146+ if ! gitlabArgs .private {
147+ gitlabArgs .visibility .Set (string (gitprovider .RepositoryVisibilityPublic ))
148+ cmd .Println ("Using visibility public as --private=false" )
149+ }
150+
136151 if err := bootstrapValidate (); err != nil {
137152 return err
138153 }
@@ -282,6 +297,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
282297 // Bootstrap config
283298 bootstrapOpts := []bootstrap.GitProviderOption {
284299 bootstrap .WithProviderRepository (gitlabArgs .owner , gitlabArgs .repository , gitlabArgs .personal ),
300+ bootstrap .WithProviderVisibility (gitlabArgs .visibility .String ()),
285301 bootstrap .WithBranch (bootstrapArgs .branch ),
286302 bootstrap .WithBootstrapTransportType ("https" ),
287303 bootstrap .WithSignature (bootstrapArgs .authorName , bootstrapArgs .authorEmail ),
@@ -301,9 +317,6 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
301317 if gitlabArgs .deployTokenAuth {
302318 bootstrapOpts = append (bootstrapOpts , bootstrap .WithDeployTokenAuth ())
303319 }
304- if ! gitlabArgs .private {
305- bootstrapOpts = append (bootstrapOpts , bootstrap .WithProviderRepositoryConfig ("" , "" , "public" ))
306- }
307320 if gitlabArgs .reconcile {
308321 bootstrapOpts = append (bootstrapOpts , bootstrap .WithReconcile ())
309322 }
0 commit comments