-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the httpsprovider component (#6683)
* Feat: add httpsprovider component Add the httpsprovider component that allows the collector to fetch configuration from a web server using the https protocol. Signed-off-by: Raphael Silva <[email protected]> * Add httpsprovider to the list of config providers Signed-off-by: Raphael Silva <[email protected]> * Update README Signed-off-by: Raphael Silva <[email protected]> * Apply suggestions from code review Co-authored-by: Pablo Baeyens <[email protected]> * Improve unit tests Improve unit tests to check for error while parsing test URL. Co-authored-by: Pablo Baeyens <[email protected]> * Fix comments Co-authored-by: Anthony Mirabella <[email protected]> * Fix comments Co-authored-by: Anthony Mirabella <[email protected]> * Use SchemeType instead of TransportType Signed-off-by: Raphael Silva <[email protected]> * Refactor to improve readability Signed-off-by: Raphael Silva <[email protected]> * Use consts from http to set http status code Signed-off-by: Raphael Silva <[email protected]> * Refactor code organization Signed-off-by: Raphael Silva <[email protected]> * Use struct with zero initialized properties Signed-off-by: Raphael Silva <[email protected]> Signed-off-by: Raphael Silva <[email protected]> Co-authored-by: Pablo Baeyens <[email protected]> Co-authored-by: Anthony Mirabella <[email protected]>
- Loading branch information
1 parent
f616fab
commit 6f1cbd8
Showing
10 changed files
with
545 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: httpsprovider | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add the httpsprovider. This component allows the collector to fetch configurations from web servers using the HTTPS protocol. | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [6683] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### What is the httpsprovider? | ||
|
||
An implementation of `confmap.Provider` for HTTPS (httpsprovider) allows OTEL Collector to use the HTTPS protocol to | ||
load configuration files stored in web servers. | ||
|
||
Expected URI format: | ||
- https://... | ||
|
||
### Prerequistes | ||
|
||
You need to setup a HTTP server with support to HTTPS. The server must have a certificate that can be validated in the | ||
host running the collector using system root certificates. | ||
|
||
### Configuration | ||
|
||
At this moment, this component only support communicating with servers whose certificate can be verified using the root | ||
CA certificates installed in the system. The process of adding more root CA certificates to the system is operating | ||
system dependent. For Linux, please refer to the `update-ca-trust` command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright The OpenTelemetry 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. | ||
|
||
package httpsprovider // import "go.opentelemetry.io/collector/confmap/provider/httpsprovider" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/confmap" | ||
"go.opentelemetry.io/collector/confmap/provider/internal/configurablehttpprovider" | ||
) | ||
|
||
// New returns a new confmap.Provider that reads the configuration from a https server. | ||
// | ||
// This Provider supports "https" scheme. One example of an HTTPS URI is: https://localhost:3333/getConfig | ||
// | ||
// To add extra CA certificates you need to install certificates in the system pool. This procedure is operating system | ||
// dependent. E.g.: on Linux please refer to the `update-ca-trust` command. | ||
func New() confmap.Provider { | ||
return configurablehttpprovider.New(configurablehttpprovider.HTTPSScheme) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry 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. | ||
|
||
package httpsprovider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSupportedScheme(t *testing.T) { | ||
fp := New() | ||
assert.Equal(t, "https", fp.Scheme()) | ||
} |
Oops, something went wrong.