Skip to content

Commit

Permalink
Merge pull request #30 from duplocloud/DUPLO-26089-fix-lint
Browse files Browse the repository at this point in the history
DUPLO-26219 Fix lint GitHub Action
  • Loading branch information
sp1676 authored Nov 7, 2024
2 parents 7ca0c45 + 74f60f7 commit dca1d3a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dev-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
-
name: Run linting
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
only-new-issues: true # Only show new issues for pull requests.
format:
Expand All @@ -34,7 +34,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
-
name: Run formatting
run: gofmt -s -w duplocloud cmd/duplo-aws-credential-process
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
-
name: Run tests
run: make test
2 changes: 1 addition & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23
-
name: Run tests
run: make test
Expand Down
6 changes: 3 additions & 3 deletions cmd/duplo-jit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func main() {
// Identify the tenant name to use for the cache key.
var tenantName string
client, _ := internal.MustDuploClient(*host, *token, *interactive, false, *port)
*tenantID, tenantName = GetTenantIdAndName(*tenantID, client)
*tenantID, tenantName = getTenantIDAndName(*tenantID, client)

// Build the cache key.
cacheKey = strings.Join([]string{strings.TrimPrefix(*host, "https://"), "tenant", tenantName}, ",")
Expand Down Expand Up @@ -191,7 +191,7 @@ func main() {
// Identify the tenant name to use for the cache key.
var tenantName string
client, _ := internal.MustDuploClient(*host, *token, *interactive, false, *port)
*tenantID, tenantName = GetTenantIdAndName(*tenantID, client)
*tenantID, tenantName = getTenantIDAndName(*tenantID, client)

// Build the cache key.
cacheKey = strings.Join([]string{strings.TrimPrefix(*host, "https://"), "tenant", tenantName}, ",")
Expand All @@ -215,7 +215,7 @@ func main() {
}
}

func GetTenantIdAndName(tenantIDorName string, client *duplocloud.Client) (string, string) {
func getTenantIDAndName(tenantIDorName string, client *duplocloud.Client) (string, string) {
var tenantID string
var tenantName string

Expand Down
11 changes: 6 additions & 5 deletions duplocloud/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ func (c *Client) AdminGetK8sJitAccess(plan string) (*DuploPlanK8ClusterConfig, C
return &creds, nil
}

// AdminGetJITAwsCredentials retrieves just-in-time admin AWS credentials via the Duplo API.
// AdminGetJitAwsCredentials retrieves just-in-time admin AWS credentials via the Duplo API.
func (c *Client) AdminGetJitAwsCredentials() (*AwsJitCredentials, ClientError) {
return c.AdminAwsGetJitAccess("admin")
}

// TenantGetJITAwsCredentials retrieves just-in-time AWS credentials for a tenant via the Duplo API.
// TenantGetJitAwsCredentials retrieves just-in-time AWS credentials for a tenant via the Duplo API.
func (c *Client) TenantGetJitAwsCredentials(tenantID string) (*AwsJitCredentials, ClientError) {
creds := AwsJitCredentials{}
err := c.getAPI(
Expand Down Expand Up @@ -143,11 +143,12 @@ func (c *Client) ListTenantsForUser() (*[]UserTenant, ClientError) {
return &list, nil
}

func (c *Client) GetTenantFeatures(tenantId string) (*DuploTenantFeatures, ClientError) {
// GetTenantFeatures retrieves a tenant's current configuration via the Duplo API.
func (c *Client) GetTenantFeatures(tenantID string) (*DuploTenantFeatures, ClientError) {
features := DuploTenantFeatures{}
err := c.getAPI(
fmt.Sprintf("GetTenantFeatures(%s)", tenantId),
fmt.Sprintf("v3/features/tenant/%s", tenantId),
fmt.Sprintf("GetTenantFeatures(%s)", tenantID),
fmt.Sprintf("v3/features/tenant/%s", tenantID),
&features,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions duplocloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

// Represents a connection to the Duplo API
// Client represents a connection to the Duplo API
type Client struct {
HTTPClient *http.Client
HostURL string
Expand Down Expand Up @@ -66,7 +66,7 @@ func (e clientError) Response() map[string]interface{} {
return e.response
}

// Represents an error from an API call.
// ClientError represents an error from an API call.
type ClientError interface {
Error() string
Status() int
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/duplocloud/duplo-jit

go 1.21
go 1.23

require (
github.com/aws/aws-sdk-go-v2 v1.23.5
Expand Down
8 changes: 4 additions & 4 deletions internal/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func CacheGetAwsConfigOutput(cacheKey string) (creds *AwsConfigOutput) {

// Check credentials for expiry.
if creds != nil {
five_minutes_from_now := time.Now().UTC().Add(5 * time.Minute)
fiveMinutesFromNow := time.Now().UTC().Add(5 * time.Minute)
expiration, err := time.Parse(time.RFC3339, creds.Expiration)

// Invalid expiration?
Expand All @@ -107,7 +107,7 @@ func CacheGetAwsConfigOutput(cacheKey string) (creds *AwsConfigOutput) {
creds = nil

// Expires in five minutes or less?
} else if five_minutes_from_now.After(expiration) {
} else if fiveMinutesFromNow.After(expiration) {
creds = nil
}
}
Expand Down Expand Up @@ -189,9 +189,9 @@ func CacheGetK8sConfigOutput(cacheKey string, tenantName string) (creds *clienta
// Check credentials for expiry.
if creds != nil {
// Expires in five minutes or less?
five_minutes_from_now := time.Now().UTC().Add(5 * time.Minute)
fiveMinutesFromNow := time.Now().UTC().Add(5 * time.Minute)
expiration := creds.Status.ExpirationTimestamp.Time
if five_minutes_from_now.After(expiration) {
if fiveMinutesFromNow.After(expiration) {
creds = nil
}
}
Expand Down

0 comments on commit dca1d3a

Please sign in to comment.