Skip to content

Commit

Permalink
adds flag to configure only webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam Mukhade committed Apr 20, 2022
1 parent 7b5136b commit e7cc68e
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions pkg/cmd/tknpac/repository/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type createOptions struct {

func CreateCommand(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
var githubURLForWebhook string
var onlyWebhook bool
createOpts := &createOptions{
event: info.NewEvent(),
repository: &apipac.Repository{},
Expand All @@ -60,29 +61,31 @@ func CreateCommand(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
return err
}

if err := getRepoURL(createOpts); err != nil {
return err
}
if !onlyWebhook {
if err := getRepoURL(createOpts); err != nil {
return err
}

if err := getOrCreateNamespace(ctx, createOpts); err != nil {
return err
}
if err := getOrCreateNamespace(ctx, createOpts); err != nil {
return err
}

if err := createRepoCRD(ctx, createOpts); err != nil {
return err
}
if err := createRepoCRD(ctx, createOpts); err != nil {
return err
}

gopt := generate.MakeOpts()
gopt.GitInfo = createOpts.gitInfo
gopt.IOStreams = createOpts.ioStreams
gopt.CLIOpts = createOpts.cliOpts
gopt := generate.MakeOpts()
gopt.GitInfo = createOpts.gitInfo
gopt.IOStreams = createOpts.ioStreams
gopt.CLIOpts = createOpts.cliOpts

// defaulting the values for repo create command
gopt.Event.EventType = "[pull_request, push]"
gopt.Event.BaseBranch = "main"
// defaulting the values for repo create command
gopt.Event.EventType = "[pull_request, push]"
gopt.Event.BaseBranch = "main"

if err := generate.Generate(gopt); err != nil {
return err
if err := generate.Generate(gopt); err != nil {
return err
}
}

config := &webhook.Webhook{
Expand Down Expand Up @@ -110,6 +113,7 @@ func CreateCommand(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
cmd.PersistentFlags().StringVarP(&createOpts.pacNamespace, "pac-namespace",
"", "", "the namespace where pac is installed")
cmd.PersistentFlags().StringVarP(&githubURLForWebhook, "github-api-url", "", "", "Github Enterprise API URL")
cmd.PersistentFlags().BoolVar(&onlyWebhook, "webhook", false, "Skip repository creation, proceed with configuring webhook")

return cmd
}
Expand Down

0 comments on commit e7cc68e

Please sign in to comment.