Skip to content

Commit

Permalink
Merge branch 'main' into feat/DEV-2849_metadata-locked
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh authored Jan 7, 2025
2 parents 4965f7c + 2019d88 commit 880240e
Show file tree
Hide file tree
Showing 18 changed files with 724 additions and 220 deletions.
45 changes: 45 additions & 0 deletions cmd/about.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package cmd

import (
_ "embed"
"fmt"
"os"

"github.com/charmbracelet/glamour"
"github.com/spf13/cobra"
)

//go:embed markdown/about.md
var aboutMarkdown string

// aboutCmd represents the about command
var aboutCmd = &cobra.Command{
Use: "about",
Short: "Learn about Atmos",
Long: `Display information about Atmos, its features, and benefits.`,
Args: cobra.NoArgs,
DisableSuggestions: true,
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(80),
)
if err != nil {
return fmt.Errorf("failed to create markdown renderer: %w", err)
}

out, err := renderer.Render(aboutMarkdown)
if err != nil {
return fmt.Errorf("failed to render about documentation: %w", err)
}

fmt.Fprint(os.Stdout, out)
return nil
},
}

func init() {
RootCmd.AddCommand(aboutCmd)
}
5 changes: 0 additions & 5 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,6 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
}
}

func customHelpMessageToUpgradeToAtmosLatestRelease(cmd *cobra.Command, args []string) {
originalHelpFunc(cmd, args)
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
}

// Check Atmos is version command
func isVersionCommand() bool {
return len(os.Args) > 1 && os.Args[1] == "version"
Expand Down
6 changes: 4 additions & 2 deletions cmd/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ var helmfileCmd = &cobra.Command{
u.LogErrorAndExit(schema.AtmosConfiguration{}, err)
}
// Exit on help
if info.NeedHelp {
if info.NeedHelp || (info.SubCommand == "" && info.SubCommand2 == "") {
// Check for the latest Atmos release on GitHub and print update message
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
if err := cmd.Help(); err != nil {
u.LogErrorAndExit(schema.AtmosConfiguration{}, err)
}
return
}
// Check Atmos configuration
Expand Down
20 changes: 20 additions & 0 deletions cmd/markdown/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# About Atmos

Atmos is an open-source framework for managing the configuration of Infrastructure as Code (IaC) at scale using Stacks.

It simplifies the deployment of infrastructure by providing a consistent, YAML-driven configuration system using tools like Terraform and Helmfile. Atmos helps teams adopt best practices, enforce standards, and automate complex workflows across environments.

## Key Features

- **Reusable Components**: Modular building blocks for defining infrastructure.
- **Stacks**: Environment-specific configurations for managing multiple AWS accounts.
- **YAML-Based**: Declarative configurations for easy maintenance.
- **Terraform & Helmfile**: Unified commands for seamless integration.
- **Automation-Ready**: Perfect for CI/CD pipelines and DevOps workflows.
- **Scalable**: Designed for multi-account, multi-environment AWS setups.

## Why Atmos?
Atmos reduces complexity, promotes consistency, and accelerates delivery, making it an ideal choice
for organizations managing large-scale AWS infrastructure.

Learn more [here](https://atmos.tools)
31 changes: 31 additions & 0 deletions cmd/markdown/support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Support

## Community Resources

Need help? Join the [Atmos community!](https://cloudposse.com/slack)

- **Slack Community**: Connect with active users in the `#atmos` channel and get help anytime [on slack](https://cloudposse.com/slack).
- **GitHub Discussions**: Post questions or join conversations with the community and Cloud Posse.
- **Issue Tracker**: Found a bug? Report it [here](https://github.com/cloudposse/atmos/issues).

## Office Hours

We hold **office hours every Wednesday at 11:30 AM PST**. Join us for live Q&A sessions.

[](https://cloudposse.com/office-hours)

## Paid Support

We offer priority support to GitHub Sponsors (Enterprise Tier).

[](https://github.com/sponsors/cloudposse)

Included with sponsorship, we host **30-minute workshops twice a week** to:
- Answer your questions.
- Assist with debugging issues.
- Discuss architectural decisions.

Workshops are tailored to help you succeed with Atmos, our AWS Reference Architectures, and related tools.

> **Note**: Paid support includes priority responses.
> [](https://github.com/sponsors/cloudposse)
54 changes: 23 additions & 31 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/elewis787/boa"
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/internal/tui/templates"
Expand All @@ -20,9 +19,6 @@ import (

var atmosConfig schema.AtmosConfiguration

// originalHelpFunc holds Cobra's original help function to avoid recursion.
var originalHelpFunc func(*cobra.Command, []string)

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "atmos",
Expand Down Expand Up @@ -74,15 +70,6 @@ func Execute() error {
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(schema.AtmosConfiguration{}, err)
}
}
// InitCliConfig finds and merges CLI configurations in the following order:
// system dir, home dir, current dir, ENV vars, command-line arguments
// Here we need the custom commands from the config
Expand All @@ -95,15 +82,7 @@ func Execute() error {
u.LogErrorAndExit(schema.AtmosConfiguration{}, initErr)
}
}

// Save the original help function to prevent infinite recursion when overriding it.
// This allows us to call the original help functionality within our custom help function.
originalHelpFunc = RootCmd.HelpFunc()

// Override the help function with a custom one that adds an upgrade message after displaying help.
// This custom help function will call the original help function and then display the bordered message.
RootCmd.SetHelpFunc(customHelpMessageToUpgradeToAtmosLatestRelease)

var err error
// If CLI configuration was found, process its custom commands and command aliases
if initErr == nil {
err = processCustomCommands(atmosConfig, atmosConfig.Commands, RootCmd, true)
Expand Down Expand Up @@ -132,25 +111,38 @@ func init() {

// Set custom usage template
templates.SetCustomUsageFunc(RootCmd)
cobra.OnInitialize(initConfig)
initCobraConfig()
}

func initConfig() {
func initCobraConfig() {
RootCmd.SetOut(os.Stdout)
styles := boa.DefaultStyles()
b := boa.New(boa.WithStyles(styles))

oldUsageFunc := RootCmd.UsageFunc()
RootCmd.SetUsageFunc(b.UsageFunc)

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(schema.AtmosConfiguration{}, err)
if command.Use != "atmos" || command.Flags().Changed("help") {
err := tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(atmosConfig, err)
}
if err := oldUsageFunc(command); err != nil {
u.LogErrorAndExit(atmosConfig, err)
}
} else {
err := tuiUtils.PrintStyledText("ATMOS")
if err != nil {
u.LogErrorAndExit(atmosConfig, err)
}
b.HelpFunc(command, strings)
if err := command.Usage(); err != nil {
u.LogErrorAndExit(atmosConfig, err)
}
}

b.HelpFunc(command, strings)
command.Usage()
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
})
}

Expand Down
45 changes: 45 additions & 0 deletions cmd/support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package cmd

import (
_ "embed"
"fmt"
"os"

"github.com/charmbracelet/glamour"
"github.com/spf13/cobra"
)

//go:embed markdown/support.md
var supportMarkdown string

// supportCmd represents the support command
var supportCmd = &cobra.Command{
Use: "support",
Short: "Show Atmos support options",
Long: `Display information about Atmos support options, including community resources and paid support.`,
Args: cobra.NoArgs,
DisableSuggestions: true,
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(80),
)
if err != nil {
return fmt.Errorf("failed to create markdown renderer: %w", err)
}

out, err := renderer.Render(supportMarkdown)
if err != nil {
return fmt.Errorf("failed to render support documentation: %w", err)
}

fmt.Fprint(os.Stdout, out)
return nil
},
}

func init() {
RootCmd.AddCommand(supportCmd)
}
Loading

0 comments on commit 880240e

Please sign in to comment.