cli, gapi, lang, lib: Add a flag to skip autoedges

The GAPI API is a bit of a mess, but I think this seems to work for
standalone run and also deploys. Hopefully I didn't add any unnecessary
extra dead code here, but that's archaeology for another day.
This commit is contained in:
James Shubin
2025-03-11 03:14:58 -04:00
parent 8d34910b9b
commit 17b859d0d7
6 changed files with 27 additions and 6 deletions

View File

@@ -58,6 +58,8 @@ type DeployArgs struct {
NoGit bool `arg:"--no-git" help:"don't look at git commit id for safe deploys"` NoGit bool `arg:"--no-git" help:"don't look at git commit id for safe deploys"`
Force bool `arg:"--force" help:"force a new deploy, even if the safety chain would break"` Force bool `arg:"--force" help:"force a new deploy, even if the safety chain would break"`
NoAutoEdges bool `arg:"--no-autoedges" help:"skip the autoedges stage"`
DeployEmpty *cliUtil.EmptyArgs `arg:"subcommand:empty" help:"deploy empty payload"` DeployEmpty *cliUtil.EmptyArgs `arg:"subcommand:empty" help:"deploy empty payload"`
DeployLang *cliUtil.LangArgs `arg:"subcommand:lang" help:"deploy lang (mcl) payload"` DeployLang *cliUtil.LangArgs `arg:"subcommand:lang" help:"deploy lang (mcl) payload"`
DeployYaml *cliUtil.YamlArgs `arg:"subcommand:yaml" help:"deploy yaml graph payload"` DeployYaml *cliUtil.YamlArgs `arg:"subcommand:yaml" help:"deploy yaml graph payload"`
@@ -251,6 +253,8 @@ func (obj *DeployArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error
deploy.Noop = obj.Noop deploy.Noop = obj.Noop
deploy.Sema = obj.Sema deploy.Sema = obj.Sema
deploy.NoAutoEdges = obj.NoAutoEdges
str, err := deploy.ToB64() str, err := deploy.ToB64()
if err != nil { if err != nil {
return false, errwrap.Wrapf(err, "encoding error") return false, errwrap.Wrapf(err, "encoding error")

View File

@@ -141,6 +141,8 @@ func (obj *RunArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error) {
Noop: obj.Noop, Noop: obj.Noop,
Sema: obj.Sema, Sema: obj.Sema,
//Update: obj.Update, //Update: obj.Update,
NoAutoEdges: obj.NoAutoEdges,
}, },
Fs: standaloneFs, Fs: standaloneFs,

View File

@@ -51,6 +51,9 @@ type Deploy struct {
//Sync bool // wait for everyone to close previous GAPI before switching //Sync bool // wait for everyone to close previous GAPI before switching
Noop bool Noop bool
Sema int // sema override Sema int // sema override
NoAutoEdges bool
GAPI GAPI GAPI GAPI
} }

View File

@@ -71,6 +71,8 @@ type Flags struct {
Noop bool Noop bool
Sema int Sema int
NoAutoEdges bool
} }
// Info is the set of input values passed into the Cli method so that the GAPI // Info is the set of input values passed into the Cli method so that the GAPI

View File

@@ -488,6 +488,9 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
Name: Name, Name: Name,
Noop: info.Flags.Noop, Noop: info.Flags.Noop,
Sema: info.Flags.Sema, Sema: info.Flags.Sema,
NoAutoEdges: info.Flags.NoAutoEdges,
GAPI: &GAPI{ GAPI: &GAPI{
InputURI: fs.URI(), InputURI: fs.URI(),
Data: &lang.Data{ Data: &lang.Data{

View File

@@ -116,6 +116,9 @@ type Config struct {
// TODO: We should consider deprecating this feature. // TODO: We should consider deprecating this feature.
NoDeployWatch bool `arg:"--no-deploy-watch" help:"do not change deploys after an initial deploy"` NoDeployWatch bool `arg:"--no-deploy-watch" help:"do not change deploys after an initial deploy"`
// NoAutoEdges tells the engine to not try and build autoedges.
NoAutoEdges bool `arg:"--no-autoedges" help:"skip the autoedges stage"`
// Noop globally forces all resources into no-op mode. // Noop globally forces all resources into no-op mode.
Noop bool `arg:"--noop" help:"globally force all resources into no-op mode"` Noop bool `arg:"--noop" help:"globally force all resources into no-op mode"`
@@ -834,13 +837,17 @@ func (obj *Main) Run() error {
// XXX: can we change this into a ge.Apply operation? // XXX: can we change this into a ge.Apply operation?
// add autoedges; modifies the graph only if no error // add autoedges; modifies the graph only if no error
timing = time.Now() if mainDeploy.NoAutoEdges {
if err := obj.ge.AutoEdge(); err != nil { Logf("skipping auto edges...")
obj.ge.Abort() // delete graph } else {
Logf("error running auto edges: %+v", err) timing = time.Now()
continue if err := obj.ge.AutoEdge(); err != nil {
obj.ge.Abort() // delete graph
Logf("error running auto edges: %+v", err)
continue
}
Logf("auto edges took: %s", time.Since(timing))
} }
Logf("auto edges took: %s", time.Since(timing))
// XXX: can we change this into a ge.Apply operation? // XXX: can we change this into a ge.Apply operation?
// run autogroup; modifies the graph // run autogroup; modifies the graph