Skip to content

Commit

Permalink
Add fogg apply --no-apply-plugins flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarrien committed Sep 30, 2018
1 parent fa70ae7 commit 7a2cd50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 8 additions & 4 deletions apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
const rootPath = "terraform"

// Apply will run a plan and apply all the changes to the current repo.
func Apply(fs afero.Fs, conf *config.Config, tmp *templates.T, upgrade bool) error {
func Apply(fs afero.Fs, conf *config.Config, tmp *templates.T, upgrade bool, noApplyPlugins bool) error {
if !upgrade {
toolVersion, err := util.VersionString()
if err != nil {
Expand All @@ -49,9 +49,13 @@ func Apply(fs afero.Fs, conf *config.Config, tmp *templates.T, upgrade bool) err
return errs.WrapUser(e, "unable to apply repo")
}

e = applyPlugins(fs, p)
if e != nil {
return errs.WrapUser(e, "unable to apply plugins")
if noApplyPlugins {
log.Infof("NOT applying plugins. This may result in unexpected behavior.")
} else {
e = applyPlugins(fs, p)
if e != nil {
return errs.WrapUser(e, "unable to apply plugins")
}
}

e = applyAccounts(fs, p, &tmp.Account)
Expand Down
2 changes: 1 addition & 1 deletion apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestApplySmokeTest(t *testing.T) {
c, e := config.ReadConfig(ioutil.NopCloser(strings.NewReader(json)))
assert.Nil(t, e)

e = Apply(fs, c, templates.Templates, false)
e = Apply(fs, c, templates.Templates, false, false)
assert.Nil(t, e)
}

Expand Down
8 changes: 7 additions & 1 deletion cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func init() {
applyCmd.Flags().StringP("config", "c", "fogg.json", "Use this to override the fogg config file.")
applyCmd.Flags().BoolP("verbose", "v", false, "use this to turn on verbose output")
applyCmd.Flags().BoolP("upgrade", "u", false, "use this when running a new version of fogg")
applyCmd.Flags().Bool("no-apply-plugins", false, "do not apply fogg plugins; this may result in unexpected behavior.")
rootCmd.AddCommand(applyCmd)
}

Expand Down Expand Up @@ -54,6 +55,11 @@ var applyCmd = &cobra.Command{
return e
}

noApplyPlugins, e := cmd.Flags().GetBool("no-apply-plugins")
if e != nil {
return e
}

// check that we are at root of initialized git repo
openGitOrExit(pwd)

Expand All @@ -65,7 +71,7 @@ var applyCmd = &cobra.Command{
}

// apply
e = apply.Apply(fs, config, templates.Templates, upgrade)
e = apply.Apply(fs, config, templates.Templates, upgrade, noApplyPlugins)

return e
},
Expand Down

0 comments on commit 7a2cd50

Please sign in to comment.