Skip to content

Commit

Permalink
fix: plugins updating
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors committed Jul 27, 2021
1 parent 5e83df1 commit b54c22f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cmd/executor_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/outblocks/outblocks-cli/pkg/plugins"
)

func (e *Executor) loadProjectConfig(ctx context.Context, cfgPath string, vals map[string]interface{}, skipLoadPlugins bool) error {
func (e *Executor) loadProjectConfig(ctx context.Context, cfgPath string, vals map[string]interface{}, skipLoadPlugins, skipCheck bool) error {
cfg, err := config.LoadProjectConfig(cfgPath, vals, &config.ProjectOptions{
Env: e.opts.env,
})
Expand All @@ -28,19 +28,22 @@ func (e *Executor) loadProjectConfig(ctx context.Context, cfgPath string, vals m
}

e.loader = plugins.NewLoader(cfg.Path, e.PluginsCacheDir())
e.cfg = cfg

if !skipLoadPlugins {
if err := cfg.LoadPlugins(ctx, e.log, e.loader); err != nil {
return err
}
}

if skipLoadPlugins || skipCheck {
return nil
}

if err := cfg.FullCheck(); err != nil {
return err
}

e.cfg = cfg

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (e *Executor) newPluginsCmd() *cobra.Command {
Long: `Update installed plugins to matching versions from config.`,
Annotations: map[string]string{
cmdGroupAnnotation: cmdGroupMain,
cmdSkipLoadPluginsAnnotation: "1",
cmdSkipCheckConfigAnnotation: "1",
},
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

const (
cmdSkipLoadConfigAnnotation = "cmd_skip_load_config"
cmdSkipCheckConfigAnnotation = "cmd_skip_check_config"
cmdSkipLoadPluginsAnnotation = "cmd_skip_load_plugins"
cmdGroupAnnotation = "cmd_group"
cmdGroupDelimiter = "-"
Expand Down Expand Up @@ -293,9 +294,10 @@ func (e *Executor) newRoot() *cobra.Command {

vals := map[string]interface{}{"var": v}
skipLoadPlugins := cmd.Annotations[cmdSkipLoadPluginsAnnotation] == "1"
skipCheckConfig := cmd.Annotations[cmdSkipCheckConfigAnnotation] == "1"

// Load config file.
if err := e.loadProjectConfig(cmd.Context(), cfgPath, vals, skipLoadPlugins); err != nil && !errors.Is(err, config.ErrProjectConfigNotFound) {
if err := e.loadProjectConfig(cmd.Context(), cfgPath, vals, skipLoadPlugins, skipCheckConfig); err != nil && !errors.Is(err, config.ErrProjectConfigNotFound) {
return err
}

Expand Down

0 comments on commit b54c22f

Please sign in to comment.