Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ linters:
- "2"
- "10"
- "64"
- "0o600"
- "0o700"
nolintlint:
require-explanation: false
require-specific: false
Expand Down
25 changes: 12 additions & 13 deletions airflow-client/airflow-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/hashicorp/go-retryablehttp"

"github.com/astronomer/astro-cli/context"
"github.com/astronomer/astro-cli/pkg/credentials"
"github.com/astronomer/astro-cli/pkg/httputil"
)

Expand Down Expand Up @@ -41,12 +41,14 @@ type Client interface {
// Client containers the logger and HTTPClient used to communicate with the Astronomer API
type HTTPClient struct {
*httputil.HTTPClient
creds *credentials.CurrentCredentials
}

// NewAstroClient returns a new Client with the logger and HTTP client setup.
func NewAirflowClient(c *httputil.HTTPClient) *HTTPClient {
// NewAirflowClient returns a new Client with the logger and HTTP client setup.
func NewAirflowClient(c *httputil.HTTPClient, creds *credentials.CurrentCredentials) *HTTPClient {
return &HTTPClient{
c,
HTTPClient: c,
creds: creds,
}
}

Expand Down Expand Up @@ -242,17 +244,14 @@ func checkRetryPolicy(method string) retryablehttp.CheckRetry {
}

func (c *HTTPClient) DoAirflowClient(doOpts *httputil.DoOptions) (*Response, error) {
cl, err := context.GetCurrentContext()
if err != nil {
return nil, err
}

if cl.Token != "" {
doOpts.Headers = map[string]string{
"authorization": cl.Token,
if c.creds != nil {
if tok := c.creds.Get(); tok != "" {
if doOpts.Headers == nil {
doOpts.Headers = map[string]string{}
}
doOpts.Headers["authorization"] = tok
}
}

req, err := retryablehttp.NewRequest(doOpts.Method, doOpts.Path, doOpts.Data)
if err != nil {
return nil, err
Expand Down
Loading