From cbf23f4ad5e0e65c056cb8221bc93cd6dfc6aff7 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Mon, 5 Dec 2022 15:11:49 -0800 Subject: [PATCH] Update CI to latest versions of Go (#67) * Update CI to latest versions of Go * switch to golangci-lint * clean up lint * switch to go install * fix formatting --- aad/jwt.go | 9 ++++----- azure-pipelines.yml | 27 ++++++++++++++------------- sas/sas.go | 2 +- sas/sas_test.go | 2 ++ 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/aad/jwt.go b/aad/jwt.go index affd716..dea29ce 100644 --- a/aad/jwt.go +++ b/aad/jwt.go @@ -76,15 +76,14 @@ func JWTProviderWithAzureEnvironment(env *azure.Environment) JWTProviderOption { // JWTProviderWithEnvironmentVars configures the TokenProvider using the environment variables available // -// 1. Client Credentials: attempt to authenticate with a Service Principal via "AZURE_TENANT_ID", "AZURE_CLIENT_ID" and -// "AZURE_CLIENT_SECRET" +// 1. Client Credentials: attempt to authenticate with a Service Principal via "AZURE_TENANT_ID", "AZURE_CLIENT_ID" and +// "AZURE_CLIENT_SECRET" // -// 2. Client Certificate: attempt to authenticate with a Service Principal via "AZURE_TENANT_ID", "AZURE_CLIENT_ID", -// "AZURE_CERTIFICATE_PATH" and "AZURE_CERTIFICATE_PASSWORD" +// 2. Client Certificate: attempt to authenticate with a Service Principal via "AZURE_TENANT_ID", "AZURE_CLIENT_ID", +// "AZURE_CERTIFICATE_PATH" and "AZURE_CERTIFICATE_PASSWORD" // // 3. Managed Service Identity (MSI): attempt to authenticate via MSI // -// // The Azure Environment used can be specified using the name of the Azure Environment set in "AZURE_ENVIRONMENT" var. func JWTProviderWithEnvironmentVars() JWTProviderOption { return func(config *TokenProviderConfiguration) error { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ae5d469..eb72610 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,12 +9,12 @@ jobs: strategy: matrix: - Linux_Go113: - vm.image: 'ubuntu-18.04' - go.version: '1.14.10' - Linux_Go114: - vm.image: 'ubuntu-18.04' - go.version: '1.15.3' + Linux_Go118: + vm.image: 'ubuntu-20.04' + go.version: '1.18.8' + Linux_Go119: + vm.image: 'ubuntu-20.04' + go.version: '1.19.3' pool: vmImage: '$(vm.image)' @@ -37,12 +37,11 @@ jobs: - script: | set -e - go get github.com/jstemmer/go-junit-report - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go get -u github.com/matm/gocov-html - go get -u golang.org/x/lint/golint - go get github.com/fzipp/gocyclo/cmd/gocyclo + go install github.com/jstemmer/go-junit-report@v0.9.1 + go install github.com/axw/gocov/gocov@v1.1.0 + go install github.com/AlekSi/gocov-xml@v1.0.0 + go install github.com/matm/gocov-html@v0.0.0-20200509184451-71874e2e203b + go install github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0 workingDirectory: '$(sdkPath)' displayName: 'Install Dependencies' @@ -57,7 +56,9 @@ jobs: displayName: 'Vet' - script: | - golint ./... + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1 + golangci-lint --version + golangci-lint run workingDirectory: '$(sdkPath)' displayName: 'Lint' diff --git a/sas/sas.go b/sas/sas.go index 5baeb78..267149b 100644 --- a/sas/sas.go +++ b/sas/sas.go @@ -58,7 +58,7 @@ type ( // TokenProviderWithEnvironmentVars creates a new SAS TokenProvider from environment variables // -// There are two sets of environment variables which can produce a SAS TokenProvider +// # There are two sets of environment variables which can produce a SAS TokenProvider // // 1) Expected Environment Variables: // - "EVENTHUB_KEY_NAME" the name of the Event Hub key diff --git a/sas/sas_test.go b/sas/sas_test.go index 0501dca..9154894 100644 --- a/sas/sas_test.go +++ b/sas/sas_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const ( @@ -30,6 +31,7 @@ func TestNewSigner(t *testing.T) { before := time.Now().UTC().Add(-2 * time.Second) sigStr, expiry := signer.SignWithDuration("http://microsoft.com", 1*time.Hour) nixExpiry, err := strconv.ParseInt(expiry, 10, 64) + require.NoError(t, err) assert.WithinDuration(t, before.Add(1*time.Hour), time.Unix(nixExpiry, 0), 10*time.Second, "signing expiry") sig, err := parseSig(sigStr)