Skip to content

Commit

Permalink
DEV-2465: add atmos pro stack locking (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun authored Aug 20, 2024
1 parent b7f8e30 commit 41048d5
Show file tree
Hide file tree
Showing 19 changed files with 1,347 additions and 244 deletions.
17 changes: 17 additions & 0 deletions cmd/pro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/spf13/cobra"
)

// proCmd executes 'atmos pro' CLI commands
var proCmd = &cobra.Command{
Use: "pro",
Short: "Execute 'pro' commands",
Long: `This command executes 'atmos pro' CLI commands`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
}

func init() {
RootCmd.AddCommand(proCmd)
}
33 changes: 33 additions & 0 deletions cmd/pro_lock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
e "github.com/cloudposse/atmos/internal/exec"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/spf13/cobra"
)

// proLockCmd executes 'pro lock' CLI command
var proLockCmd = &cobra.Command{
Use: "lock",
Short: "Lock a stack",
Long: `This command calls the atmos pro API and locks a stack`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
checkAtmosConfig()

err := e.ExecuteProLockCommand(cmd, args)
if err != nil {
u.LogErrorAndExit(err)
}
},
}

func init() {
proLockCmd.PersistentFlags().StringP("component", "c", "", "Specify the Atmos component to lock")
proLockCmd.PersistentFlags().StringP("stack", "s", "", "Specify the Atmos stack to lock")
proLockCmd.PersistentFlags().StringP("message", "m", "", "The lock message to display if someone else tries to lock the stack. Defaults to 'Locked by Atmos'")
proLockCmd.PersistentFlags().Int32P("ttl", "t", 0, "The amount of time in seconds to lock the stack for. Defaults to 30")

proCmd.AddCommand(proLockCmd)
}
31 changes: 31 additions & 0 deletions cmd/pro_unlock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
e "github.com/cloudposse/atmos/internal/exec"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/spf13/cobra"
)

// proUnlockCmd executes 'pro unlock' CLI command
var proUnlockCmd = &cobra.Command{
Use: "unlock",
Short: "Unlock a stack",
Long: `This command calls the atmos pro API and unlocks a stack`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
checkAtmosConfig()

err := e.ExecuteProUnlockCommand(cmd, args)
if err != nil {
u.LogErrorAndExit(err)
}
},
}

func init() {
proUnlockCmd.PersistentFlags().StringP("component", "c", "", "Specify the Atmos component to lock")
proUnlockCmd.PersistentFlags().StringP("stack", "s", "", "Specify the Atmos stack to lock")

proCmd.AddCommand(proUnlockCmd)
}
2 changes: 2 additions & 0 deletions demo/screengrabs/demo-stacks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ atmos describe dependents --help
atmos describe stacks --help
atmos describe workflows --help
atmos docs --help
atmos pro lock --help
atmos pro unlock --help
atmos terraform --help
atmos terraform clean --help
atmos terraform deploy --help
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
Expand Down
Loading

0 comments on commit 41048d5

Please sign in to comment.