8000 Update `!store` YAML function by aknysh · Pull Request #1185 · cloudposse/atmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update !store YAML function #1185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/quick-start-advanced/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian
# https://atmos.tools/
# https://github.com/cloudposse/atmos
# https://github.com/cloudposse/atmos/releases
ARG ATMOS_VERSION=1.169.0
ARG ATMOS_VERSION=1.170.0

# Terraform: https://github.com/hashicorp/terraform/releases
ARG TF_VERSION=1.5.7
Expand Down
16 changes: 8 additions & 8 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions internal/exec/yaml_func_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"fmt"
"strings"

"github.com/charmbracelet/log"
log "github.com/charmbracelet/log"

"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
Expand All @@ -23,7 +23,7 @@

str, err := getStringAfterTag(input, u.AtmosYamlFuncStore)
if err != nil {
u.LogErrorAndExit(err)
log.Fatal(err)

Check warning on line 26 in internal/exec/yaml_func_store.go

View check run for this annotation

Codecov / codecov/patch

internal/exec/yaml_func_store.go#L26

Added line #L26 was not covered by tests
}

// Split the input on the pipe symbol to separate the store parameters and default value
Expand Down Expand Up @@ -55,8 +55,8 @@
}

if partsLength == 4 {
retParams.stack = strings.TrimSpace(storeParts[1])
retParams.component = strings.TrimSpace(storeParts[2])
retParams.component = strings.TrimSpace(storeParts[1])
retParams.stack = strings.TrimSpace(storeParts[2])
retParams.key = strings.TrimSpace(storeParts[3])
} else if partsLength == 3 {
retParams.stack = currentStack
Expand All @@ -68,7 +68,7 @@
store := atmosConfig.Stores[retParams.storeName]

if store == nil {
u.LogErrorAndExit(fmt.Errorf("invalid Atmos Store YAML function execution:: %s\nstore '%s' not found", input, retParams.storeName))
log.Fatal(fmt.Errorf("invalid Atmos Store YAML function execution:: %s\nstore '%s' not found", input, retParams.storeName))

Check warning on line 71 in internal/exec/yaml_func_store.go

View check run for this annotation

Codecov / codecov/patch

internal/exec/yaml_func_store.go#L71

Added line #L71 was not covered by tests
}

// Retrieve the value from the store
Expand All @@ -77,7 +77,7 @@
if retParams.defaultValue != nil {
return *retParams.defaultValue
}
u.LogErrorAndExit(fmt.Errorf("failed to get key: %s", err))
log.Fatal(fmt.Errorf("failed to get key: %s", err))

Check warning on line 80 in internal/exec/yaml_func_store.go

View check run for this annotation

Codecov / codecov/patch

internal/exec/yaml_func_store.go#L80

Added line #L80 was not covered by tests
}

return value
Expand Down
22 changes: 12 additions & 10 deletions internal/exec/yaml_func_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"testing"

"github.com/alicebob/miniredis/v2"
"github.com/cloudposse/atmos/pkg/schema"
"github.com/cloudposse/atmos/pkg/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cloudposse/atmos/pkg/schema"
"github.com/cloudposse/atmos/pkg/store"
)

func TestProcessTagStore(t *testing.T) {
Expand Down Expand Up @@ -54,45 +55,46 @@ func TestProcessTagStore(t *testing.T) {
},
{
name: "basic lookup cross-stack",
input: "!store redis dev vpc cidr",
input: "!store redis vpc dev cidr",
currentStack: "prod",
expected: "10.0.0.0/16",
},
{
name: "lookup with default value without quotes",
input: "!store redis staging vpc cidr | default 172.20.0.0/16",
input: "!store redis vpc staging cidr | default 172.20.0.0/16",
currentStack: "dev",
expected: "172.20.0.0/16",
},
{
name: "lookup with default value with single quotes",
input: "!store redis staging vpc cidr | default '172.20.0.0/16'",
input: "!store redis vpc staging cidr | default '172.20.0.0/16'",
currentStack: "dev",
expected: "172.20.0.0/16",
},
{
name: "lookup with default value with double quotes",
input: "!store redis staging vpc cidr | default \"172.20.0.0/16\"",
input: "!store redis vpc staging cidr | default \"172.20.0.0/16\"",
currentStack: "dev",
expected: "172.20.0.0/16",
},
{
name: "lookup with invalid default format",
input: "!store redis staging vpc cidr | default",
input: "!store redis vpc staging cidr | default",
currentStack: "dev",
expected: "invalid default value format in: redis staging vpc cidr | default",
expected: "invalid default value format in: redis vpc staging cidr | default",
},
{
name: "lookup with extra parameters after default",
input: "!store redis staging vpc cidr | default 172.20.0.0/16 extra",
input: "!store redis vpc staging cidr | default 172.20.0.0/16 extra",
currentStack: "dev",
expected: "invalid default value format in: redis staging vpc cidr | default 172.20.0.0/16 extra",
expected: "invalid default value format in: redis vpc staging cidr | default 172.20.0.0/16 extra",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := processTagStore(atmosConfig, tt.input, tt.currentStack)
t.Logf("%s: %v", tt.input, result)
assert.Equal(t, tt.expected, result)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ components:

## Specifying Atmos `stack`

If you call the `!temolate` function with three parameters, you need to specify the stack as the second argument.
If you call the `!terraform.output` function with three parameters, you need to specify the stack as the second argument.

There are multiple ways you can specify the Atmos stack parameter in the `!terraform.output` function.

Expand Down
6 changes: 3 additions & 3 deletions website/docs/core-concepts/workflows/workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ workflows:

workflow-1:
description: "Description of Workflow #1"
steps: [ ]
steps: []

workflow-2:
description: "Description of Workflow #2"
steps: [ ]
steps: []
```

Each workflow file must have the `workflows:` top-level section with a map of workflow definitions.
Expand Down Expand Up @@ -371,7 +371,7 @@ The Atmos stack used by the workflow commands of type `atmos` can be specified i
atmos workflow my-workflow -f workflow1 -s tenant1-ue2-dev
```

## Workflow Failure Handling and Resume
## Workflow Failure Handling and Resuming

When a workflow step fails, Atmos will:
1. Display which step failed
Expand Down
2 changes: 1 addition & 1 deletion website/docs/integrations/atlantis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ on:
branches: [ main ]

env:
ATMOS_VERSION: 1.169.0
ATMOS_VERSION: 1.170.0
ATMOS_CLI_CONFIG_PATH: ./

jobs:
Expand Down
Loading
0