Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit eba638d

Browse files
committed
remote/atlas: if ATLAS_RUN_ID is set, send it with remote state save
This detects the presence of ATLAS_RUN_ID in the environment and sends it if exists with remote state PUT requests with query params.
1 parent d19ec9d commit eba638d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

state/remote/atlas.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ func atlasFactory(conf map[string]string) (Client, error) {
5151
return nil, fmt.Errorf("malformed name '%s', expected format '<account>/<name>'", name)
5252
}
5353

54+
// If it exists, add the `ATLAS_RUN_ID` environment
55+
// variable as a param, which is injected during Atlas Terraform
56+
// runs. This is completely optional.
57+
client.RunId = os.Getenv("ATLAS_RUN_ID")
58+
5459
client.Server = server
5560
client.ServerURL = url
5661
client.AccessToken = token
@@ -67,6 +72,7 @@ type AtlasClient struct {
6772
User string
6873
Name string
6974
AccessToken string
75+
RunId string
7076
}
7177

7278
func (c *AtlasClient) Get() (*Payload, error) {
@@ -218,10 +224,15 @@ func (c *AtlasClient) readBody(b io.Reader) string {
218224
}
219225

220226
func (c *AtlasClient) url() *url.URL {
227+
values := url.Values{}
228+
229+
values.Add("atlas_run_id", c.RunId)
230+
values.Add("access_token", c.AccessToken)
231+
221232
return &url.URL{
222233
Scheme: c.ServerURL.Scheme,
223234
Host: c.ServerURL.Host,
224235
Path: path.Join("api/v1/terraform/state", c.User, c.Name),
225-
RawQuery: fmt.Sprintf("access_token=%s", c.AccessToken),
236+
RawQuery: values.Encode(),
226237
}
227238
}

0 commit comments

Comments
 (0)