Skip to content

Commit

Permalink
track github action deploys (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkickr authored and kushalmalani committed Jul 23, 2024
1 parent cb7dd91 commit 8ebe111
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
17 changes: 14 additions & 3 deletions astro-client-core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"runtime"

"github.com/astronomer/astro-cli/context"
Expand Down Expand Up @@ -49,7 +50,7 @@ func CoreRequestEditor(ctx httpContext.Context, req *http.Request) error {
if err != nil {
return nil
}
os := runtime.GOOS
operatingSystem := runtime.GOOS
arch := runtime.GOARCH
baseURL := currentCtx.GetPublicRESTAPIURL("v1alpha1")
requestURL, err := url.Parse(baseURL + req.URL.String())
Expand All @@ -58,9 +59,19 @@ func CoreRequestEditor(ctx httpContext.Context, req *http.Request) error {
}
req.URL = requestURL
req.Header.Add("authorization", currentCtx.Token)
req.Header.Add("x-astro-client-identifier", "cli")
switch {
case os.Getenv("DEPLOY_ACTION") == "true" && os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "deploy-action")
req.Header.Add("x-astro-client-version", os.Getenv("DEPLOY_ACTION_VERSION"))
case os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "github-action")
req.Header.Add("x-astro-client-version", version.CurrVersion)
default:
req.Header.Add("x-astro-client-identifier", "cli")
req.Header.Add("x-astro-client-version", version.CurrVersion)
}
req.Header.Add("x-astro-client-version", version.CurrVersion)
req.Header.Add("x-client-os-identifier", os+"-"+arch)
req.Header.Add("x-client-os-identifier", operatingSystem+"-"+arch)
req.Header.Add("User-Agent", fmt.Sprintf("astro-cli/%s", version.CurrVersion))
return nil
}
18 changes: 14 additions & 4 deletions astro-client-iam-core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"runtime"

"github.com/astronomer/astro-cli/context"
Expand Down Expand Up @@ -48,7 +49,7 @@ func CoreRequestEditor(ctx httpContext.Context, req *http.Request) error {
if err != nil {
return nil
}
os := runtime.GOOS
operatingSystem := runtime.GOOS
arch := runtime.GOARCH
baseURL := currentCtx.GetPublicRESTAPIURL("iam/v1beta1")
requestURL, err := url.Parse(baseURL + req.URL.String())
Expand All @@ -57,9 +58,18 @@ func CoreRequestEditor(ctx httpContext.Context, req *http.Request) error {
}
req.URL = requestURL
req.Header.Add("authorization", currentCtx.Token)
req.Header.Add("x-astro-client-identifier", "cli")
req.Header.Add("x-astro-client-version", version.CurrVersion)
req.Header.Add("x-client-os-identifier", os+"-"+arch)
switch {
case os.Getenv("DEPLOY_ACTION") == "true" && os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "deploy-action")
req.Header.Add("x-astro-client-version", os.Getenv("DEPLOY_ACTION_VERSION"))
case os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "github-action")
req.Header.Add("x-astro-client-version", version.CurrVersion)
default:
req.Header.Add("x-astro-client-identifier", "cli")
req.Header.Add("x-astro-client-version", version.CurrVersion)
}
req.Header.Add("x-client-os-identifier", operatingSystem+"-"+arch)
req.Header.Add("User-Agent", fmt.Sprintf("astro-cli/%s", version.CurrVersion))
return nil
}
19 changes: 14 additions & 5 deletions astro-client-platform-core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"runtime"

"github.com/astronomer/astro-cli/context"
Expand Down Expand Up @@ -37,7 +38,7 @@ func requestEditor(ctx httpContext.Context, req *http.Request) error {
if err != nil {
return nil
}
os := runtime.GOOS
operatingSystem := runtime.GOOS
arch := runtime.GOARCH
baseURL := currentCtx.GetPublicRESTAPIURL("platform/v1beta1")
requestURL, err := url.Parse(baseURL + req.URL.String())
Expand All @@ -46,10 +47,18 @@ func requestEditor(ctx httpContext.Context, req *http.Request) error {
}
req.URL = requestURL
req.Header.Add("authorization", currentCtx.Token)
req.Header.Add("x-astro-client-identifier", "cli")

req.Header.Add("x-astro-client-version", version.CurrVersion)
req.Header.Add("x-client-os-identifier", os+"-"+arch)
switch {
case os.Getenv("DEPLOY_ACTION") == "true" && os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "deploy-action")
req.Header.Add("x-astro-client-version", os.Getenv("DEPLOY_ACTION_VERSION"))
case os.Getenv("GITHUB_ACTIONS") == "true":
req.Header.Add("x-astro-client-identifier", "github-action")
req.Header.Add("x-astro-client-version", version.CurrVersion)
default:
req.Header.Add("x-astro-client-identifier", "cli")
req.Header.Add("x-astro-client-version", version.CurrVersion)
}
req.Header.Add("x-client-os-identifier", operatingSystem+"-"+arch)
req.Header.Add("User-Agent", fmt.Sprintf("astro-cli/%s", version.CurrVersion))
return nil
}
Expand Down

0 comments on commit 8ebe111

Please sign in to comment.