Skip to content

Commit ca014dd

Browse files
authored
[feature] Reduce TLS config (#13)
1 parent 612cef3 commit ca014dd

File tree

7 files changed

+0
-53
lines changed

7 files changed

+0
-53
lines changed

exporter/solarwindsexporter/config.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ type Config struct {
4545
ingestionToken configopaque.String `mapstructure:"-"`
4646
// endpointURL stores the URL provided by the Solarwinds Extension.
4747
endpointURL string `mapstructure:"-"`
48-
// insecure stores the option to disable TLS provided
49-
// by the Solarwinds Extension.
50-
insecure bool `mapstructure:"-"`
5148
}
5249

5350
// extensionAsComponent tries to parse `extension` value of the form 'type/name'
@@ -124,9 +121,6 @@ func (cfg *Config) OTLPConfig() (*otlpexporter.Config, error) {
124121
ClientConfig: clientCfg,
125122
}
126123

127-
// Disable TLS for testing.
128-
otlpConfig.ClientConfig.TLSSetting.Insecure = cfg.insecure
129-
130124
if err := otlpConfig.Validate(); err != nil {
131125
return nil, err
132126
}

exporter/solarwindsexporter/solarwinds_exporter.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ func (swiExporter *solarwindsExporter) initExporterType(
108108
}
109109
swiExporter.config.endpointURL = url
110110

111-
// Get TLS settings for testing.
112-
insecure := endpointCfg.Insecure()
113-
swiExporter.config.insecure = insecure
114-
115111
otlpExporter := otlpexporter.NewFactory()
116112
otlpCfg, err := swiExporter.config.OTLPConfig()
117113
if err != nil {

extension/solarwindsextension/config_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func TestConfigUnmarshalFull(t *testing.T) {
4242
EndpointURLOverride: "127.0.0.1:1234",
4343
IngestionToken: "TOKEN",
4444
CollectorName: "test-collector",
45-
Insecure: true,
4645
}, cfg)
4746
}
4847

@@ -115,23 +114,6 @@ func TestConfigValidateMissingCollectorName(t *testing.T) {
115114
)
116115
}
117116

118-
// TestConfigValidateInsecureInProd tests that 'insecure'
119-
// cannot be enabled for a production endpoint.
120-
func TestConfigValidateInsecureInProd(t *testing.T) {
121-
cfgFile := testutil.LoadConfigTestdata(t, "insecure_in_prod")
122-
123-
// Parse configuration.
124-
factory := NewFactory()
125-
cfg := factory.CreateDefaultConfig()
126-
require.NoError(t, cfgFile.Unmarshal(&cfg))
127-
128-
assert.ErrorContains(
129-
t,
130-
cfg.(*internal.Config).Validate(),
131-
"invalid configuration: 'insecure'",
132-
)
133-
}
134-
135117
// TestConfigTokenRedacted checks that the configuration
136118
// type doesn't leak its secret token unless it is accessed explicitly.
137119
func TestConfigTokenRedacted(t *testing.T) {

extension/solarwindsextension/endpoint_config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
type EndpointConfig interface {
2424
Url() (string, error)
2525
Token() configopaque.String
26-
Insecure() bool
2726
}
2827

2928
type endpointConfig struct{ cfg *internal.Config }
@@ -41,7 +40,3 @@ func (c *endpointConfig) Url() (string, error) {
4140
func (c *endpointConfig) Token() configopaque.String {
4241
return c.cfg.IngestionToken
4342
}
44-
45-
func (c *endpointConfig) Insecure() bool {
46-
return c.cfg.Insecure
47-
}

extension/solarwindsextension/internal/config.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,15 @@ type Config struct {
3636
IngestionToken configopaque.String `mapstructure:"token"`
3737
// CollectorName name of the collector passed in the heartbeat metric
3838
CollectorName string `mapstructure:"collector_name"`
39-
// Insecure disables TLS in the exporters.
40-
4139
// ⚠️ Warning: For testing purpose only.
4240
// EndpointURLOverride sets OTLP endpoint directly, it overrides the DataCenter configuration.
4341
EndpointURLOverride string `mapstructure:"endpoint_url_override"`
44-
// ⚠️ Warning: For testing purpose only.
45-
// Insecure disables the TLS security. It can be used only together with EndpointURLOverride.
46-
Insecure bool `mapstructure:"insecure"`
4742
}
4843

4944
var (
5045
ErrMissingDataCenter = errors.New("invalid configuration: 'data_center' must be set")
5146
ErrMissingToken = errors.New("invalid configuration: 'token' must be set")
5247
ErrMissingCollectorName = errors.New("invalid configuration: 'collector_name' must be set")
53-
ErrInsecureInProd = errors.New("invalid configuration: 'insecure' is not allowed in production mode")
5448
)
5549

5650
// NewDefaultConfig creates a new default configuration.
@@ -67,10 +61,6 @@ func (cfg *Config) Validate() error {
6761
return ErrMissingDataCenter
6862
}
6963

70-
if cfg.Insecure && cfg.EndpointURLOverride == "" {
71-
return ErrInsecureInProd
72-
}
73-
7464
if _, err := cfg.EndpointUrl(); err != nil {
7565
return fmt.Errorf("invalid 'data_center' value: %w", err)
7666
}
@@ -113,11 +103,6 @@ func (cfg *Config) OTLPConfig() (*otlpexporter.Config, error) {
113103
},
114104
}
115105

116-
// Disable TLS for testing.
117-
if cfg.Insecure {
118-
otlpConfig.ClientConfig.TLSSetting.Insecure = true
119-
}
120-
121106
if err = otlpConfig.Validate(); err != nil {
122107
return nil, err
123108
}

extension/solarwindsextension/testdata/full.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ token: "TOKEN"
22
data_center: "na-01"
33
collector_name: "test-collector"
44
endpoint_url_override: "127.0.0.1:1234"
5-
insecure: true

extension/solarwindsextension/testdata/insecure_in_prod.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)