Skip to content

Commit

Permalink
add version file.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Feb 28, 2023
1 parent 97a167e commit a868933
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:

- name: Build
run: |
export VERSION=${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER
sed -i "s/0.0.0/${VERSION}/g" src/version.go
make install
make test
make docs
- name: Create Github Release and Tag
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.event_name == 'push'
Expand Down
2 changes: 1 addition & 1 deletion src/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (p *authressProvider) Configure(ctx context.Context, req provider.Configure
tflog.Debug(ctx, "Creating Authress client")

// Create a new Authress client using the configuration values
client, err := AuthressSdk.NewClient(customDomain, accessKey)
client, err := AuthressSdk.NewClient(customDomain, accessKey, GetBuildInfo().Version)
if err != nil {
resp.Diagnostics.AddError(
"Unable to Create Authress API Client",
Expand Down
12 changes: 7 additions & 5 deletions src/sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ const HostURL string = "http://localhost:19090"

// Client -
type Client struct {
HostURL string
HTTPClient *http.Client
AccessKey string
HostURL string
HTTPClient *http.Client
AccessKey string
Version string
}

// NewClient -
func NewClient(customDomain string, accessKey string) (*Client, error) {
func NewClient(customDomain string, accessKey string, version string) (*Client, error) {
c := Client{
HTTPClient: &http.Client{Timeout: 10 * time.Second},
AccessKey: accessKey,
HostURL: customDomain,
Version: version,
}

return &c, nil
}

func (c *Client) doRequest(req *http.Request) ([]byte, error) {
req.Header.Set("Authorization", "Bearer " + c.AccessKey)
req.Header.Set("User-Agent", "Terraform SDK")
req.Header.Set("User-Agent", "Terraform SDK " + c.Version)

res, err := c.HTTPClient.Do(req)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions src/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package authress

type BuildInfo struct {
Version string
}

func GetBuildInfo() BuildInfo {
return BuildInfo{
Version: "0.0.0",
}
}

0 comments on commit a868933

Please sign in to comment.