Style
Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -102,13 +102,17 @@ func (d *DatadogDriver) ListAccounts(ctx context.Context) ([]AccountRecord, erro
|
||||
for _, u := range resp.Data {
|
||||
active := !u.Attributes.Disabled
|
||||
|
||||
var role string
|
||||
var isAdmin bool
|
||||
var (
|
||||
role string
|
||||
isAdmin bool
|
||||
)
|
||||
|
||||
for _, r := range u.Relationships.Roles.Data {
|
||||
name := roleNames[r.ID]
|
||||
if role == "" {
|
||||
role = name
|
||||
}
|
||||
|
||||
if strings.Contains(strings.ToLower(name), "admin") {
|
||||
isAdmin = true
|
||||
role = name
|
||||
@@ -150,12 +154,14 @@ func (d *DatadogDriver) queryUsers(ctx context.Context, page int) (*datadogUsers
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create datadog users request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := d.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list datadog users: %w", err)
|
||||
}
|
||||
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
||||
@@ -769,8 +769,10 @@ func TestCompleteWithState_PerDomainTokenURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var gotPath string
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotPath = r.URL.Path
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"access_token":"at","refresh_token":"rt","expires_in":3600,"token_type":"Bearer"}`))
|
||||
}))
|
||||
@@ -788,6 +790,7 @@ func TestCompleteWithState_PerDomainTokenURL(t *testing.T) {
|
||||
if domain != "us3.datadoghq.com" {
|
||||
return "", fmt.Errorf("unknown domain")
|
||||
}
|
||||
|
||||
return srv.URL + "/oauth2/v1/token", nil
|
||||
},
|
||||
}
|
||||
@@ -859,8 +862,10 @@ func TestRefreshableClient_PrefersConnectionTokenURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var gotHost string
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotHost = r.Host
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"access_token":"new","token_type":"Bearer","expires_in":3600}`))
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user