Skip to content

Commit

Permalink
Various fixes (cloudposse#109)
Browse files Browse the repository at this point in the history
* Various fixes

* Various fixes

* Various fixes
  • Loading branch information
aknysh authored Jan 24, 2022
1 parent f817119 commit 93ade5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 50 deletions.
20 changes: 10 additions & 10 deletions examples/complete/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# https://github.com/cloudposse/geodesic/
ARG GEODESIC_VERSION=0.147.11
# Geodesic: https://github.com/cloudposse/geodesic/
ARG GEODESIC_VERSION=0.149.0
ARG GEODESIC_OS=debian
# https://github.com/cloudposse/atmos
ARG ATMOS_VERSION=1.3.23
# atmos: https://github.com/cloudposse/atmos
ARG ATMOS_VERSION=1.3.24
# Terraform
ARG TF_VERSION=1.1.4

FROM cloudposse/geodesic:${GEODESIC_VERSION}-${GEODESIC_OS}

Expand All @@ -21,17 +23,15 @@ ENV DIRENV_ENABLED=false
ENV AWS_SDK_LOAD_CONFIG=1
ENV AWS_DEFAULT_REGION=us-east-2

# Install specific versions of Terraform
ARG TF_1_0_VERSION=1.1.3
# Install specific version of Terraform
ARG TF_VERSION
RUN apt-get update && apt-get install -y -u --allow-downgrades \
terraform-1="${TF_1_0_VERSION}-*" && \
terraform-1="${TF_VERSION}-*" && \
update-alternatives --set terraform /usr/share/terraform/1/bin/terraform

ARG ATMOS_VERSION
RUN apt-get update && apt-get install -y --allow-downgrades \
atmos="${ATMOS_VERSION}-*" \
rainbow-text \
kubectl
atmos="${ATMOS_VERSION}-*"

COPY rootfs/ /

Expand Down
2 changes: 1 addition & 1 deletion internal/exec/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ExecuteHelmfile(cmd *cobra.Command, args []string) error {
// Check if the component is allowed to be provisioned (`metadata.type` attribute)
if (info.SubCommand == "sync" || info.SubCommand == "apply" || info.SubCommand == "deploy") && info.ComponentIsAbstract {
return errors.New(fmt.Sprintf("Abstract component '%s' cannot be provisioned since it's explicitly prohibited from being deployed "+
"with 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component)))
"by 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component)))
}

// Write variables to a file
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {
// Check if the component is allowed to be provisioned (`metadata.type` attribute)
if (info.SubCommand == "apply" || info.SubCommand == "deploy") && info.ComponentIsAbstract {
return errors.New(fmt.Sprintf("Abstract component '%s' cannot be provisioned since it's explicitly prohibited from being deployed "+
"with 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component)))
"by 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component)))
}

var varFile string
Expand Down
38 changes: 0 additions & 38 deletions pkg/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"os"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -248,43 +247,6 @@ func checkConfig() error {
return nil
}

// processBasePath adjusts the current working dir by making it relative to the provided base path
// NOTE: this function is not in use, we leave it here (in utils) in case we need it in the future
func processBasePath() error {
if len(Config.BasePath) > 0 && path.IsAbs(Config.BasePath) {
// Find the relative path from the current working dir to the provided base path (only if the provided base path is absolute).
// This will make the final (adjusted) path relative to the `stacks` and `components` folders

// Get the current working dir
wd, err := os.Getwd()
if err != nil {
return err
}

// Find the relative path to `Config.BasePath` from the current working dir
// https://pkg.go.dev/path/filepath#Rel
// func Rel(basepath, targpath string) (string, error)
// Rel returns a relative path that is lexically equivalent to targpath when joined to basepath with an intervening separator.
// That is, Join(basepath, Rel(basepath, targpath)) is equivalent to targpath itself.
// On success, the returned path will always be relative to basepath, even if basepath and targpath share no elements.
// An error is returned if targpath can't be made relative to basepath.
rel, err := filepath.Rel(wd, Config.BasePath)
if err != nil {
return err
}

if len(rel) > 0 {
abs, err := filepath.Abs(rel)
if err != nil {
return err
}
Config.BasePath = abs
}
}

return nil
}

func processCommandLineArgs(configAndStacksInfo ConfigAndStacksInfo) error {
if len(configAndStacksInfo.BasePath) > 0 {
Config.BasePath = configAndStacksInfo.BasePath
Expand Down

0 comments on commit 93ade5d

Please sign in to comment.