Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcollom committed Jul 9, 2024
1 parent 3aa4a0a commit dfaf915
Show file tree
Hide file tree
Showing 28 changed files with 1,591 additions and 551 deletions.
63 changes: 63 additions & 0 deletions cmd/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const (
envACRPassword = "ACR_PASSWORD"
envACRRefreshToken = "ACR_REFRESH_TOKEN"

envACRAppID = "ACR_APP_ID"
envACRTenantID = "ACR_TENANT_ID"
envACRClientSecret = "ACR_CLIENT_SECRET"

envDockerUsername = "DOCKER_USERNAME"
envDockerPassword = "DOCKER_PASSWORD"
envDockerToken = "DOCKER_TOKEN"
Expand All @@ -47,6 +51,8 @@ const (
envSelfhostedBearer = "TOKEN"
envSelfhostedTokenPath = "TOKEN_PATH"
envSelfhostedInsecure = "INSECURE"
envSelfhostedTimeout = "TIMEOUT"
envSelfhostedRetries = "RETRIES"
envSelfhostedCAPath = "CA_PATH"
)

Expand All @@ -57,6 +63,8 @@ var (
selfhostedTokenPath = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_TOKEN_PATH_(.*)")
selfhostedTokenReg = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_TOKEN_(.*)")
selfhostedCAPath = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_CA_PATH_(.*)")
selfhostedTimeout = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_TIMEOUT_(.*)")
selfhostedRetryMax = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_RETRIES_(.*)")
selfhostedInsecureReg = regexp.MustCompile("^VERSION_CHECKER_SELFHOSTED_INSECURE_(.*)")
)

Expand Down Expand Up @@ -140,6 +148,27 @@ func (o *Options) addAuthFlags(fs *pflag.FlagSet) {
"username/password (%s_%s).",
envPrefix, envACRRefreshToken,
))
fs.StringVar(&o.Client.ACR.AppID,
"acr-app-id", "",
fmt.Sprintf(
"App ID to authenticate with azure container registry, to be used with "+
"client-secret/tenant-id (%s_%s).",
envPrefix, envACRAppID,
))
fs.StringVar(&o.Client.ACR.TenantID,
"acr-tenant-id", "",
fmt.Sprintf(
"client ID to authenticate with azure container registry, to be used with "+
"client-secret/app-id (%s_%s).",
envPrefix, envACRTenantID,
))
fs.StringVar(&o.Client.ACR.ClientSecret,
"acr-client-secret", "",
fmt.Sprintf(
"Client Secret to authenticate with azure container registry, to be used with "+
"tenant-id/app-id (%s_%s).",
envPrefix, envACRClientSecret,
))
///

// Docker
Expand Down Expand Up @@ -264,6 +293,18 @@ func (o *Options) addAuthFlags(fs *pflag.FlagSet) {
"THIS IS NOT RECOMMENDED AND IS INTENDED FOR DEBUGGING (%s_%s)",
envPrefix, envSelfhostedInsecure,
))
fs.IntVarP(&o.selfhosted.Timeout,
"selfhosted-timeout", "", 10,
fmt.Sprintf(
"Timeout for API Calls to the Registry (%s_%s)",
envPrefix, envSelfhostedTimeout,
))
fs.IntVarP(&o.selfhosted.RetryMax,
"selfhosted-retries", "", 10,
fmt.Sprintf(
"Max number of retries per request to the Registry (%s_%s)",
envPrefix, envSelfhostedRetries,
))
///
}

Expand All @@ -278,6 +319,9 @@ func (o *Options) complete() {
{envACRUsername, &o.Client.ACR.Username},
{envACRPassword, &o.Client.ACR.Password},
{envACRRefreshToken, &o.Client.ACR.RefreshToken},
{envACRAppID, &o.Client.ACR.AppID},
{envACRTenantID, &o.Client.ACR.TenantID},
{envACRClientSecret, &o.Client.ACR.ClientSecret},

{envDockerUsername, &o.Client.Docker.Username},
{envDockerPassword, &o.Client.Docker.Password},
Expand Down Expand Up @@ -365,6 +409,25 @@ func (o *Options) assignSelfhosted(envs []string) {
continue
}

if matches := selfhostedTimeout.FindStringSubmatch(strings.ToUpper(pair[0])); len(matches) == 2 {
initOptions(matches[1])
i, err := strconv.Atoi(pair[1])
if err != nil {
continue
}
o.Client.Selfhosted[matches[1]].Timeout = i
continue
}
if matches := selfhostedRetryMax.FindStringSubmatch(strings.ToUpper(pair[0])); len(matches) == 2 {
initOptions(matches[1])
i, err := strconv.Atoi(pair[1])
if err != nil {
continue
}
o.Client.Selfhosted[matches[1]].Timeout = i
continue
}

if matches := selfhostedInsecureReg.FindStringSubmatch(strings.ToUpper(pair[0])); len(matches) == 2 {
initOptions(matches[1])
val, err := strconv.ParseBool(pair[1])
Expand Down
40 changes: 36 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ toolchain go1.22.3

require (
github.com/Azure/go-autorest/autorest v0.11.29
github.com/Azure/go-autorest/autorest/adal v0.9.24
github.com/Azure/go-autorest/autorest/adal v0.9.24 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/prometheus/client_golang v1.19.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/oauth2 v0.21.0
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/cli-runtime v0.30.2
Expand All @@ -28,20 +27,34 @@ require (
)

require (
cloud.google.com/go/artifactregistry v1.14.11
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
github.com/aws/aws-sdk-go-v2/config v1.27.24
github.com/aws/aws-sdk-go-v2/credentials v1.17.24
github.com/aws/aws-sdk-go-v2/service/ecr v1.30.1
github.com/gofri/go-github-ratelimit v1.1.0
github.com/google/go-containerregistry v0.20.0
github.com/google/go-github/v62 v62.0.0
github.com/jarcoal/httpmock v1.3.1
github.com/stretchr/testify v1.9.0
google.golang.org/api v0.187.0
)

require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/auth v0.6.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.4.0 // indirect
cloud.google.com/go/iam v1.1.10 // indirect
cloud.google.com/go/longrunning v0.5.9 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13 // indirect
Expand All @@ -59,25 +72,31 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/cli v27.0.3+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v27.0.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.2 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/imdario/mergo v0.3.16 // indirect
Expand All @@ -86,6 +105,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -97,12 +117,20 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/vbatts/tar-split v0.11.5 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.starlark.net v0.0.0-20240705175910-70002002b310 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
Expand All @@ -111,6 +139,10 @@ require (
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
Loading

0 comments on commit dfaf915

Please sign in to comment.