Skip to content

Commit 2972f58

Browse files
committed
chore: Consolidating go-getter routes
1 parent 9c49dd4 commit 2972f58

56 files changed

Lines changed: 3057 additions & 1384 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ linters:
1616
- bidichk
1717
- bodyclose
1818
- contextcheck
19+
- depguard
1920
- dupl
2021
- durationcheck
2122
- errchkjson
@@ -57,6 +58,30 @@ linters:
5758
- wsl_v5
5859
- zerologlint
5960
settings:
61+
depguard:
62+
rules:
63+
no-direct-go-getter:
64+
# Direct hashicorp/go-getter imports are confined to the internal/getter
65+
# package (which owns the integration) plus two carve-out files that
66+
# would otherwise create import cycles. Everything else must go through
67+
# internal/getter.
68+
list-mode: lax
69+
files:
70+
- $all
71+
- "!**/internal/getter/**"
72+
- "!**/internal/util/file.go"
73+
- "!**/internal/cas/stacks.go"
74+
deny:
75+
- pkg: github.com/hashicorp/go-getter
76+
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
77+
- pkg: github.com/hashicorp/go-getter/v2
78+
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
79+
- pkg: github.com/hashicorp/go-getter/v2/helper/url
80+
desc: use github.com/gruntwork-io/terragrunt/internal/getter URLParse instead
81+
- pkg: github.com/hashicorp/go-getter/s3/v2
82+
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
83+
- pkg: github.com/hashicorp/go-getter/gcs/v2
84+
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
6085
dupl:
6186
threshold: 120
6287
errcheck:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
version: "v1.0.4"
3+
category: "bug-fixes"
4+
---
5+
6+
#### `s3::` and `gcs::` stack sources now download
7+
8+
Stack file `source` URLs starting with `s3::https://` or `gcs::https://` previously failed with a credentials error even when valid credentials were available. They now download. Existing stack files need no change.
9+
10+
Plain `https://www.googleapis.com/storage/...` URLs are now intended to download anonymously without GCP credentials, but Terragrunt continues to use GCS credentials to download them for backward compatibility, emitting a deprecation warning the first time it does so. To opt into the new behavior, enable the `legacy-gcs-public-prefix` strict control. To pull from a private GCS bucket explicitly, prefix the URL with `gcs::` yourself.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: legacy-gcs-public-prefix
3+
status: active
4+
since: "1.0.4"
5+
---
6+
7+
Stops auto-prefixing plain `https://www.googleapis.com/storage/...` source URLs with `gcs::`. Pre-v1.0.4 Terragrunt routed those URLs through the credentialed GCS getter; v1.0.4+ routes them through the HTTP getter for anonymous access. The legacy prefix-rewrite is restored by default with a deprecation warning. Enable this control to opt into the new behavior and silence the warning.
8+
9+
### `legacy-gcs-public-prefix` - Reason
10+
11+
The legacy auto-prefixing made it impossible to download a public Cloud Storage object without GCP credentials, since every plain `https://www.googleapis.com/storage/...` URL was rewritten to use the credentialed getter. The new behavior leaves the URL alone so it resolves through the HTTP getter and downloads anonymously.
12+
13+
To keep using GCS credentials for a specific URL, prefix it with `gcs::` yourself:
14+
15+
```hcl
16+
terraform {
17+
source = "gcs::https://www.googleapis.com/storage/v1/my-private-bucket/module.zip"
18+
}
19+
```

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/gruntwork-io/go-commons v0.17.2
2121
github.com/gruntwork-io/terragrunt-engine-go v0.1.0
2222
github.com/hashicorp/go-cleanhttp v0.5.2
23-
github.com/hashicorp/go-getter v1.8.6
23+
github.com/hashicorp/go-getter v1.8.6 // indirect
2424
github.com/hashicorp/go-getter/v2 v2.2.3
2525
github.com/hashicorp/go-hclog v1.6.3
2626
github.com/hashicorp/go-multierror v1.1.1
@@ -93,6 +93,8 @@ require (
9393
github.com/go-git/go-billy/v6 v6.0.0-20260328065524-593ae452e14d
9494
github.com/go-git/go-git/v6 v6.0.0-alpha.1
9595
github.com/gobwas/glob v0.2.3
96+
github.com/hashicorp/go-getter/gcs/v2 v2.2.3
97+
github.com/hashicorp/go-getter/s3/v2 v2.2.3
9698
github.com/invopop/jsonschema v0.13.0
9799
github.com/mattn/go-shellwords v1.0.12
98100
github.com/rogpeppe/go-internal v1.14.1
@@ -139,6 +141,7 @@ require (
139141
github.com/apparentlymart/go-versions v1.0.3 // indirect
140142
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
141143
github.com/atotto/clipboard v0.1.4 // indirect
144+
github.com/aws/aws-sdk-go v1.44.122 // indirect
142145
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
143146
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21 // indirect
144147
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.2 // indirect
@@ -223,6 +226,7 @@ require (
223226
github.com/hashicorp/yamux v0.1.2 // indirect
224227
github.com/huandu/xstrings v1.5.0 // indirect
225228
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.189 // indirect
229+
github.com/jmespath/go-jmespath v0.4.0 // indirect
226230
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
227231
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
228232
github.com/kevinburke/ssh_config v1.6.0 // indirect

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn
203203
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
204204
github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
205205
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
206+
github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo=
207+
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
206208
github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY=
207209
github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o=
208210
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 h1:eBMB84YGghSocM7PsjmmPffTa+1FBUeNvGvFou6V/4o=
@@ -579,6 +581,10 @@ github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/S
579581
github.com/hashicorp/go-getter v1.5.1/go.mod h1:a7z7NPPfNQpJWcn4rSWFtdrSldqLdLPEF3d8nFMsSLM=
580582
github.com/hashicorp/go-getter v1.8.6 h1:9sQboWULaydVphxc4S64oAI4YqpuCk7nPmvbk131ebY=
581583
github.com/hashicorp/go-getter v1.8.6/go.mod h1:nVH12eOV2P58dIiL3rsU6Fh3wLeJEKBOJzhMmzlSWoo=
584+
github.com/hashicorp/go-getter/gcs/v2 v2.2.3 h1:m/KO1hAqSrL8sH91c7uyJzVhRtfk0GtRD+jU6Buy3nc=
585+
github.com/hashicorp/go-getter/gcs/v2 v2.2.3/go.mod h1:HFbVYUSI6RERon4TTKpsloiYMnFYYGuJu0EaWUTfb9w=
586+
github.com/hashicorp/go-getter/s3/v2 v2.2.3 h1:H2C6b9n1NyKiuxqpAbF3pIOMKSD2efy0vmtyC7khPrQ=
587+
github.com/hashicorp/go-getter/s3/v2 v2.2.3/go.mod h1:SZQ4oeqBoOAoYfrUZ35PT6WcCeGeBHd22ZnI/yG2Iyo=
582588
github.com/hashicorp/go-getter/v2 v2.2.3 h1:6CVzhT0KJQHqd9b0pK3xSP0CM/Cv+bVhk+jcaRJ2pGk=
583589
github.com/hashicorp/go-getter/v2 v2.2.3/go.mod h1:hp5Yy0GMQvwWVUmwLs3ygivz1JSLI323hdIE9J9m7TY=
584590
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
@@ -667,7 +673,9 @@ github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5Xum
667673
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
668674
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
669675
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
676+
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
670677
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
678+
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
671679
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
672680
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
673681
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
@@ -1177,6 +1185,7 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
11771185
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
11781186
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
11791187
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1188+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
11801189
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
11811190
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
11821191
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
@@ -1249,6 +1258,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
12491258
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12501259
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12511260
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1261+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12521262
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12531263
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12541264
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1450,6 +1460,7 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
14501460
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
14511461
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
14521462
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
1463+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
14531464
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
14541465
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14551466
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

internal/cas/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const (
3838
ErrAbsoluteSource Error = "update_source_with_cas does not support absolute sources"
3939
// ErrSourceEscapesRepo is returned when an update_source_with_cas source resolves outside the cloned repository
4040
ErrSourceEscapesRepo Error = "update_source_with_cas source escapes repository root"
41+
// ErrNotADirectory is returned when a path expected to be a directory is not.
42+
ErrNotADirectory Error = "not a directory"
4143
)
4244

4345
// WrappedError provides additional context for errors

internal/cas/getter.go

Lines changed: 0 additions & 146 deletions
This file was deleted.

internal/cas/getter_ssh_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"testing"
1515

1616
"github.com/gruntwork-io/terragrunt/internal/cas"
17+
"github.com/gruntwork-io/terragrunt/internal/getter"
1718
"github.com/gruntwork-io/terragrunt/test/helpers"
1819
"github.com/gruntwork-io/terragrunt/test/helpers/logger"
19-
"github.com/hashicorp/go-getter/v2"
2020
"github.com/stretchr/testify/assert"
2121
"github.com/stretchr/testify/require"
2222
)
@@ -55,7 +55,7 @@ func TestSSHCASGetterGet(t *testing.T) {
5555
Branch: "main",
5656
}
5757
l := logger.CreateLogger()
58-
g := cas.NewCASGetter(l, c, opts)
58+
g := getter.NewCASGetter(l, c, opts)
5959
client := getter.Client{
6060
Getters: []getter.Getter{g},
6161
}

0 commit comments

Comments
 (0)