Skip to content

Commit

Permalink
Use format v$MAJOR.$MINOR.$PATCH for auto-release tags. Move public…
Browse files Browse the repository at this point in the history
… packages from `internal` folder (#63)
  • Loading branch information
aknysh authored Oct 18, 2021
1 parent 42882e2 commit 9da16c8
Show file tree
Hide file tree
Showing 29 changed files with 51 additions and 47 deletions.
6 changes: 5 additions & 1 deletion .github/auto-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'

# https://golang.org/ref/mod#versions
tag-template: 'v$RESOLVED_VERSION'

version-template: '$MAJOR.$MINOR.$PATCH'

version-resolver:
major:
labels:
Expand Down
10 changes: 5 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
g "github.com/cloudposse/atmos/internal/globals"
u "github.com/cloudposse/atmos/internal/utils"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
Expand Down Expand Up @@ -194,14 +194,14 @@ func InitConfig(configAndStacksInfo ConfigAndStacksInfo) error {
ProcessedConfig.StacksBaseAbsolutePath = stacksBaseAbsPath

// Convert the included stack paths to absolute paths
includeStackAbsPaths, err := u.JoinAbsolutePathWithPaths(stacksBaseAbsPath, Config.Stacks.IncludedPaths)
includeStackAbsPaths, err := utils.JoinAbsolutePathWithPaths(stacksBaseAbsPath, Config.Stacks.IncludedPaths)
if err != nil {
return err
}
ProcessedConfig.IncludeStackAbsolutePaths = includeStackAbsPaths

// Convert the excluded stack paths to absolute paths
excludeStackAbsPaths, err := u.JoinAbsolutePathWithPaths(stacksBaseAbsPath, Config.Stacks.ExcludedPaths)
excludeStackAbsPaths, err := utils.JoinAbsolutePathWithPaths(stacksBaseAbsPath, Config.Stacks.ExcludedPaths)
if err != nil {
return err
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func InitConfig(configAndStacksInfo ConfigAndStacksInfo) error {

if g.LogVerbose {
color.Cyan("\nFinal CLI configuration:")
err = u.PrintAsYAML(Config)
err = utils.PrintAsYAML(Config)
if err != nil {
return err
}
Expand All @@ -292,7 +292,7 @@ func InitConfig(configAndStacksInfo ConfigAndStacksInfo) error {
// https://github.com/spf13/viper/issues/181
// https://medium.com/@bnprashanth256/reading-configuration-files-and-environment-variables-in-go-golang-c2607f912b63
func processConfigFile(path string, v *viper.Viper) error {
if !u.FileExists(path) {
if !utils.FileExists(path) {
if g.LogVerbose {
fmt.Println(fmt.Sprintf("No config found in %s", path))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"github.com/bmatcuk/doublestar"
g "github.com/cloudposse/atmos/internal/globals"
u "github.com/cloudposse/atmos/internal/utils"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"os"
"path/filepath"
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
c "github.com/cloudposse/atmos/internal/config"
g "github.com/cloudposse/atmos/internal/globals"
s "github.com/cloudposse/atmos/internal/stack"
u "github.com/cloudposse/atmos/internal/utils"
s "github.com/cloudposse/atmos/pkg/stack"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions internal/exec/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package exec
import (
"fmt"
c "github.com/cloudposse/atmos/internal/config"
u "github.com/cloudposse/atmos/internal/utils"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -30,7 +30,7 @@ func ExecuteHelmfile(cmd *cobra.Command, args []string) error {
}

componentPath := path.Join(c.ProcessedConfig.HelmfileDirAbsolutePath, info.ComponentFolderPrefix, info.Component)
componentPathExists, err := u.IsDirectory(componentPath)
componentPathExists, err := utils.IsDirectory(componentPath)
if err != nil || !componentPathExists {
return errors.New(fmt.Sprintf("Component '%s' does not exixt in %s",
info.Component,
Expand Down Expand Up @@ -59,7 +59,7 @@ func ExecuteHelmfile(cmd *cobra.Command, args []string) error {

color.Cyan("Writing variables to file:")
fmt.Println(varFileName)
err = u.WriteToFileAsYAML(varFileName, info.ComponentVarsSection, 0644)
err = utils.WriteToFileAsYAML(varFileName, info.ComponentVarsSection, 0644)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/exec/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package exec
import (
"fmt"
c "github.com/cloudposse/atmos/internal/config"
u "github.com/cloudposse/atmos/internal/utils"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,7 +41,7 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {

// Check if the component exists
componentPath := path.Join(c.ProcessedConfig.TerraformDirAbsolutePath, info.ComponentFolderPrefix, finalComponent)
componentPathExists, err := u.IsDirectory(componentPath)
componentPathExists, err := utils.IsDirectory(componentPath)
if err != nil || !componentPathExists {
return errors.New(fmt.Sprintf("Component '%s' does not exixt in %s",
finalComponent,
Expand Down Expand Up @@ -85,7 +85,7 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {

color.Cyan("Writing variables to file:")
fmt.Println(varFileName)
err = u.WriteToFileAsJSON(varFileName, info.ComponentVarsSection, 0644)
err = utils.WriteToFileAsJSON(varFileName, info.ComponentVarsSection, 0644)
if err != nil {
return err
}
Expand Down Expand Up @@ -113,14 +113,14 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {
// Handle `terraform deploy` custom command
if info.SubCommand == "deploy" {
info.SubCommand = "apply"
if !u.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
if !utils.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
info.AdditionalArgsAndFlags = append(info.AdditionalArgsAndFlags, autoApproveFlag)
}
}

// Handle Config.Components.Terraform.ApplyAutoApprove flag
if info.SubCommand == "apply" && c.Config.Components.Terraform.ApplyAutoApprove == true {
if !u.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
if !utils.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
info.AdditionalArgsAndFlags = append(info.AdditionalArgsAndFlags, autoApproveFlag)
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {

// Check if the terraform command requires a user interaction,
// but it's running in a scripted environment (where a `tty` is not attached or `stdin` is not attached)
if os.Stdin == nil && !u.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
if os.Stdin == nil && !utils.SliceContainsString(info.AdditionalArgsAndFlags, autoApproveFlag) {
errorMessage := ""
if info.SubCommand == "apply" {
errorMessage = "'terraform apply' requires a user interaction, but it's running without `tty` or `stdin` attached." +
Expand Down
10 changes: 5 additions & 5 deletions internal/exec/terraform_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
c "github.com/cloudposse/atmos/internal/config"
g "github.com/cloudposse/atmos/internal/globals"
s "github.com/cloudposse/atmos/internal/stack"
u "github.com/cloudposse/atmos/internal/utils"
s "github.com/cloudposse/atmos/pkg/stack"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -45,7 +45,7 @@ func ExecuteTerraformGenerateBackend(cmd *cobra.Command, args []string) error {
}
color.Cyan(msg)

err = u.PrintAsYAML(c.ProcessedConfig.StackConfigFilesRelativePaths)
err = utils.PrintAsYAML(c.ProcessedConfig.StackConfigFilesRelativePaths)
if err != nil {
return err
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func ExecuteTerraformGenerateBackend(cmd *cobra.Command, args []string) error {
}

color.Cyan("\nComponent backend config:\n\n")
err = u.PrintAsJSON(componentBackendConfig)
err = utils.PrintAsJSON(componentBackendConfig)
if err != nil {
return err
}
Expand Down Expand Up @@ -188,7 +188,7 @@ func ExecuteTerraformGenerateBackend(cmd *cobra.Command, args []string) error {

color.Cyan("\nWriting backend config to file:")
fmt.Println(varFileName)
err = u.WriteToFileAsJSON(varFileName, componentBackendConfig, 0644)
err = utils.WriteToFileAsJSON(varFileName, componentBackendConfig, 0644)
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/exec/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
c "github.com/cloudposse/atmos/internal/config"
g "github.com/cloudposse/atmos/internal/globals"
s "github.com/cloudposse/atmos/internal/stack"
u "github.com/cloudposse/atmos/internal/utils"
s "github.com/cloudposse/atmos/pkg/stack"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/spf13/cobra"
"os"
Expand Down Expand Up @@ -181,7 +181,7 @@ func processConfigAndStacks(componentType string, cmd *cobra.Command, args []str
msg = "Found config files:"
}
color.Cyan(msg)
err = u.PrintAsYAML(c.ProcessedConfig.StackConfigFilesRelativePaths)
err = utils.PrintAsYAML(c.ProcessedConfig.StackConfigFilesRelativePaths)
if err != nil {
return configAndStacksInfo, err
}
Expand Down Expand Up @@ -295,7 +295,7 @@ func processConfigAndStacks(componentType string, cmd *cobra.Command, args []str
}

color.Cyan("\nVariables for the component '%s' in the stack '%s':\n\n", configAndStacksInfo.ComponentFromArg, configAndStacksInfo.Stack)
err = u.PrintAsYAML(configAndStacksInfo.ComponentVarsSection)
err = utils.PrintAsYAML(configAndStacksInfo.ComponentVarsSection)
if err != nil {
return configAndStacksInfo, err
}
Expand Down Expand Up @@ -470,7 +470,7 @@ func processArgsAndFlags(inputArgsAndFlags []string) (c.ArgsAndFlagsInfo, error)
}

for i, arg := range inputArgsAndFlags {
if !u.SliceContainsInt(indexesToRemove, i) {
if !utils.SliceContainsInt(indexesToRemove, i) {
additionalArgsAndFlags = append(additionalArgsAndFlags, arg)
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package spacelift

import (
"fmt"
s "github.com/cloudposse/atmos/internal/stack"
u "github.com/cloudposse/atmos/internal/utils"
s "github.com/cloudposse/atmos/pkg/stack"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/pkg/errors"
"strings"
)
Expand Down Expand Up @@ -65,7 +65,7 @@ func TransformStackConfigToSpaceliftStacks(
if terraformComponents, ok := componentsSection["terraform"]; ok {
terraformComponentsMap := terraformComponents.(map[string]interface{})

terraformComponentNamesInCurrentStack := u.StringKeysFromMap(terraformComponentsMap)
terraformComponentNamesInCurrentStack := utils.StringKeysFromMap(terraformComponentsMap)

for component, v := range terraformComponentsMap {
componentMap := v.(map[string]interface{})
Expand Down Expand Up @@ -191,7 +191,7 @@ func TransformStackConfigToSpaceliftStacks(
labels = append(labels, fmt.Sprintf("folder:component/%s", component))
labels = append(labels, fmt.Sprintf("folder:%s", stackName))

spaceliftConfig["labels"] = u.UniqueStrings(labels)
spaceliftConfig["labels"] = utils.UniqueStrings(labels)

// Add Spacelift stack config to the final map
spaceliftStackName := strings.Replace(fmt.Sprintf("%s-%s", stackName, component), "/", "-", -1)
Expand All @@ -213,9 +213,9 @@ func buildSpaceliftDependsOnStackName(
) (string, error) {
var spaceliftStackName string

if u.SliceContainsString(allStackNames, dependsOn) {
if utils.SliceContainsString(allStackNames, dependsOn) {
spaceliftStackName = dependsOn
} else if u.SliceContainsString(componentNamesInCurrentStack, dependsOn) {
} else if utils.SliceContainsString(componentNamesInCurrentStack, dependsOn) {
spaceliftStackName = fmt.Sprintf("%s-%s", currentStackName, dependsOn)
} else {
errorMessage := errors.New(fmt.Sprintf("Component '%[1]s' in stack '%[2]s' specifies 'depends_on' dependency '%[3]s', "+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package stack
import (
"fmt"
"github.com/bmatcuk/doublestar"
c "github.com/cloudposse/atmos/internal/convert"
g "github.com/cloudposse/atmos/internal/globals"
m "github.com/cloudposse/atmos/internal/merge"
u "github.com/cloudposse/atmos/internal/utils"
c "github.com/cloudposse/atmos/pkg/convert"
m "github.com/cloudposse/atmos/pkg/merge"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
"io/ioutil"
Expand Down Expand Up @@ -57,7 +57,7 @@ func ProcessYAMLConfigFiles(
imports = append(imports, k)
}

uniqueImports := u.UniqueStrings(imports)
uniqueImports := utils.UniqueStrings(imports)
sort.Strings(uniqueImports)

componentStackMap := map[string]map[string][]string{}
Expand Down Expand Up @@ -85,7 +85,7 @@ func ProcessYAMLConfigFiles(

stackName := strings.TrimSuffix(
strings.TrimSuffix(
u.TrimBasePathFromPath(stackBasePath+"/", p),
utils.TrimBasePathFromPath(stackBasePath+"/", p),
g.DefaultStackConfigFileExtension),
".yml",
)
Expand Down Expand Up @@ -206,7 +206,7 @@ func ProcessConfig(

stackName := strings.TrimSuffix(
strings.TrimSuffix(
u.TrimBasePathFromPath(basePath+"/", stack),
utils.TrimBasePathFromPath(basePath+"/", stack),
g.DefaultStackConfigFileExtension),
".yml",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package stack

import (
c "github.com/cloudposse/atmos/internal/convert"
u "github.com/cloudposse/atmos/internal/utils"
c "github.com/cloudposse/atmos/pkg/convert"
u "github.com/cloudposse/atmos/pkg/utils"
"testing"

"github.com/stretchr/testify/assert"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package stack

import (
g "github.com/cloudposse/atmos/internal/globals"
u "github.com/cloudposse/atmos/internal/utils"
"github.com/cloudposse/atmos/pkg/utils"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -31,7 +31,7 @@ func FindComponentStacks(
}
}

unique := u.UniqueStrings(stacks)
unique := utils.UniqueStrings(stacks)
sort.Strings(unique)
return unique, nil
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func FindComponentDependencies(
}

deps = append(deps, stack)
unique := u.UniqueStrings(deps)
unique := utils.UniqueStrings(deps)
sort.Strings(unique)
return unique, nil
}
Expand All @@ -127,12 +127,12 @@ func CreateComponentStackMap(basePath string, filePath string) (map[string]map[s
return err
}

isDirectory, err := u.IsDirectory(p)
isDirectory, err := utils.IsDirectory(p)
if err != nil {
return err
}

isYaml := u.IsYaml(p)
isYaml := utils.IsYaml(p)

if !isDirectory && isYaml {
config, _, err := ProcessYAMLConfigFile(basePath, p, map[string]map[interface{}]interface{}{})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9da16c8

Please sign in to comment.