Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to disable sigv4 #366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions sigv4/disabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2022 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build noaws
// +build noaws

package sigv4

import (
"errors"
"net/http"
)

// NewSigV4RoundTripper returns an error when a new RoundTripper is created.
func NewSigV4RoundTripper(cfg *SigV4Config, next http.RoundTripper) (http.RoundTripper, error) {
return nil, errors.New("sigv4 support has been disabled in this build")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a package var, ErrSigV4Disabled, so it works with errors.Is()?

}

// SigV4Config is the configuration for signing remote write requests with
// AWS's SigV4 verification process.
type SigV4Config struct {
}

func (c *SigV4Config) Validate() error {
return errors.New("sigv4 support has been disabled in this build")
}

func (c *SigV4Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
return c.Validate()
}
3 changes: 3 additions & 0 deletions sigv4/sigv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !noaws
// +build !noaws

package sigv4

import (
Expand Down
3 changes: 3 additions & 0 deletions sigv4/sigv4_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !noaws
// +build !noaws

package sigv4

import (
Expand Down
3 changes: 3 additions & 0 deletions sigv4/sigv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !noaws
// +build !noaws

package sigv4

import (
Expand Down