Skip to content

Commit

Permalink
Merge branch 'gruntwork-io:master' into assume-role-web-identity
Browse files Browse the repository at this point in the history
  • Loading branch information
partcyborg committed May 29, 2024
2 parents 2fde63f + 50ddb79 commit 9c3e3c3
Show file tree
Hide file tree
Showing 14 changed files with 382 additions and 198 deletions.
54 changes: 51 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
orbs:
# The Windows orb gives us everything we need to start using the Windows executor.
win: circleci/windows@2.4.0
go: circleci/go@1.7.3
win: circleci/windows@5.0
go: circleci/go@1.11

# The "sign binary" rubs in a MacOS environment, so it's necessary to download GW's binaries
env: &env
Expand Down Expand Up @@ -339,10 +339,47 @@ jobs:
root: .
paths: [bin]

test_signing:
<<: *env
macos:
xcode: 15.3.0
resource_class: macos.x86.medium.gen2
steps:
- checkout
- attach_workspace:
at: .
- go/install:
version: "1.20.5"
- run:
name: Install sign-binary-helpers
command: |
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --module-name "sign-binary-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}"
- run:
name: Compile and sign the binaries
command: |
export AC_PASSWORD=${MACOS_AC_PASSWORD}
export AC_PROVIDER=${MACOS_AC_PROVIDER}
sign-binary --os mac --install-macos-sign-dependencies .gon_amd64.hcl
sign-binary --os mac .gon_arm64.hcl
echo "Done signing the binary"
# Replace the files in bin. These are the same file names generated from .gon_amd64.hcl and .gon_arm64.hcl
unzip terragrunt_darwin_amd64.zip
mv terragrunt_darwin_amd64 bin/
unzip terragrunt_darwin_arm64.zip
mv terragrunt_darwin_arm64 bin/
codesign -dv --verbose=4 ./bin/terragrunt_darwin_amd64
codesign -dv --verbose=4 ./bin/terragrunt_darwin_arm64
deploy:
<<: *env
macos:
xcode: 14.2.0
xcode: 15.3.0
resource_class: macos.x86.medium.gen2
steps:
- checkout
Expand Down Expand Up @@ -463,6 +500,17 @@ workflows:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- test_signing:
requires:
- build
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- APPLE__OSX__code-signing
- deploy:
requires:
- build
Expand Down
5 changes: 5 additions & 0 deletions cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ func initialSetup(cliCtx *cli.Context, opts *options.TerragruntOptions) error {
opts.TerragruntConfigPath = util.JoinPath(opts.WorkingDir, opts.TerragruntConfigPath)
}

opts.TerragruntConfigPath, err = filepath.Abs(opts.TerragruntConfigPath)
if err != nil {
return errors.WithStackTrace(err)
}

opts.TerraformPath = filepath.ToSlash(opts.TerraformPath)

opts.ExcludeDirs, err = util.GlobCanonicalPath(opts.WorkingDir, opts.ExcludeDirs...)
Expand Down
8 changes: 5 additions & 3 deletions cli/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,15 @@ func TestTerragruntHelp(t *testing.T) {
func TestTerraformHelp(t *testing.T) {
t.Parallel()

wrappedBinary := options.DefaultWrappedPath

testCases := []struct {
args []string
expected string
}{
{[]string{"terragrunt", terraform.CommandNamePlan, "--help"}, "Usage: terraform .* plan"},
{[]string{"terragrunt", terraform.CommandNameApply, "-help"}, "Usage: terraform .* apply"},
{[]string{"terragrunt", terraform.CommandNameApply, "-h"}, "Usage: terraform .* apply"},
{[]string{"terragrunt", terraform.CommandNamePlan, "--help"}, "Usage: " + wrappedBinary + " .* plan"},
{[]string{"terragrunt", terraform.CommandNameApply, "-help"}, "Usage: " + wrappedBinary + " .* apply"},
{[]string{"terragrunt", terraform.CommandNameApply, "-h"}, "Usage: " + wrappedBinary + " .* apply"},
}

for _, testCase := range testCases {
Expand Down
10 changes: 5 additions & 5 deletions cli/commands/terraform/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,16 @@ func prepareInitOptions(terragruntOptions *options.TerragruntOptions) *options.T
// modules at all. Detecting if your downloaded modules are out of date (as opposed to missing entirely) is more
// complicated and not something we handle at the moment.
func modulesNeedInit(terragruntOptions *options.TerragruntOptions) (bool, error) {
moduleNeedInit := util.JoinPath(terragruntOptions.WorkingDir, moduleInitRequiredFile)
if util.FileExists(moduleNeedInit) {
return true, nil
}

modulesPath := util.JoinPath(terragruntOptions.DataDir(), "modules")
if util.FileExists(modulesPath) {
return false, nil
}

moduleNeedInit := util.JoinPath(terragruntOptions.WorkingDir, moduleInitRequiredFile)
if util.FileExists(moduleNeedInit) {
return true, nil
}

return util.Grep(ModuleRegex, fmt.Sprintf("%s/%s", terragruntOptions.WorkingDir, TerraformExtensionGlob))
}

Expand Down
8 changes: 7 additions & 1 deletion config/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,13 @@ func getOutputJsonWithCaching(ctx *ParsingContext, targetConfig string) ([]byte,
func cloneTerragruntOptionsForDependency(ctx *ParsingContext, targetConfigPath string) *options.TerragruntOptions {
targetOptions := ctx.TerragruntOptions.Clone(targetConfigPath)
targetOptions.OriginalTerragruntConfigPath = targetConfigPath
targetOptions.DownloadDir = filepath.Join(filepath.Dir(targetConfigPath), util.TerragruntCacheDir)

// `needUpdateDownloadDir` is true if `DownloadDir` was not explicitly specified by the user and we need to assign the default download dir, otherwise leave as is.
needUpdateDownloadDir := filepath.Join(filepath.Dir(ctx.TerragruntOptions.TerragruntConfigPath), util.TerragruntCacheDir) == ctx.TerragruntOptions.DownloadDir
if needUpdateDownloadDir {
targetOptions.DownloadDir = filepath.Join(filepath.Dir(targetConfigPath), util.TerragruntCacheDir)
}

// Clear IAMRoleOptions in case if it is different from one passed through CLI to allow dependencies to define own iam roles
// https://github.com/gruntwork-io/terragrunt/issues/1853#issuecomment-940102676
if targetOptions.IAMRoleOptions != targetOptions.OriginalIAMRoleOptions {
Expand Down
Loading

0 comments on commit 9c3e3c3

Please sign in to comment.