diff --git a/.github/workflows/test-build-deploy.yml b/.github/workflows/test-build-deploy.yml index 6be57848..5fb05c50 100644 --- a/.github/workflows/test-build-deploy.yml +++ b/.github/workflows/test-build-deploy.yml @@ -9,7 +9,7 @@ on: jobs: lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 container: image: quay.io/cortexproject/build-image:master-0ddced051 steps: @@ -30,7 +30,7 @@ jobs: run: make lint protos: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -46,7 +46,7 @@ jobs: run: make check-protos test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 container: image: quay.io/cortexproject/build-image:master-0ddced051 steps: diff --git a/aws/config.go b/aws/config.go deleted file mode 100644 index 3d92b986..00000000 --- a/aws/config.go +++ /dev/null @@ -1,65 +0,0 @@ -package aws - -import ( - "fmt" - "net" - "net/http" - "net/url" - "os" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" -) - -// ConfigFromURL returns AWS config from given URL. It expects escaped -// AWS Access key ID & Secret Access Key to be encoded in the URL. It -// also expects region specified as a host (letting AWS generate full -// endpoint) or fully valid endpoint with dummy region assumed (e.g -// for URLs to emulated services). -func ConfigFromURL(awsURL *url.URL) (*aws.Config, error) { - config := aws.NewConfig(). - // Use a custom http.Client with the golang defaults but also specifying - // MaxIdleConnsPerHost because of a bug in golang https://github.com/golang/go/issues/13801 - // where MaxIdleConnsPerHost does not work as expected. - WithHTTPClient(&http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - DualStack: true, - }).DialContext, - MaxIdleConns: 100, - IdleConnTimeout: 90 * time.Second, - MaxIdleConnsPerHost: 100, - TLSHandshakeTimeout: 3 * time.Second, - ExpectContinueTimeout: 1 * time.Second, - }, - }) - - if awsURL.User != nil { - username := awsURL.User.Username() - password, _ := awsURL.User.Password() - - // We request at least the username or password being set to enable the static credentials. - if username != "" || password != "" { - config = config.WithCredentials(credentials.NewStaticCredentials(username, password, "")) - } - } - - if strings.Contains(awsURL.Host, ".") { - region := os.Getenv("AWS_REGION") - if region == "" { - region = "dummy" - } - if awsURL.Scheme == "https" { - return config.WithEndpoint(fmt.Sprintf("https://%s", awsURL.Host)).WithRegion(region), nil - } - return config.WithEndpoint(fmt.Sprintf("http://%s", awsURL.Host)).WithRegion(region), nil - } - - // Let AWS generate default endpoint based on region passed as a host in URL. - return config.WithRegion(awsURL.Host), nil -} diff --git a/aws/config_test.go b/aws/config_test.go deleted file mode 100644 index 1848ef73..00000000 --- a/aws/config_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package aws - -import ( - "net/url" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestAWSConfigFromURL(t *testing.T) { - for i, tc := range []struct { - url string - expectedKey string - expectedSecret string - expectedRegion string - expectedEp string - }{ - { - "s3://abc:123@s3.default.svc.cluster.local:4569", - "abc", - "123", - "dummy", - "http://s3.default.svc.cluster.local:4569", - }, - { - "s3://@us-east-1/test-bucket", - "", - "", - "us-east-1", - "", - }, - { - "dynamodb://user:pass@dynamodb.default.svc.cluster.local:8000/cortex", - "user", - "pass", - "dummy", - "http://dynamodb.default.svc.cluster.local:8000", - }, - { - // No credentials. - "s3://s3.default.svc.cluster.local:4569", - "", - "", - "dummy", - "http://s3.default.svc.cluster.local:4569", - }, - { - "s3://keyWithEscapedSlashAtTheEnd%2F:%24%2C%26%2C%2B%2C%27%2C%2F%2C%3A%2C%3B%2C%3D%2C%3F%2C%40@eu-west-2/bucket1", - "keyWithEscapedSlashAtTheEnd/", - "$,&,+,',/,:,;,=,?,@", - "eu-west-2", - "", - }, - } { - t.Run(strconv.Itoa(i), func(t *testing.T) { - parsedURL, err := url.Parse(tc.url) - require.NoError(t, err) - - cfg, err := ConfigFromURL(parsedURL) - require.NoError(t, err) - - if tc.expectedKey == "" && tc.expectedSecret == "" { - assert.Nil(t, cfg.Credentials) - } else { - require.NotNil(t, cfg.Credentials) - val, err := cfg.Credentials.Get() - require.NoError(t, err) - assert.Equal(t, tc.expectedKey, val.AccessKeyID) - assert.Equal(t, tc.expectedSecret, val.SecretAccessKey) - } - - require.NotNil(t, cfg.Region) - assert.Equal(t, tc.expectedRegion, *cfg.Region) - - if tc.expectedEp != "" { - require.NotNil(t, cfg.Endpoint) - assert.Equal(t, tc.expectedEp, *cfg.Endpoint) - } else { - assert.Nil(t, cfg.Endpoint) - } - }) - } -} diff --git a/go.mod b/go.mod index 6640ea17..35d329af 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ toolchain go1.23.2 require ( github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 - github.com/aws/aws-sdk-go v1.55.5 github.com/davecgh/go-spew v1.1.1 github.com/felixge/httpsnoop v1.0.3 github.com/go-kit/log v0.2.1 diff --git a/go.sum b/go.sum index d6bcb497..558ae0e1 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= -github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -38,8 +36,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=