Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-store-writes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun authored Jan 7, 2025
2 parents 0fd21d7 + bc0841c commit 9eba367
Show file tree
Hide file tree
Showing 219 changed files with 879 additions and 596 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,25 @@ jobs:
- { os: windows-latest, target: windows }
- { os: macos-latest, target: macos }
demo-folder:
- demo-atlantis
# - demo-component-manifest
- demo-component-versions
- demo-context
# - demo-custom-command
# - demo-json-validation
# - demo-opa-validation
# - demo-opentofu
# - demo-project
# - demo-stacks
# - demo-terraform
# - demo-terraform-overrides
# - demo-workflows
# - demo-yaml-anchors
# - demo-mock-architecture
# - demo-stack-templating
# - demo-multi-cloud
- demo-vendoring
- tests
- examples/demo-atlantis
# - examples/demo-component-manifest
- examples/demo-component-versions
- examples/demo-context
# - examples/demo-custom-command
# - examples/demo-json-validation
# - examples/demo-opa-validation
# - examples/demo-opentofu
# - examples/demo-project
# - examples/demo-stacks
# - examples/demo-terraform
# - examples/demo-terraform-overrides
# - examples/demo-workflows
# - examples/demo-yaml-anchors
# - examples/demo-mock-architecture
# - examples/demo-stack-templating
# - examples/demo-multi-cloud
- examples/demo-vendoring
- tests/fixtures/scenarios/complete

timeout-minutes: 20
steps:
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
terraform_wrapper: false

- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: examples/${{ matrix.demo-folder }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
run: |
atmos test
Expand All @@ -366,7 +366,7 @@ jobs:
atmos version
- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: examples/${{ matrix.demo-folder }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'windows'
shell: pwsh
run: |
Expand Down
10 changes: 0 additions & 10 deletions atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,6 @@ settings:
# If the source and destination lists have the same length, all items in the destination lists are
# deep-merged with all items in the source list.
list_merge_strategy: replace
terminal:
syntax_highlighting:
enabled: true
lexer: yaml # Default lexer for the content
formatter: terminal # Output formatter (e.g., terminal, html)
style: dracula # Highlighting style
pager: true # Enable pager
options:
line_numbers: true # Display line numbers
wrap: false # Wrap long lines

# Terminal settings for displaying content
terminal:
Expand Down
4 changes: 2 additions & 2 deletions pkg/atlantis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ projects:
- name: tenant1-ue2-staging-test-test-component-override-3
workspace: test-component-override-3-workspace
workflow: workflow-1
dir: examples/tests/components/terraform/test/test-component
dir: tests/fixtures/scenarios/complete/components/terraform/test/test-component
terraform_version: v1.2
delete_source_branch_on_merge: true
autoplan:
Expand All @@ -135,7 +135,7 @@ projects:
- name: tenant1-ue2-staging-infra-vpc
workspace: tenant1-ue2-staging
workflow: workflow-1
dir: examples/tests/components/terraform/infra/vpc
dir: tests/fixtures/scenarios/complete/components/terraform/infra/vpc
terraform_version: v1.2
delete_source_branch_on_merge: true
autoplan:
Expand Down
2 changes: 1 addition & 1 deletion pkg/atlantis/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/aws/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
101 changes: 2 additions & 99 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ var (
Frequency: "daily",
},
},
Settings: &schema.AtmosSettings{
Terminal: &schema.TerminalSettings{
SyntaxHighlighting: &schema.SyntaxHighlightingSettings{
Enabled: true,
Lexer: "yaml",
Formatter: "terminal",
Style: "dracula",
Pager: false,
Options: &schema.SyntaxHighlightOptions{
LineNumbers: false,
Wrap: false,
},
},
},
},
}
)

Expand All @@ -126,17 +111,6 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks
v.SetConfigType("yaml")
v.SetTypeByDefaultValue(true)

// Load default configuration first
defaultConfigJSON, err := json.Marshal(defaultCliConfig)
if err != nil {
return atmosConfig, err
}

defaultReader := bytes.NewReader(defaultConfigJSON)
if err := v.ReadConfig(defaultReader); err != nil {
return atmosConfig, err
}

// Default configuration values
v.SetDefault("components.helmfile.use_eks", true)
v.SetDefault("components.terraform.append_user_agent", fmt.Sprintf("Atmos/%s (Cloud Posse; +https://atmos.tools)", version.Version))
Expand Down Expand Up @@ -289,31 +263,6 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks
atmosConfig.Components.Terraform.AppendUserAgent = fmt.Sprintf("Atmos/%s (Cloud Posse; +https://atmos.tools)", version.Version)
}

// Initialize settings with defaults if not set
if atmosConfig.Settings == nil {
atmosConfig.Settings = defaultCliConfig.Settings
} else {
// Only initialize nil fields with defaults
if atmosConfig.Settings.Terminal == nil {
atmosConfig.Settings.Terminal = defaultCliConfig.Settings.Terminal
} else if atmosConfig.Settings.Terminal.SyntaxHighlighting == nil {
atmosConfig.Settings.Terminal.SyntaxHighlighting = defaultCliConfig.Settings.Terminal.SyntaxHighlighting
} else {
// Update settings from viper
atmosConfig.Settings.Terminal.SyntaxHighlighting.Enabled = v.GetBool("settings.terminal.syntax_highlighting.enabled")
atmosConfig.Settings.Terminal.SyntaxHighlighting.Lexer = v.GetString("settings.terminal.syntax_highlighting.lexer")
atmosConfig.Settings.Terminal.SyntaxHighlighting.Formatter = v.GetString("settings.terminal.syntax_highlighting.formatter")
atmosConfig.Settings.Terminal.SyntaxHighlighting.Style = v.GetString("settings.terminal.syntax_highlighting.style")
atmosConfig.Settings.Terminal.SyntaxHighlighting.Pager = v.GetBool("settings.terminal.syntax_highlighting.pager")

if atmosConfig.Settings.Terminal.SyntaxHighlighting.Options == nil {
atmosConfig.Settings.Terminal.SyntaxHighlighting.Options = &schema.SyntaxHighlightOptions{}
}
atmosConfig.Settings.Terminal.SyntaxHighlighting.Options.LineNumbers = v.GetBool("settings.terminal.syntax_highlighting.options.line_numbers")
atmosConfig.Settings.Terminal.SyntaxHighlighting.Options.Wrap = v.GetBool("settings.terminal.syntax_highlighting.options.wrap")
}
}

// Check config
err = checkConfig(atmosConfig)
if err != nil {
Expand Down Expand Up @@ -426,56 +375,10 @@ func processConfigFile(
}
}(reader)

// Create a new viper instance for this config file
fileViper := viper.New()
fileViper.SetConfigType("yaml")

// Read the config file
if err := fileViper.ReadConfig(reader); err != nil {
err = v.MergeConfig(reader)
if err != nil {
return false, err
}

// Get all settings from the file
settings := fileViper.AllSettings()

// Merge settings into the main viper instance
for key, value := range settings {
if key == "settings" {
// Handle settings section separately to preserve nested values
if settingsMap, ok := value.(map[string]interface{}); ok {
if terminalMap, ok := settingsMap["terminal"].(map[string]interface{}); ok {
if syntaxMap, ok := terminalMap["syntax_highlighting"].(map[string]interface{}); ok {
// Set each field individually to preserve nested values
if enabled, ok := syntaxMap["enabled"].(bool); ok {
v.Set("settings.terminal.syntax_highlighting.enabled", enabled)
}
if lexer, ok := syntaxMap["lexer"].(string); ok {
v.Set("settings.terminal.syntax_highlighting.lexer", lexer)
}
if formatter, ok := syntaxMap["formatter"].(string); ok {
v.Set("settings.terminal.syntax_highlighting.formatter", formatter)
}
if style, ok := syntaxMap["style"].(string); ok {
v.Set("settings.terminal.syntax_highlighting.style", style)
}
if pager, ok := syntaxMap["pager"].(bool); ok {
v.Set("settings.terminal.syntax_highlighting.pager", pager)
}
if options, ok := syntaxMap["options"].(map[string]interface{}); ok {
if lineNumbers, ok := options["line_numbers"].(bool); ok {
v.Set("settings.terminal.syntax_highlighting.options.line_numbers", lineNumbers)
}
if wrap, ok := options["wrap"].(bool); ok {
v.Set("settings.terminal.syntax_highlighting.options.wrap", wrap)
}
}
}
}
}
} else {
v.Set(key, value)
}
}

return true, nil
}
2 changes: 1 addition & 1 deletion pkg/describe/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
8 changes: 4 additions & 4 deletions pkg/describe/describe_affected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestDescribeAffectedWithTargetRefClone(t *testing.T) {
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
assert.Nil(t, err)

// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../examples/tests",
// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../tests/fixtures/scenarios/complete",
// which will be wrong for the remote repo which is cloned into a temp dir.
// Set the correct base path for the cloned remote repo
atmosConfig.BasePath = "./examples/tests"
atmosConfig.BasePath = "./tests/fixtures/scenarios/complete"

// Git reference and commit SHA
// Refer to https://git-scm.com/book/en/v2/Git-Internals-Git-References for more details
Expand Down Expand Up @@ -53,10 +53,10 @@ func TestDescribeAffectedWithTargetRepoPath(t *testing.T) {
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
assert.Nil(t, err)

// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../examples/tests",
// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../tests/fixtures/scenarios/complete",
// which will be wrong for the remote repo which is cloned into a temp dir.
// Set the correct base path for the cloned remote repo
atmosConfig.BasePath = "./examples/tests"
atmosConfig.BasePath = "./tests/fixtures/scenarios/complete"

// Point to the same local repository
// This will compare this local repository with itself as the remote target, which should result in an empty `affected` list
Expand Down
2 changes: 1 addition & 1 deletion pkg/generate/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/list/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
54 changes: 18 additions & 36 deletions pkg/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type AtmosConfiguration struct {
Integrations Integrations `yaml:"integrations,omitempty" json:"integrations,omitempty" mapstructure:"integrations"`
Schemas Schemas `yaml:"schemas,omitempty" json:"schemas,omitempty" mapstructure:"schemas"`
Templates Templates `yaml:"templates,omitempty" json:"templates,omitempty" mapstructure:"templates"`
Settings *AtmosSettings `yaml:"settings,omitempty" json:"settings,omitempty" mapstructure:"settings"`
Settings AtmosSettings `yaml:"settings,omitempty" json:"settings,omitempty" mapstructure:"settings"`
StoresConfig store.StoresConfig `yaml:"stores,omitempty" json:"stores,omitempty" mapstructure:"stores"`
Vendor Vendor `yaml:"vendor,omitempty" json:"vendor,omitempty" mapstructure:"vendor"`
Initialized bool `yaml:"initialized" json:"initialized" mapstructure:"initialized"`
Expand All @@ -37,43 +37,19 @@ type AtmosConfiguration struct {
Stores store.StoreRegistry `yaml:"stores_registry,omitempty" json:"stores_registry,omitempty" mapstructure:"stores_registry"`
}

type AtmosSettings struct {
ListMergeStrategy string `yaml:"list_merge_strategy" json:"list_merge_strategy" mapstructure:"list_merge_strategy"`
Terminal *TerminalSettings `yaml:"terminal,omitempty" json:"terminal,omitempty" mapstructure:"terminal"`
Docs Docs `yaml:"docs,omitempty" json:"docs,omitempty" mapstructure:"docs"`
Markdown MarkdownSettings `yaml:"markdown,omitempty" json:"markdown,omitempty" mapstructure:"markdown"`
}

type TerminalSettings struct {
MaxWidth int `yaml:"max_width,omitempty" json:"max_width,omitempty" mapstructure:"max_width"`
Pager bool `yaml:"pager,omitempty" json:"pager,omitempty" mapstructure:"pager"`
Timestamps bool `yaml:"timestamps,omitempty" json:"timestamps,omitempty" mapstructure:"timestamps"`
Colors bool `yaml:"colors,omitempty" json:"colors,omitempty" mapstructure:"colors"`
Unicode bool `yaml:"unicode,omitempty" json:"unicode,omitempty" mapstructure:"unicode"`
SyntaxHighlighting *SyntaxHighlightingSettings `yaml:"syntax_highlighting,omitempty" json:"syntax_highlighting,omitempty" mapstructure:"syntax_highlighting"`
}

type SyntaxHighlightOptions struct {
LineNumbers bool `yaml:"line_numbers" json:"line_numbers" mapstructure:"line_numbers"`
Wrap bool `yaml:"wrap" json:"wrap" mapstructure:"wrap"`
}

type SyntaxHighlightingSettings struct {
Enabled bool `yaml:"enabled" json:"enabled" mapstructure:"enabled"`
Lexer string `yaml:"lexer" json:"lexer" mapstructure:"lexer"`
Formatter string `yaml:"formatter" json:"formatter" mapstructure:"formatter"`
Style string `yaml:"style" json:"style" mapstructure:"style"`
Pager bool `yaml:"pager" json:"pager" mapstructure:"pager"`
Options *SyntaxHighlightOptions `yaml:"options,omitempty" json:"options,omitempty" mapstructure:"options"`
type Terminal struct {
MaxWidth int `yaml:"max_width" json:"max_width" mapstructure:"max_width"`
Pager bool `yaml:"pager" json:"pager" mapstructure:"pager"`
Timestamps bool `yaml:"timestamps" json:"timestamps" mapstructure:"timestamps"`
Colors bool `yaml:"colors" json:"colors" mapstructure:"colors"`
Unicode bool `yaml:"unicode" json:"unicode" mapstructure:"unicode"`
}

type Settings struct {
DependsOn DependsOn `yaml:"depends_on,omitempty" json:"depends_on,omitempty" mapstructure:"depends_on"`
Spacelift SettingsSpacelift `yaml:"spacelift,omitempty" json:"spacelift,omitempty" mapstructure:"spacelift"`
Templates Templates `yaml:"templates,omitempty" json:"templates,omitempty" mapstructure:"templates"`
ListMergeStrategy string `yaml:"list_merge_strategy,omitempty" json:"list_merge_strategy,omitempty"`
Terminal *TerminalSettings `yaml:"terminal,omitempty" json:"terminal,omitempty" mapstructure:"terminal"`
Docs *Docs `yaml:"docs,omitempty" json:"docs,omitempty" mapstructure:"docs"`
type AtmosSettings struct {
ListMergeStrategy string `yaml:"list_merge_strategy" json:"list_merge_strategy" mapstructure:"list_merge_strategy"`
Terminal Terminal `yaml:"terminal,omitempty" json:"terminal,omitempty" mapstructure:"terminal"`
Docs Docs `yaml:"docs,omitempty" json:"docs,omitempty" mapstructure:"docs"`
Markdown MarkdownSettings `yaml:"markdown,omitempty" json:"markdown,omitempty" mapstructure:"markdown"`
}

type Docs struct {
Expand Down Expand Up @@ -565,6 +541,12 @@ type Dependent struct {

type SettingsSpacelift AtmosSectionMapType

type Settings struct {
DependsOn DependsOn `yaml:"depends_on,omitempty" json:"depends_on,omitempty" mapstructure:"depends_on"`
Spacelift SettingsSpacelift `yaml:"spacelift,omitempty" json:"spacelift,omitempty" mapstructure:"spacelift"`
Templates Templates `yaml:"templates,omitempty" json:"templates,omitempty" mapstructure:"templates"`
}

// ConfigSourcesStackDependency defines schema for sources of config sections
type ConfigSourcesStackDependency struct {
StackFile string `yaml:"stack_file" json:"stack_file" mapstructure:"stack_file"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/spacelift/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
Loading

0 comments on commit 9eba367

Please sign in to comment.