Skip to content

Commit

Permalink
Merge branch 'main' into DEV-2835
Browse files Browse the repository at this point in the history
  • Loading branch information
Listener430 committed Jan 20, 2025
2 parents 1a25517 + 07c9e71 commit 9794c9b
Show file tree
Hide file tree
Showing 180 changed files with 6,733 additions and 692 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
insert_final_newline = true
end_of_line = lf

# Binary files (override to ensure no text-related rules are applied)
[*.{png,jpg,gif,svg,pdf,ai,eps,mp4}]
insert_final_newline = false
end_of_line = unset
indent_style = unset
indent_size = unset

# Override for machine generated binary HTML files in Screengrabs directory
[website/src/components/Screengrabs/**/*.html]
insert_final_newline = false
end_of_line = unset
indent_style = unset
indent_size = unset

# Override for machine generated binary files in tests/snapshots directory for golden snapshots
[test/snapshots/**/*.golden]
insert_final_newline = false
end_of_line = unset
indent_style = unset
indent_size = unset

# Override for Makefile
[{Makefile,makefile,GNUmakefile}]
indent_style = tab
Expand Down
16 changes: 14 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
* text eol=lf
# Always check-out / check-in files with LF line endings.
* text=auto eol=lf

docs linguist-documentation=true
website/src/components/screengrabs/**/*.html linguist-generated=true binary

# Screengrabs are binary HTML files that are automatically generated
website/src/components/Screengrabs/**/*.html linguist-generated=true binary

# Golden snapshots should be treated a raw output to prevent line-ending conversions
tests/snapshots/**/*.golden linguist-generated=true -text

# Mark binary files to prevent normalization
*.png binary
Expand All @@ -12,3 +19,8 @@ website/src/components/screengrabs/**/*.html linguist-generated=true binary
*.eps binary
*.ansi binary
*.mp4 binary

# Reduce merge conflicts that can occur when go.mod and go.sum files are updated
# Run `go mod tidy` to update the go.sum file
go.sum linguist-generated=true merge=union
go.mod linguist-generated=true merge=union
40 changes: 39 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ jobs:
path: |
./build/
tidy:
name: Tidy Go Modules
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go

- uses: j0hnsmith/go-mod-check@v1
with:
working-directory: ${{ github.workspace }}
# optional, only if you're happy to have `replace ` lines in your go.mod file
skip-replace-check: true

# run acceptance tests
test:
name: Acceptance Tests
Expand Down Expand Up @@ -140,8 +159,23 @@ jobs:
run: |
make deps
# Enable this after merging test-cases
# Only seems to work with remote schema files
#- name: Validate YAML Schema for Test Cases
# uses: InoUno/[email protected]
# with:
# root: "tests/test-cases"
# schemaMapping: |
# {
# "schema.json": [
# "**/*.yaml"
# ]
# }

- name: Acceptance tests
timeout-minutes: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make testacc

docker:
Expand Down Expand Up @@ -352,6 +386,8 @@ jobs:
- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
atmos test
Expand All @@ -369,6 +405,8 @@ jobs:
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'windows'
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
atmos test
Expand Down Expand Up @@ -446,7 +484,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Validate YAML Schema
- name: Validate YAML Schema for Stacks
uses: InoUno/[email protected]
with:
root: "examples/${{ matrix.demo-folder }}/stacks"
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"yaml.customTags": [
"!not scalar"
],
"[mdx]": { "editor.defaultFormatter": null, "editor.formatOnSave": false },
}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This works because `go list ./...` excludes vendor directories by default in modern versions of Go (1.11+).
# No need for grep or additional filtering.
TEST ?= $$(go list ./...)
TESTARGS ?=
SHELL := /bin/bash
#GOOS=darwin
#GOOS=linux
Expand Down
53 changes: 48 additions & 5 deletions atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,43 @@ logs:
# Can also be set using 'ATMOS_LOGS_LEVEL' ENV var, or '--logs-level' command-line argument
level: Info

validate:
# The configuration settings for the editorconfig-checker.

editorconfig:
# A list of file paths or patterns to exclude from checks.
exclude: []

# If set to true, the default ignore patterns (like .git/*) will not be applied.
ignore_defaults: false

# Runs the checker without making any changes or producing output, useful for testing configuration.
dry_run: false

# Specifies the output format. Options: "default", "json".
format: "default"

# Enables/Disables colored output in the terminal if .
color: true

# Disables checking for trailing whitespace at the end of lines.
disable_trim_trailing_whitespace: false

# Disables checking for consistent line endings (e.g., LF vs. CRLF).
disable_end_of_line: false

# Disables checking for the presence of a newline at the end of files.
disable_insert_final_newline: false

# Disables checking for consistent indentation style (e.g., tabs or spaces).
disable_indentation: false

# Disables checking for consistent indentation size (e.g., 2 spaces or 4 spaces).
disable_indent_size: false

# Disables checking for lines exceeding a maximum length.
disable_max_line_length: false

# Custom CLI commands
commands:
- name: tf
Expand Down Expand Up @@ -320,11 +357,17 @@ settings:

# Terminal settings for displaying content
terminal:
max_width: 120 # Maximum width for terminal output
pager: true # Use pager for long output
timestamps: false # Show timestamps in logs
colors: true # Enable colored output
unicode: true # Use unicode characters
max_width: 120 # Maximum width for terminal output
pager: true # Pager setting for all terminal output
colors: true # Enable colored output
unicode: true # Use unicode characters

syntax_highlighting:
enabled: true
formatter: terminal # Output formatter (e.g., terminal, html)
theme: dracula # Highlighting theme
line_numbers: true # Display line numbers
wrap: false # Wrap long lines

# Markdown element styling
markdown:
Expand Down
1 change: 1 addition & 0 deletions cmd/atlantis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var atlantisCmd = &cobra.Command{
Short: "Generate and manage Atlantis configurations",
Long: `Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation.`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
}

func init() {
Expand Down
1 change: 1 addition & 0 deletions cmd/atlantis_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var atlantisGenerateCmd = &cobra.Command{
Short: "Generate Atlantis configuration files",
Long: "This command generates configuration files to automate and streamline Terraform workflows with Atlantis.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
}

func init() {
Expand Down
5 changes: 4 additions & 1 deletion cmd/atlantis_generate_repo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ var atlantisGenerateRepoConfigCmd = &cobra.Command{
Long: "Generate the repository configuration file required for Atlantis to manage Terraform repositories.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
handleHelpRequest(cmd, args)
if len(args) > 0 {
showUsageAndExit(cmd, args)
}
// Check Atmos configuration
checkAtmosConfig()

err := e.ExecuteAtlantisGenerateRepoConfigCmd(cmd, args)
if err != nil {
u.LogErrorAndExit(schema.AtmosConfiguration{}, err)
Expand Down
1 change: 1 addition & 0 deletions cmd/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var awsCmd = &cobra.Command{
Short: "Run AWS-specific commands for interacting with cloud resources",
Long: `This command allows interaction with AWS resources through various CLI commands.`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
}

func init() {
Expand Down
1 change: 1 addition & 0 deletions cmd/aws_eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ You can use this command to interact with AWS EKS, including operations like con
For a list of available AWS EKS commands, refer to the Atmos documentation:
https://atmos.tools/cli/commands/aws/eks-update-kubeconfig`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
}

func init() {
Expand Down
66 changes: 65 additions & 1 deletion cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/samber/lo"
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
Expand Down Expand Up @@ -441,7 +442,7 @@ func checkAtmosConfig(opts ...AtmosValidateOption) {
atmosConfigExists, err := u.IsDirectory(atmosConfig.StacksBaseAbsolutePath)
if !atmosConfigExists || err != nil {
printMessageForMissingAtmosConfig(atmosConfig)
os.Exit(0)
os.Exit(1)
}
}
}
Expand Down Expand Up @@ -543,3 +544,66 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
func isVersionCommand() bool {
return len(os.Args) > 1 && os.Args[1] == "version"
}

// handleHelpRequest shows help content and exits only if the first argument is "help" or "--help" or "-h"
func handleHelpRequest(cmd *cobra.Command, args []string) {
if (len(args) > 0 && args[0] == "help") || Contains(args, "--help") || Contains(args, "-h") {
cmd.Help()
os.Exit(0)
}
}

func showUsageAndExit(cmd *cobra.Command, args []string) {

var suggestions []string
unknownCommand := fmt.Sprintf("Error: Unknown command: %q\n\n", cmd.CommandPath())

if len(args) > 0 {
suggestions = cmd.SuggestionsFor(args[0])
unknownCommand = fmt.Sprintf("Error: Unknown command %q for %q\n\n", args[0], cmd.CommandPath())
}
u.PrintErrorInColor(unknownCommand)
if len(suggestions) > 0 {
u.PrintMessage("Did you mean this?")
for _, suggestion := range suggestions {
u.PrintMessage(fmt.Sprintf(" %s\n", suggestion))
}
} else {
// Retrieve valid subcommands dynamically
validSubcommands := []string{}
for _, subCmd := range cmd.Commands() {
validSubcommands = append(validSubcommands, subCmd.Name())
}
if len(validSubcommands) > 0 {
u.PrintMessage("Valid subcommands are:")
for _, sub := range validSubcommands {
u.PrintMessage(fmt.Sprintf(" %s", sub))
}
} else {
u.PrintMessage("No valid subcommands found")
}
}
u.PrintMessage(fmt.Sprintf("\nRun '%s --help' for usage", cmd.CommandPath()))
os.Exit(1)
}

// getConfigAndStacksInfo gets the
func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []string) schema.ConfigAndStacksInfo {
// Check Atmos configuration
checkAtmosConfig()

var argsAfterDoubleDash []string
var finalArgs = args

doubleDashIndex := lo.IndexOf(args, "--")
if doubleDashIndex > 0 {
finalArgs = lo.Slice(args, 0, doubleDashIndex)
argsAfterDoubleDash = lo.Slice(args, doubleDashIndex+1, len(args))
}

info, err := e.ProcessCommandLineArgs(commandName, cmd, finalArgs, argsAfterDoubleDash)
if err != nil {
u.LogErrorAndExit(schema.AtmosConfiguration{}, err)
}
return info
}
Loading

0 comments on commit 9794c9b

Please sign in to comment.