Skip to content

Commit

Permalink
fix: use correct atlas-cli for linux (#102)
Browse files Browse the repository at this point in the history
* provider: print atlas-cli version in debug

* chore: remove must

* scripts: use atlasgo.sh for download
  • Loading branch information
giautm authored Nov 9, 2023
1 parent 8614e3c commit d9c9189
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ builds:
binary: '{{ .ProjectName }}_v{{ .Version }}'
hooks:
post:
- curl "https://release.ariga.io/atlas/atlas-{{ .Os }}-{{ if eq .Os "darwin" }}amd64{{ else }}{{ .Arch }}{{ end }}{{ if eq .Os "linux" }}-musl{{ end }}-latest{{ .Ext }}"
-o {{ dir .Path }}/atlas{{ .Ext }}
-A "Terraform-Provider-CI"
- ./scripts/atlas.sh {{ .Os }}-{{ .Arch }} {{ dir .Path }}/atlas{{ .Ext }}
archives:
- format: zip
files:
Expand Down
16 changes: 13 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,24 @@ func (p *AtlasProvider) Configure(ctx context.Context, req provider.ConfigureReq
resp.Diagnostics.AddError("Unable to find atlas-cli", err.Error())
return
}
tflog.Debug(ctx, "Found atlas-cli", map[string]any{
"path": atlasPath,
})
c, err := atlas.NewClient("", atlasPath)
if err != nil {
resp.Diagnostics.AddError("Failed to create client", err.Error())
return
}
v, err := c.Version(ctx)
if err != nil {
resp.Diagnostics.AddError("Check atlas version failure", err.Error())
return
}
version := fmt.Sprintf("%s-%s", v.Version, v.SHA)
if v.Canary {
version += "-canary"
}
tflog.Debug(ctx, "found atlas-cli", map[string]any{
"path": atlasPath,
"version": version,
})
p.client = c

var model *AtlasProviderModel
Expand Down
3 changes: 3 additions & 0 deletions scripts/atlas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
curl -sSf https://atlasgo.sh | \
sh -s -- -y --no-install --platform $1 --output $2
2 changes: 1 addition & 1 deletion scripts/local.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

HOSTNAME=registry.terraform.io
NAMESPACE=ariga
Expand Down

0 comments on commit d9c9189

Please sign in to comment.