-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c78ab33
commit b75be94
Showing
19 changed files
with
904 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package exec | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/charmbracelet/log" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
u "github.com/cloudposse/atmos/pkg/utils" | ||
) | ||
|
||
func processTagStore(cliConfig schema.CliConfiguration, input string, currentStack string) any { | ||
log.Debug("Executing Atmos YAML function store", "input", input) | ||
|
||
str, err := getStringAfterTag(input, u.AtmosYamlFuncStore) | ||
|
||
if err != nil { | ||
u.LogErrorAndExit(cliConfig, err) | ||
} | ||
|
||
parts := strings.Split(str, " ") | ||
if len(parts) != 2 { | ||
u.LogErrorAndExit(cliConfig, fmt.Errorf("invalid Atmos Store YAML function execution:: %s\nexactly two parameters are required: store_name, key", input)) | ||
} | ||
|
||
storeName := strings.TrimSpace(parts[0]) | ||
key := strings.TrimSpace(parts[1]) | ||
|
||
store := cliConfig.Stores[storeName] | ||
|
||
if store == nil { | ||
u.LogErrorAndExit(cliConfig, fmt.Errorf("invalid Atmos Store YAML function execution:: %s\nstore '%s' not found", input, storeName)) | ||
} | ||
|
||
value, err := store.Get(key) | ||
if err != nil { | ||
u.LogErrorAndExit(cliConfig, fmt.Errorf("invalid Atmos Store YAML function execution:: %s\nkey '%s' not found in store '%s'", input, key, storeName)) | ||
} | ||
|
||
return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package hooks | ||
|
||
type HookType string | ||
|
||
const ( | ||
AfterTerraformApply HookType = "after.terraform.apply" | ||
BeforeTerraformApply HookType = "before.terraform.apply" | ||
AfterTerraformPlan HookType = "after.terraform.plan" | ||
BeforeTerraformPlan HookType = "before.terraform.plan" | ||
) | ||
|
||
type Command string | ||
|
||
const ( | ||
Store Command = "store" | ||
) | ||
|
||
// Hook defines the structure of a hook | ||
type Hook struct { | ||
Events []string `yaml:"events"` | ||
Command string `yaml:"command"` | ||
|
||
// Dynamic command-specific properties | ||
|
||
// store command | ||
Name string `yaml:"name,omitempty"` // for store command | ||
Values map[string]interface{} `yaml:"values,omitempty"` // for store command | ||
} | ||
|
||
type Hooks struct { | ||
Hooks map[string]Hook `yaml:"hooks"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.