diff --git a/.gitignore b/.gitignore index feb5062..4e13458 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,5 @@ test/.artifacts test/artifacts artifacts libpod/ - +.env.local dist/ diff --git a/cmd/portage/cli/v0/pipelines.go b/cmd/portage/cli/v0/pipelines.go index 2a8fb17..dbbf0e1 100644 --- a/cmd/portage/cli/v0/pipelines.go +++ b/cmd/portage/cli/v0/pipelines.go @@ -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 diff --git a/pkg/pipelines/config.go b/pkg/pipelines/config.go index 9491cc5..199eeeb 100644 --- a/pkg/pipelines/config.go +++ b/pkg/pipelines/config.go @@ -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 diff --git a/pkg/pipelines/deploy.go b/pkg/pipelines/deploy.go index a4476c1..4643a70 100644 --- a/pkg/pipelines/deploy.go +++ b/pkg/pipelines/deploy.go @@ -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 } diff --git a/pkg/shell/gatecheck.go b/pkg/shell/gatecheck.go index 4999915..3816239 100644 --- a/pkg/shell/gatecheck.go +++ b/pkg/shell/gatecheck.go @@ -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) +}