From d3c1ebe1dd84dfde5508d362e59d6cf25363fabd Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Tue, 15 Aug 2023 00:45:57 -0700 Subject: [PATCH 1/5] Add support for AAD auth for docker-acr --- cmd/drone-acr/main.go | 207 +++++++++++++++++++++++++++++++++++++++ cmd/drone-docker/main.go | 8 +- go.mod | 18 +++- go.sum | 70 ++++++++++++- 4 files changed, 296 insertions(+), 7 deletions(-) diff --git a/cmd/drone-acr/main.go b/cmd/drone-acr/main.go index 68c553ca..c5eaaa86 100644 --- a/cmd/drone-acr/main.go +++ b/cmd/drone-acr/main.go @@ -1,17 +1,40 @@ package main import ( + "context" + "encoding/base64" + "encoding/json" "fmt" + "io/ioutil" + "net/http" + "net/url" "os" "os/exec" "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/joho/godotenv" + "github.com/pkg/errors" "github.com/sirupsen/logrus" docker "github.com/drone-plugins/drone-docker" ) +const ( + acrCertPath = "/tmp/acr-cert.pem" + azSubscriptionApiVersion = "2021-04-01" + azSubscriptionBaseUrl = "https://management.azure.com/subscriptions/" + basePublicUrl = "https://portal.azure.com/#view/Microsoft_Azure_ContainerRegistries/TagMetadataBlade/registryId/" + defaultUsername = "00000000-0000-0000-0000-000000000000" + + // Environment variable names for Azure Environment Credential + clientIdEnv = "AZURE_CLIENT_ID" + clientSecretKeyEnv = "AZURE_CLIENT_SECRET" + tenantKeyEnv = "AZURE_TENANT_ID" + certPathEnv = "AZURE_CLIENT_CERTIFICATE_PATH" +) + func main() { // Load env-file if it exists first if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" { @@ -21,8 +44,19 @@ func main() { var ( repo = getenv("PLUGIN_REPO") registry = getenv("PLUGIN_REGISTRY") + + // If these credentials are provided, they will be directly used + // for docker login username = getenv("SERVICE_PRINCIPAL_CLIENT_ID") password = getenv("SERVICE_PRINCIPAL_CLIENT_SECRET") + + // Service principal credentials + clientId = getenv("CLIENT_ID") + clientSecret = getenv("CLIENT_SECRET") + clientCert = getenv("CLIENT_CERTIFICATE") + tenantId = getenv("TENANT_ID") + subscriptionId = getenv("SUBSCRIPTION_ID") + publicUrl = getenv("DAEMON_REGISTRY") ) // default registry value @@ -30,6 +64,17 @@ func main() { registry = "azurecr.io" } + // Get auth if username and password is not specified + if username == "" && password == "" { + // docker login credentials are not provided + var err error + username = defaultUsername + password, publicUrl, err = getAuth(clientId, clientSecret, clientCert, tenantId, subscriptionId, registry) + if err != nil { + logrus.Fatal(err) + } + } + // must use the fully qualified repo name. If the // repo name does not have the registry prefix we // should prepend. @@ -42,6 +87,11 @@ func main() { os.Setenv("DOCKER_USERNAME", username) os.Setenv("DOCKER_PASSWORD", password) os.Setenv("PLUGIN_REGISTRY_TYPE", "ACR") + if publicUrl != "" { + // Set this env variable if public URL for artifact is available + // If not, we will fall back to registry url + os.Setenv("DAEMON_REGISTRY", publicUrl) + } // invoke the base docker plugin binary cmd := exec.Command(docker.GetDroneDockerExecCmd()) @@ -53,6 +103,157 @@ func main() { } } +func getAuth(clientId, clientSecret, clientCert, tenantId, subscriptionId, registry string) (string, string, error) { + // Verify inputs + if tenantId == "" { + return "", "", fmt.Errorf("tenantId cannot be empty for AAD authentication") + } + if clientId == "" { + return "", "", fmt.Errorf("clientId cannot be empty for AAD authentication") + } + if clientSecret == "" && clientCert == "" { + return "", "", fmt.Errorf("one of client secret or client cert should be defined") + } + + // Setup cert + if clientCert != "" { + err := setupACRCert(clientCert, acrCertPath) + if err != nil { + errors.Wrap(err, "failed to push setup cert file") + } + } + + // Get AZ env + if err := os.Setenv(clientIdEnv, clientId); err != nil { + return "", "", errors.Wrap(err, "failed to set env variable client Id") + } + if err := os.Setenv(clientSecretKeyEnv, clientSecret); err != nil { + return "", "", errors.Wrap(err, "failed to set env variable client secret") + } + if err := os.Setenv(tenantKeyEnv, tenantId); err != nil { + return "", "", errors.Wrap(err, "failed to set env variable tenant Id") + } + if err := os.Setenv(certPathEnv, acrCertPath); err != nil { + return "", "", errors.Wrap(err, "failed to set env variable cert path") + } + env, err := azidentity.NewEnvironmentCredential(nil) + if err != nil { + return "", "", errors.Wrap(err, "failed to get env credentials from azure") + } + os.Unsetenv(clientIdEnv) + os.Unsetenv(clientSecretKeyEnv) + os.Unsetenv(tenantKeyEnv) + os.Unsetenv(certPathEnv) + + // Fetch AAD token + policy := policy.TokenRequestOptions{ + Scopes: []string{"https://management.azure.com/.default"}, + } + aadToken, err := env.GetToken(context.Background(), policy) + if err != nil { + return "", "", errors.Wrap(err, "failed to fetch access token") + } + + // Get public URL for artifacts + publicUrl, err := getPublicUrl(aadToken.Token, registry, subscriptionId) + if err != nil { + // execution should not fail because of this error + fmt.Fprintf(os.Stderr, "failed to get public url with error: %s\n", err) + } + + // Fetch token + ACRToken, err := fetchACRToken(tenantId, aadToken.Token, registry) + if err != nil { + return "", "", errors.Wrap(err, "failed to fetch ACR token") + } + return ACRToken, publicUrl, nil +} + +func fetchACRToken(tenantId, token, registry string) (string, error) { + // oauth exchange + formData := url.Values{ + "grant_type": {"access_token"}, + "service": {registry}, + "tenant": {tenantId}, + "access_token": {token}, + } + jsonResponse, err := http.PostForm(fmt.Sprintf("https://%s/oauth2/exchange", registry), formData) + if err != nil || jsonResponse == nil { + return "", errors.Wrap(err, "failed to fetch ACR token") + } + + // fetch token from response + var response map[string]interface{} + err = json.NewDecoder(jsonResponse.Body).Decode(&response) + if err != nil { + return "", errors.Wrap(err, "failed to decode oauth exchange response") + } + + // Parse the refresh_token from the response + if t, found := response["refresh_token"]; found { + if refreshToken, ok := t.(string); ok { + return refreshToken, nil + } + return "", errors.New("failed to cast refresh token from acr") + } + return "", errors.Wrap(err, "refresh token not found in response of oauth exchange call") +} + +func setupACRCert(cert, certPath string) error { + decoded, err := base64.StdEncoding.DecodeString(cert) + if err != nil { + return errors.Wrap(err, "failed to base64 decode ACR certificate") + } + err = ioutil.WriteFile(certPath, decoded, 0644) + if err != nil { + return errors.Wrap(err, "failed to write ACR certificate") + } + return nil +} + +func getPublicUrl(token, registryUrl, subscriptionId string) (string, error) { + if len(subscriptionId) == 0 || registryUrl == "" { + return "", nil + } + + registry := strings.Split(registryUrl, ".")[0] + filter := fmt.Sprintf("resourceType eq 'Microsoft.ContainerRegistry/registries' and name eq '%s'", registry) + params := url.Values{} + params.Add("$filter", filter) + params.Add("api-version", azSubscriptionApiVersion) + params.Add("$select", "id") + url := azSubscriptionBaseUrl + subscriptionId + "/resources?" + params.Encode() + + client := &http.Client{} + req, err := http.NewRequest("GET", url, nil) + if err != nil { + fmt.Println(err) + return "", errors.Wrap(err, "failed to create request for getting container registry setting") + } + + req.Header.Add("Authorization", "Bearer "+token) + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return "", errors.Wrap(err, "failed to send request for getting container registry setting") + } + defer res.Body.Close() + + var response strct + err = json.NewDecoder(res.Body).Decode(&response) + if err != nil { + return "", errors.Wrap(err, "failed to send request for getting container registry setting") + } + if len(response.Value) == 0 { + return "", errors.New("no id present for base url") + } + return basePublicUrl + encodeParam(response.Value[0].ID), nil +} + +func encodeParam(s string) string { + return url.QueryEscape(s) +} + func getenv(key ...string) (s string) { for _, k := range key { s = os.Getenv(k) @@ -62,3 +263,9 @@ func getenv(key ...string) (s string) { } return } + +type strct struct { + Value []struct { + ID string `json:"id"` + } `json:"value"` +} diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 89dfbc8e..53a536d9 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -112,6 +112,12 @@ func main() { Usage: "don't start the docker daemon", EnvVar: "PLUGIN_DAEMON_OFF", }, + cli.StringFlag{ + Name: "daemon.registry", + Usage: "daemon registry", + Value: "https://index.docker.io/v1/", + EnvVar: "DAEMON_REGISTRY,PLUGIN_REGISTRY,DOCKER_REGISTRY", + }, cli.StringFlag{ Name: "dockerfile", Usage: "build dockerfile", @@ -346,7 +352,7 @@ func run(c *cli.Context) error { SSHAgentKey: c.String("ssh-agent-key"), }, Daemon: docker.Daemon{ - Registry: c.String("docker.registry"), + Registry: c.String("daemon.registry"), Mirror: c.String("daemon.mirror"), StorageDriver: c.String("daemon.storage-driver"), StoragePath: c.String("daemon.storage-path"), diff --git a/go.mod b/go.mod index 312568d5..3fff50d6 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,34 @@ module github.com/drone-plugins/drone-docker require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 github.com/aws/aws-sdk-go v1.26.7 github.com/coreos/go-semver v0.3.0 + github.com/dchest/uniuri v1.2.0 github.com/drone-plugins/drone-plugin-lib v0.4.1 github.com/drone/drone-go v1.7.1 github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743 github.com/joho/godotenv v1.3.0 + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.0 github.com/urfave/cli v1.22.2 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/dchest/uniuri v1.2.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect - gopkg.in/yaml.v2 v2.2.8 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect ) go 1.17 diff --git a/go.sum b/go.sum index fbd17b51..cecaa164 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,12 @@ github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg= @@ -13,18 +21,34 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/drone-plugins/drone-plugin-lib v0.4.1 h1:47rZlmcMpr1hSp+6Gl+1Z4t+efi/gMQU3lxukC1Yg64= github.com/drone-plugins/drone-plugin-lib v0.4.1/go.mod h1:KwCu92jFjHV3xv2hu5Qg/8zBNvGwbhoJDQw/EwnTvoM= github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw= github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg= +github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743 h1:X3Xxno5Ji8idrNiUoFc7QyXpqhSYlDRYQmc7mlpMBzU= github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743/go.mod h1:KrtyD5PFj++GKkFS/7/RRrfnRhAMGQwy75GLCHWrCNs= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -40,13 +64,55 @@ github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.23.6/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220731174439-a90be440212d h1:Sv5ogFZatcgIMMtBSTTAgMYsicp25MXBubjXNDKwm80= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From c0927ace49b936a40edc2957c7463aa6603962a0 Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Tue, 15 Aug 2023 12:48:23 -0700 Subject: [PATCH 2/5] Update go version --- .drone.yml | 52 ++++++++++++++++++++++++++-------------------------- go.mod | 2 +- go.sum | 45 --------------------------------------------- 3 files changed, 27 insertions(+), 72 deletions(-) diff --git a/.drone.yml b/.drone.yml index a284b0b5..16b7f06b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ platform: steps: - name: vet - image: golang:1.17 + image: golang:1.20 commands: - go vet ./... environment: @@ -22,7 +22,7 @@ steps: path: /go - name: test - image: golang:1.17 + image: golang:1.20 commands: - go test -cover ./... environment: @@ -55,7 +55,7 @@ platform: steps: - name: go build - image: golang:1.17 + image: golang:1.20 environment: CGO_ENABLED: 0 commands: @@ -146,7 +146,7 @@ platform: steps: - name: go build - image: golang:1.17 + image: golang:1.20 environment: CGO_ENABLED: 0 commands: @@ -234,7 +234,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker' environment: @@ -245,7 +245,7 @@ steps: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker' environment: @@ -255,7 +255,7 @@ steps: - tag - name: executable - image: golang:1.17 + image: golang:1.20 commands: - ./release/linux/amd64/drone-docker --help @@ -299,7 +299,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker' environment: @@ -310,7 +310,7 @@ steps: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker' environment: @@ -320,7 +320,7 @@ steps: - tag - name: executable - image: golang:1.17 + image: golang:1.20 commands: - ./release/linux/arm64/drone-docker --help @@ -399,7 +399,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr' environment: @@ -410,7 +410,7 @@ steps: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr' environment: @@ -459,7 +459,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr' environment: @@ -470,7 +470,7 @@ steps: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr' environment: @@ -554,7 +554,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr' environment: @@ -564,7 +564,7 @@ steps: exclude: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr' environment: @@ -612,7 +612,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr' environment: @@ -622,7 +622,7 @@ steps: exclude: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr' environment: @@ -705,7 +705,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku' environment: @@ -715,7 +715,7 @@ steps: exclude: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku' environment: @@ -764,7 +764,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku' environment: @@ -774,7 +774,7 @@ steps: exclude: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku' environment: @@ -855,7 +855,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr' environment: @@ -865,7 +865,7 @@ steps: exclude: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr' environment: @@ -913,7 +913,7 @@ platform: steps: - name: build-push - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr' environment: @@ -924,7 +924,7 @@ steps: - tag - name: build-tag - image: golang:1.17 + image: golang:1.20 commands: - 'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr' environment: diff --git a/go.mod b/go.mod index 3fff50d6..1aff9d64 100644 --- a/go.mod +++ b/go.mod @@ -31,4 +31,4 @@ require ( golang.org/x/text v0.8.0 // indirect ) -go 1.17 +go 1.20 diff --git a/go.sum b/go.sum index cecaa164..b9b9f914 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,6 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aov github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg= github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= @@ -21,14 +20,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/drone-plugins/drone-plugin-lib v0.4.1 h1:47rZlmcMpr1hSp+6Gl+1Z4t+efi/gMQU3lxukC1Yg64= github.com/drone-plugins/drone-plugin-lib v0.4.1/go.mod h1:KwCu92jFjHV3xv2hu5Qg/8zBNvGwbhoJDQw/EwnTvoM= github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw= github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg= -github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= @@ -43,8 +39,6 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -62,57 +56,18 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.23.6/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From c64f19dec75948ec28095e4fc6e9ff5f12f2437e Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Wed, 16 Aug 2023 14:39:54 -0700 Subject: [PATCH 3/5] Add Artifact Registry to the Daemon struct --- cmd/drone-acr/main.go | 2 +- cmd/drone-docker/main.go | 35 ++++++++++++++++++----------------- docker.go | 32 +++++++++++++++++--------------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/cmd/drone-acr/main.go b/cmd/drone-acr/main.go index c5eaaa86..a2a6c9ab 100644 --- a/cmd/drone-acr/main.go +++ b/cmd/drone-acr/main.go @@ -90,7 +90,7 @@ func main() { if publicUrl != "" { // Set this env variable if public URL for artifact is available // If not, we will fall back to registry url - os.Setenv("DAEMON_REGISTRY", publicUrl) + os.Setenv("ARTIFACT_REGISTRY", publicUrl) } // invoke the base docker plugin binary diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 53a536d9..589f2ec6 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -113,10 +113,10 @@ func main() { EnvVar: "PLUGIN_DAEMON_OFF", }, cli.StringFlag{ - Name: "daemon.registry", - Usage: "daemon registry", + Name: "artifact.registry", + Usage: "artifact registry", Value: "https://index.docker.io/v1/", - EnvVar: "DAEMON_REGISTRY,PLUGIN_REGISTRY,DOCKER_REGISTRY", + EnvVar: "ARTIFACT_REGISTRY,PLUGIN_REGISTRY,DOCKER_REGISTRY", }, cli.StringFlag{ Name: "dockerfile", @@ -352,20 +352,21 @@ func run(c *cli.Context) error { SSHAgentKey: c.String("ssh-agent-key"), }, Daemon: docker.Daemon{ - Registry: c.String("daemon.registry"), - Mirror: c.String("daemon.mirror"), - StorageDriver: c.String("daemon.storage-driver"), - StoragePath: c.String("daemon.storage-path"), - Insecure: c.Bool("daemon.insecure"), - Disabled: c.Bool("daemon.off"), - IPv6: c.Bool("daemon.ipv6"), - Debug: c.Bool("daemon.debug"), - Bip: c.String("daemon.bip"), - DNS: c.StringSlice("daemon.dns"), - DNSSearch: c.StringSlice("daemon.dns-search"), - MTU: c.String("daemon.mtu"), - Experimental: c.Bool("daemon.experimental"), - RegistryType: registryType, + Registry: c.String("docker.registry"), + Mirror: c.String("daemon.mirror"), + StorageDriver: c.String("daemon.storage-driver"), + StoragePath: c.String("daemon.storage-path"), + Insecure: c.Bool("daemon.insecure"), + Disabled: c.Bool("daemon.off"), + IPv6: c.Bool("daemon.ipv6"), + Debug: c.Bool("daemon.debug"), + Bip: c.String("daemon.bip"), + DNS: c.StringSlice("daemon.dns"), + DNSSearch: c.StringSlice("daemon.dns-search"), + MTU: c.String("daemon.mtu"), + Experimental: c.Bool("daemon.experimental"), + RegistryType: registryType, + ArtifactRegistry: c.String("artifact.registry"), }, } diff --git a/docker.go b/docker.go index 210f6dfd..33dcbe50 100644 --- a/docker.go +++ b/docker.go @@ -16,20 +16,21 @@ import ( type ( // Daemon defines Docker daemon parameters. Daemon struct { - Registry string // Docker registry - Mirror string // Docker registry mirror - Insecure bool // Docker daemon enable insecure registries - StorageDriver string // Docker daemon storage driver - StoragePath string // Docker daemon storage path - Disabled bool // DOcker daemon is disabled (already running) - Debug bool // Docker daemon started in debug mode - Bip string // Docker daemon network bridge IP address - DNS []string // Docker daemon dns server - DNSSearch []string // Docker daemon dns search domain - MTU string // Docker daemon mtu setting - IPv6 bool // Docker daemon IPv6 networking - Experimental bool // Docker daemon enable experimental mode - RegistryType drone.RegistryType // Docker registry type + Registry string // Docker registry + Mirror string // Docker registry mirror + Insecure bool // Docker daemon enable insecure registries + StorageDriver string // Docker daemon storage driver + StoragePath string // Docker daemon storage path + Disabled bool // DOcker daemon is disabled (already running) + Debug bool // Docker daemon started in debug mode + Bip string // Docker daemon network bridge IP address + DNS []string // Docker daemon dns server + DNSSearch []string // Docker daemon dns search domain + MTU string // Docker daemon mtu setting + IPv6 bool // Docker daemon IPv6 networking + Experimental bool // Docker daemon enable experimental mode + RegistryType drone.RegistryType // Docker registry type + ArtifactRegistry string // Docker registry where artifact can be viewed } // Login defines Docker login parameters. @@ -231,7 +232,8 @@ func (p Plugin) Exec() error { if p.ArtifactFile != "" { if digest, err := getDigest(p.Build.TempTag); err == nil { - if err = drone.WritePluginArtifactFile(p.Daemon.RegistryType, p.ArtifactFile, p.Daemon.Registry, p.Build.Repo, digest, p.Build.Tags); err != nil { + fmt.Printf("Got artifact reg %s and digest %s\n", p.Daemon.ArtifactRegistry, digest) + if err = drone.WritePluginArtifactFile(p.Daemon.RegistryType, p.ArtifactFile, p.Daemon.ArtifactRegistry, p.Build.Repo, digest, p.Build.Tags); err != nil { fmt.Printf("failed to write plugin artifact file at path: %s with error: %s\n", p.ArtifactFile, err) } } else { From 53c630c8c3e133c621dc227d89aac1cf50e11afe Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Mon, 21 Aug 2023 14:26:36 -0700 Subject: [PATCH 4/5] Address comments --- cmd/drone-acr/main.go | 4 ++-- docker.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/drone-acr/main.go b/cmd/drone-acr/main.go index a2a6c9ab..ea5bc14a 100644 --- a/cmd/drone-acr/main.go +++ b/cmd/drone-acr/main.go @@ -239,7 +239,7 @@ func getPublicUrl(token, registryUrl, subscriptionId string) (string, error) { } defer res.Body.Close() - var response strct + var response subscriptionUrlResponse err = json.NewDecoder(res.Body).Decode(&response) if err != nil { return "", errors.Wrap(err, "failed to send request for getting container registry setting") @@ -264,7 +264,7 @@ func getenv(key ...string) (s string) { return } -type strct struct { +type subscriptionUrlResponse struct { Value []struct { ID string `json:"id"` } `json:"value"` diff --git a/docker.go b/docker.go index 33dcbe50..df2ef3f8 100644 --- a/docker.go +++ b/docker.go @@ -232,7 +232,8 @@ func (p Plugin) Exec() error { if p.ArtifactFile != "" { if digest, err := getDigest(p.Build.TempTag); err == nil { - fmt.Printf("Got artifact reg %s and digest %s\n", p.Daemon.ArtifactRegistry, digest) + // ArtifactRegistry here will be read from env variable ARTIFACT_REGISTRY (valid for ACR). If this env + // variable is not present, it'll be read from PLUGIN_REGISTRY which is valid for docker / ecr / gcr. if err = drone.WritePluginArtifactFile(p.Daemon.RegistryType, p.ArtifactFile, p.Daemon.ArtifactRegistry, p.Build.Repo, digest, p.Build.Tags); err != nil { fmt.Printf("failed to write plugin artifact file at path: %s with error: %s\n", p.ArtifactFile, err) } From 5fbbde3aefaae6bcbddd39a321fd30f0a8a41be6 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Tue, 22 Aug 2023 11:46:16 +0100 Subject: [PATCH 5/5] Update docker.go --- docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker.go b/docker.go index df2ef3f8..51285891 100644 --- a/docker.go +++ b/docker.go @@ -233,7 +233,7 @@ func (p Plugin) Exec() error { if p.ArtifactFile != "" { if digest, err := getDigest(p.Build.TempTag); err == nil { // ArtifactRegistry here will be read from env variable ARTIFACT_REGISTRY (valid for ACR). If this env - // variable is not present, it'll be read from PLUGIN_REGISTRY which is valid for docker / ecr / gcr. + // variable is not present, it'll be read from PLUGIN_REGISTRY then finally DOCKER_REGISTRY both are valid for docker / ecr / gcr / heroku. if err = drone.WritePluginArtifactFile(p.Daemon.RegistryType, p.ArtifactFile, p.Daemon.ArtifactRegistry, p.Build.Repo, digest, p.Build.Tags); err != nil { fmt.Printf("failed to write plugin artifact file at path: %s with error: %s\n", p.ArtifactFile, err) }