Skip to content

Commit

Permalink
Update workflows UX. Update atmos, atmos --help and `atmos versio…
Browse files Browse the repository at this point in the history
…n` commands. Update demo tape. Update docs (#525)

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* Updates

* chore: update repo banner image

* chore: update demo gif

* Updates

* chore: update demo gif

* Updates

* chore: update demo gif

* Updates

* chore: update demo gif

* Updates

* Update demo.tape

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>

* Update examples/quick-start/stacks/workflows/validation.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>

* Update examples/quick-start/stacks/workflows/networking.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>

* chore: update demo gif

* Updates

* Update examples/quick-start/stacks/workflows/validation.yaml

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>

* chore: update demo gif

* Updates

* chore: update demo gif

* Updates

* chore: update demo gif

---------

Co-authored-by: screenshot-action 📷 <actions@github.com>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
  • Loading branch information
3 people committed Jan 30, 2024
1 parent 8f00ba2 commit 34ba0f4
Show file tree
Hide file tree
Showing 71 changed files with 1,097 additions and 726 deletions.
Binary file modified .github/banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,7 @@ commands:
{{ end }}
- name: set-eks-cluster
description: |
Download 'kubeconfig' and set EKS cluster.
Example usage:
atmos set-eks-cluster eks/cluster -s tenant1-ue1-dev -r admin
atmos set-eks-cluster eks/cluster -s tenant2-uw2-prod --role reader
description: Download 'kubeconfig' and set EKS cluster
verbose: false # Set to `true` to see verbose outputs
arguments:
- name: component
Expand Down
51 changes: 46 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,34 @@ package cmd

import (
"errors"
"fmt"
"os"

"github.com/elewis787/boa"
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

e "github.com/cloudposse/atmos/internal/exec"
tuiUtils "github.com/cloudposse/atmos/internal/tui/utils"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
)

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "atmos",
Short: "Universal Tool for DevOps and Cloud Automation",
Long: `'atmos' is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains`,
Example: "atmos",
Use: "atmos",
Short: "Universal Tool for DevOps and Cloud Automation",
Long: `Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains`,
PreRun: func(cmd *cobra.Command, args []string) {
// Print a styled Atmos logo to the terminal
fmt.Println()
err := tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(err)
}
},
Run: func(cmd *cobra.Command, args []string) {
err := e.ExecuteAtmosCmd()
if err != nil {
Expand All @@ -29,6 +41,25 @@ var RootCmd = &cobra.Command{
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the RootCmd.
func Execute() error {
cc.Init(&cc.Config{
RootCmd: RootCmd,
Headings: cc.HiCyan + cc.Bold + cc.Underline,
Commands: cc.HiGreen + cc.Bold,
Example: cc.Italic,
ExecName: cc.Bold,
Flags: cc.Bold,
})

// Check if the `help` flag is passed and print a styled Atmos logo to the terminal before printing the help
err := RootCmd.ParseFlags(os.Args)
if err != nil && errors.Is(err, pflag.ErrHelp) {
fmt.Println()
err = tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(err)
}
}

return RootCmd.Execute()
}

Expand Down Expand Up @@ -60,7 +91,17 @@ func initConfig() {
b := boa.New(boa.WithStyles(styles))

RootCmd.SetUsageFunc(b.UsageFunc)
RootCmd.SetHelpFunc(b.HelpFunc)

RootCmd.SetHelpFunc(func(command *cobra.Command, strings []string) {
// Print a styled Atmos logo to the terminal
fmt.Println()
err := tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(err)
}

b.HelpFunc(command, strings)
})
}

// https://www.sobyte.net/post/2021-12/create-cli-app-with-cobra/
Expand Down
15 changes: 6 additions & 9 deletions cmd/validate_component.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package cmd

import (
"fmt"

"github.com/fatih/color"
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
)

Expand All @@ -19,17 +20,13 @@ var validateComponentCmd = &cobra.Command{
"atmos validate component <component> -s <stack> --schema-path <schema_path> --schema-type opa --module-paths catalog",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
err := e.ExecuteValidateComponentCmd(cmd, args)
if err != nil {
u.LogErrorAndExit(err)
}

cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
component, stack, err := e.ExecuteValidateComponentCmd(cmd, args)
if err != nil {
u.LogErrorAndExit(err)
}

u.LogInfo(cliConfig, "component validated successfully\n")
m := fmt.Sprintf("component '%s' in the stack '%s' validated successfully", component, stack)
u.PrintMessageInColor(m, color.New(color.FgGreen))
},
}

Expand Down
10 changes: 2 additions & 8 deletions cmd/validate_stacks.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package cmd

import (
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
"github.com/fatih/color"
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
Expand All @@ -22,12 +21,7 @@ var ValidateStacksCmd = &cobra.Command{
u.LogErrorAndExit(err)
}

cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
if err != nil {
u.LogErrorAndExit(err)
}

u.LogInfo(cliConfig, "all stacks validated successfully\n")
u.PrintMessageInColor("all stacks validated successfully\n", color.New(color.FgGreen))
},
}

Expand Down
17 changes: 14 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"fmt"

tuiUtils "github.com/cloudposse/atmos/internal/tui/utils"
"github.com/spf13/cobra"

u "github.com/cloudposse/atmos/pkg/utils"
Expand All @@ -9,11 +12,19 @@ import (
var Version = "0.0.1"

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the CLI version",
Long: `This command prints the CLI version`,
Use: "version",
Short: "Print the CLI version",
Long: `This command prints the CLI version`,
Example: "atmos version",
Run: func(cmd *cobra.Command, args []string) {
// Print a styled Atmos logo to the terminal
fmt.Println()
err := tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(err)
}
u.PrintMessage(Version)
fmt.Println()
},
}

Expand Down
7 changes: 5 additions & 2 deletions demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ Type "# First check you have Atmos installed" Sleep 500ms Enter
Type "atmos version" Sleep 500ms Enter
Sleep 1s

Type "# Now let's explore the quick start example" Sleep 500ms Enter
Type "# Now let's explore the Quick Start example" Sleep 500ms Enter
Type "cd examples/quick-start" Sleep 500ms Enter

Type "ls -al" Sleep 500ms Enter
Sleep 1s

Type "# We will start by installing some 3rd-party components and other artifacts..." Sleep 500ms Enter
Type "atmos vendor pull" Sleep 500ms Enter
Sleep 7s

Type "# In Atmos you can easily explore components, stacks, and run commands..." Sleep 500ms Enter
Type "atmos" Sleep 500ms Enter
Sleep 2s

Down Sleep 500ms
Down Sleep 500ms
Up Sleep 500ms
Expand Down
Binary file modified docs/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions examples/quick-start/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Geodesic: https://github.com/cloudposse/geodesic/
ARG GEODESIC_VERSION=2.8.2
ARG GEODESIC_VERSION=2.8.3
ARG GEODESIC_OS=debian

# atmos: https://github.com/cloudposse/atmos
ARG ATMOS_VERSION=1.55.0
ARG ATMOS_VERSION=1.56.0

# Terraform: https://github.com/hashicorp/terraform/releases
ARG TF_VERSION=1.6.6
ARG TF_VERSION=1.7.0

FROM cloudposse/geodesic:${GEODESIC_VERSION}-${GEODESIC_OS}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@
"workflows": {
"type": "object",
"description": "Workflows section",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
}
},
"patternProperties": {
"^[\/a-zA-Z0-9-_{}. ]+$": {
"$ref": "#/definitions/workflow_manifest"
Expand Down
75 changes: 51 additions & 24 deletions examples/quick-start/stacks/workflows/networking.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,67 @@
name: Networking & Logging
description: Atmos workflows for managing VPCs and VPC Flow Logs

workflows:

plan-all-vpc-flow-logs-bucket-components:
description: |
Run 'terraform plan' on all 'vpc-flow-logs-bucket' components in all stacks
steps:
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-dev
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-dev
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-staging
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-staging
- command: terraform plan vpc-flow-logs-bucket -s plat-ue2-prod
- command: terraform plan vpc-flow-logs-bucket -s plat-uw2-prod
- name: Plan 'vpc-flow-logs-bucket' in 'plat-ue2-dev'
command: terraform plan vpc-flow-logs-bucket -s plat-ue2-dev
- name: Plan 'vpc-flow-logs-bucket' in 'plat-uw2-dev'
command: terraform plan vpc-flow-logs-bucket -s plat-uw2-dev
- name: Plan 'vpc-flow-logs-bucket' in 'plat-ue2-staging'
command: terraform plan vpc-flow-logs-bucket -s plat-ue2-staging
- name: Plan 'vpc-flow-logs-bucket' in 'plat-uw2-staging'
command: terraform plan vpc-flow-logs-bucket -s plat-uw2-staging
- name: Plan 'vpc-flow-logs-bucket' in 'plat-ue2-prod'
command: terraform plan vpvpc-flow-logs-bucketc -s plat-ue2-prod
- name: Plan 'vpc-flow-logs-bucket' in 'plat-uw2-prod'
command: terraform plan vpc-flow-logs-bucket -s plat-uw2-prod

plan-all-vpc-components:
description: |
Run 'terraform plan' on all 'vpc' components in all stacks
steps:
- command: terraform plan vpc -s plat-ue2-dev
- command: terraform plan vpc -s plat-uw2-dev
- command: terraform plan vpc -s plat-ue2-staging
- command: terraform plan vpc -s plat-uw2-staging
- command: terraform plan vpc -s plat-ue2-prod
- command: terraform plan vpc -s plat-uw2-prod
- name: Plan 'vpc' in 'plat-ue2-dev'
command: terraform plan vpc -s plat-ue2-dev
- name: Plan 'vpc' in 'plat-uw2-dev'
command: terraform plan vpc -s plat-uw2-dev
- name: Plan 'vpc' in 'plat-ue2-staging'
command: terraform plan vpc -s plat-ue2-staging
- name: Plan 'vpc' in 'plat-uw2-staging'
command: terraform plan vpc -s plat-uw2-staging
- name: Plan 'vpc' in 'plat-ue2-prod'
command: terraform plan vpc -s plat-ue2-prod
- name: Plan 'vpc' in 'plat-uw2-prod'
command: terraform plan vpc -s plat-uw2-prod

apply-all-components:
description: |
Run 'terraform apply' on all components in all stacks
steps:
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-dev -auto-approve
- command: terraform apply vpc -s plat-ue2-dev -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-dev -auto-approve
- command: terraform apply vpc -s plat-uw2-dev -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-staging -auto-approve
- command: terraform apply vpc -s plat-ue2-staging -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-staging -auto-approve
- command: terraform apply vpc -s plat-uw2-staging -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-ue2-prod -auto-approve
- command: terraform apply vpc -s plat-ue2-prod -auto-approve
- command: terraform apply vpc-flow-logs-bucket -s plat-uw2-prod -auto-approve
- command: terraform apply vpc -s plat-uw2-prod -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-ue2-dev`
command: terraform apply vpc-flow-logs-bucket -s plat-ue2-dev -auto-approve
- name: Apply 'vpc' in `plat-ue2-dev`
command: terraform apply vpc -s plat-ue2-dev -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-uw2-dev`
command: terraform apply vpc-flow-logs-bucket -s plat-uw2-dev -auto-approve
- name: Apply 'vpc' in `plat-uw2-dev`
command: terraform apply vpc -s plat-uw2-dev -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-ue2-staging`
command: terraform apply vpc-flow-logs-bucket -s plat-ue2-staging -auto-approve
- name: Apply `vpc` in `plat-ue2-staging`
command: terraform apply vpc -s plat-ue2-staging -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-uw2-staging`
command: terraform apply vpc-flow-logs-bucket -s plat-uw2-staging -auto-approve
- name: Apply `vpc` in `plat-uw2-staging`
command: terraform apply vpc -s plat-uw2-staging -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-ue2-prod`
command: terraform apply vpc-flow-logs-bucket -s plat-ue2-prod -auto-approve
- name: Apply `vpc` in `plat-ue2-prod`
command: terraform apply vpc -s plat-ue2-prod -auto-approve
- name: Apply `vpc-flow-logs-bucket` in `plat-uw2-prod`
command: terraform apply vpc-flow-logs-bucket -s plat-uw2-prod -auto-approve
- name: Apply `vpc` in `plat-uw2-prod`
command: terraform apply vpc -s plat-uw2-prod -auto-approve
36 changes: 36 additions & 0 deletions examples/quick-start/stacks/workflows/validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Validation
description: Atmos workflows for VPCs and VPC Flow Logs validation

workflows:

validate-all-vpc-components:
description: "Validate all VPC components in all stacks"
steps:
- name: Validate `vpc` in `plat-ue2-dev`
command: validate component vpc -s plat-ue2-dev
- name: Validate `vpc` in `plat-uw2-dev`
command: validate component vpc -s plat-uw2-dev
- name: Validate `vpc` in `plat-ue2-staging`
command: validate component vpc -s plat-ue2-staging
- name: Validate `vpc` in `plat-uw2-staging`
command: validate component vpc -s plat-uw2-staging
- name: Validate `vpc` in `plat-ue2-prod`
command: validate component vpc -s plat-ue2-prod
- name: Validate `vpc` in `plat-uw2-prod`
command: validate component vpc -s plat-uw2-prod

validate-all-vpc-flow-logs-bucket-components:
description: "Validate all VPC Flow Logs bucket components in all stacks"
steps:
- name: Validate `vpc-flow-logs-bucket` in `plat-ue2-dev`
command: validate component vpc-flow-logs-bucket -s plat-ue2-dev
- name: Validate `vpc-flow-logs-bucket` in `plat-uw2-dev`
command: validate component vpc-flow-logs-bucket -s plat-uw2-dev
- name: Validate `vpc-flow-logs-bucket` in `plat-ue2-staging`
command: validate component vpc-flow-logs-bucket -s plat-ue2-staging
- name: Validate `vpc-flow-logs-bucket` in `plat-uw2-staging`
command: validate component vpc-flow-logs-bucket -s plat-uw2-staging
- name: Validate `vpc-flow-logs-bucket` in `plat-ue2-prod`
command: validate component vpc-flow-logs-bucket -s plat-ue2-prod
- name: Validate `vpc-flow-logs-bucket` in `plat-uw2-prod`
command: validate component vpc-flow-logs-bucket -s plat-uw2-prod
2 changes: 1 addition & 1 deletion examples/tests/rootfs/usr/local/etc/atmos/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,4 @@ schemas:
atmos:
# Can also be set using 'ATMOS_SCHEMAS_ATMOS_MANIFEST' ENV var, or '--schemas-atmos-manifest' command-line arguments
# Supports both absolute and relative paths (relative to the `base_path` setting in `atmos.yaml`)
manifest: "../quick-start/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"
manifest: "stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"

0 comments on commit 34ba0f4

Please sign in to comment.