From 3acc90c03c48cf95dc9fce0c30d26d05e4b55968 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Mon, 2 Dec 2024 09:52:11 +0100 Subject: [PATCH] [internal] Remove localhostgate package (#36589) #### Description Follows open-telemetry/opentelemetry-collector/pull/11412 --- .../mx-psi_remove-internal-localhostgate.yaml | 27 +++++++++++ internal/common/localhostgate/featuregate.go | 48 ------------------- 2 files changed, 27 insertions(+), 48 deletions(-) create mode 100644 .chloggen/mx-psi_remove-internal-localhostgate.yaml delete mode 100644 internal/common/localhostgate/featuregate.go diff --git a/.chloggen/mx-psi_remove-internal-localhostgate.yaml b/.chloggen/mx-psi_remove-internal-localhostgate.yaml new file mode 100644 index 000000000000..f52afd5545ca --- /dev/null +++ b/.chloggen/mx-psi_remove-internal-localhostgate.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: internal + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove stable gate `component.UseLocalHostAsDefaultHost` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [36589] + +# (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: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/internal/common/localhostgate/featuregate.go b/internal/common/localhostgate/featuregate.go deleted file mode 100644 index e19b6e41e953..000000000000 --- a/internal/common/localhostgate/featuregate.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// package localhostgate defines a feature gate that controls whether server-like receivers and extensions use localhost as the default host for their endpoints. -// This package is duplicated across core and contrib to avoid exposing the feature gate as part of the public API. -// To do this we define a `registerOrLoad` helper and try to register the gate in both modules. -// IMPORTANT NOTE: ANY CHANGES TO THIS PACKAGE MUST BE MIRRORED IN THE CORE COUNTERPART. -// See https://github.com/open-telemetry/opentelemetry-collector/blob/main/internal/localhostgate/featuregate.go -package localhostgate // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate" - -import ( - "errors" - - "go.opentelemetry.io/collector/featuregate" -) - -const UseLocalHostAsDefaultHostID = "component.UseLocalHostAsDefaultHost" - -// UseLocalHostAsDefaultHostfeatureGate is the feature gate that controls whether -// server-like receivers and extensions such as the OTLP receiver use localhost as the default host for their endpoints. -var UseLocalHostAsDefaultHostfeatureGate = mustRegisterOrLoad( - featuregate.GlobalRegistry(), - UseLocalHostAsDefaultHostID, - featuregate.StageStable, - featuregate.WithRegisterToVersion("v0.111.0"), - featuregate.WithRegisterDescription("controls whether server-like receivers and extensions such as the OTLP receiver use localhost as the default host for their endpoints"), -) - -// mustRegisterOrLoad tries to register the feature gate and loads it if it already exists. -// It panics on any other error. -func mustRegisterOrLoad(reg *featuregate.Registry, id string, stage featuregate.Stage, opts ...featuregate.RegisterOption) *featuregate.Gate { - gate, err := reg.Register(id, stage, opts...) - - if errors.Is(err, featuregate.ErrAlreadyRegistered) { - // Gate is already registered; find it. - // Only a handful of feature gates are registered, so it's fine to iterate over all of them. - reg.VisitAll(func(g *featuregate.Gate) { - if g.ID() == id { - gate = g - return - } - }) - } else if err != nil { - panic(err) - } - - return gate -}