Skip to content

Commit

Permalink
Leverage gatecheck submit functionality to send artifacts to Belay
Browse files Browse the repository at this point in the history
  • Loading branch information
ayee808 committed Dec 9, 2024
1 parent 54444ee commit 13e065d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ test/.artifacts
test/artifacts
artifacts
libpod/

.env.local
dist/
2 changes: 2 additions & 0 deletions cmd/portage/cli/v0/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func newRunCommand() *cobra.Command {
// run deploy
deployCmd := newBasicCommand("deploy", "Beta Feature: VALIDATION ONLY - run gatecheck validate on artifacts from previous pipelines", runDeploy)
deployCmd.Flags().String("gatecheck-config", "", "gatecheck configuration file")
deployCmd.Flags().Bool("submit", false, "submit artifacts to configured API endpoint")
_ = viper.BindPFlag("deploy.gatecheckconfigfilename", deployCmd.Flags().Lookup("gatecheck-config"))
_ = viper.BindPFlag("deploy.submit", deployCmd.Flags().Lookup("submit"))

// run image-delivery

Expand Down
1 change: 1 addition & 0 deletions pkg/pipelines/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type configImagePublish struct {
type configDeploy struct {
Enabled bool `mapstructure:"enabled"`
GatecheckConfigFilename string `mapstructure:"gatecheckConfigFilename"`
Submit bool `mapstructure:"submit"`
}

// metaConfigField is used to map viper values to env variables and their associated default values
Expand Down
13 changes: 13 additions & 0 deletions pkg/pipelines/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,18 @@ func (p *Deploy) Run() error {
return mkDeploymentError(err)
}

if p.config.Deploy.Submit {
err = shell.GatecheckSubmit(
shell.WithDryRun(p.DryRunEnabled),
shell.WithStderr(p.Stderr),
shell.WithStdout(p.Stdout),
shell.WithTargetFile(p.runtime.bundleFilename),
shell.WithConfigFile(gatecheckConfigPath),
)
if err != nil {
return mkDeploymentError(err)
}
}

return nil
}
6 changes: 6 additions & 0 deletions pkg/shell/gatecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ func GatecheckValidate(options ...OptionFunc) error {
cmd := exec.Command("gatecheck", args...)
return run(cmd, o)
}

func GatecheckSubmit(options ...OptionFunc) error {
o := newOptions(options...)
cmd := exec.Command("gatecheck", "submit", "--config", o.configFilename, o.targetFilename)
return run(cmd, o)
}

0 comments on commit 13e065d

Please sign in to comment.