@@ -12,7 +12,9 @@ import (
12
12
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
13
13
"sigs.k8s.io/yaml"
14
14
15
+ "github.com/openshift/insights-operator/pkg/config"
15
16
"github.com/openshift/insights-operator/pkg/record"
17
+ "github.com/openshift/insights-operator/pkg/utils/anonymize"
16
18
)
17
19
18
20
// GatherConfigMaps Collects all `ConfigMaps` from the `openshift-config`
@@ -52,6 +54,8 @@ import (
52
54
// 4.13.0+
53
55
// - `gateway-mode-config` config map from `openshift-network-operator`
54
56
// namespace since 4.14.0+
57
+ // - `insights-config` config map from `openshift-insights` namespace
58
+ // since 4.15.0+
55
59
//
56
60
// ### Anonymization
57
61
// If the content of a `ConfigMap` contains a parseable PEM structure (like a certificate), it removes the inside of
@@ -77,6 +81,10 @@ func (g *Gatherer) GatherConfigMaps(ctx context.Context) ([]record.Record, []err
77
81
records = append (records , gateayModeConf ... )
78
82
errs = append (errs , networkErrs ... )
79
83
84
+ insightsConfg , insightsErr := gatherInsightsConfigCM (ctx , coreClient )
85
+ records = append (records , insightsConfg ... )
86
+ errs = append (errs , insightsErr ... )
87
+
80
88
clusterConfigV1Rec , clusterConfigV1Errs := gatherClusterConfigV1 (ctx , coreClient )
81
89
records = append (records , clusterConfigV1Rec ... )
82
90
errs = append (errs , clusterConfigV1Errs ... )
@@ -132,6 +140,32 @@ func gatherConfigMap(ctx context.Context, coreClient corev1client.CoreV1Interfac
132
140
return records , nil
133
141
}
134
142
143
+ func gatherInsightsConfigCM (ctx context.Context , coreClient corev1client.CoreV1Interface ) ([]record.Record , []error ) {
144
+ cm , err := coreClient .ConfigMaps ("openshift-insights" ).Get (ctx , "insights-config" , metav1.GetOptions {})
145
+ if err != nil {
146
+ return nil , []error {err }
147
+ }
148
+ insightsConfig := & config.InsightsConfigurationSerialized {}
149
+ cfg := cm .Data ["config.yaml" ]
150
+ err = yaml .Unmarshal ([]byte (cfg ), insightsConfig )
151
+ if err != nil {
152
+ return nil , []error {err }
153
+ }
154
+ return []record.Record {
155
+ {
156
+ Name : fmt .Sprintf ("config/configmaps/%s/%s/%s" , cm .Namespace , cm .Name , "config" ),
157
+ Item : record.JSONMarshaller {Object : anonymizeInsightsConfig (insightsConfig )},
158
+ },
159
+ }, nil
160
+ }
161
+
162
+ func anonymizeInsightsConfig (conf * config.InsightsConfigurationSerialized ) * config.InsightsConfigurationSerialized {
163
+ conf .Proxy .HTTPProxy = anonymize .String (conf .Proxy .HTTPProxy )
164
+ conf .Proxy .HTTPSProxy = anonymize .String (conf .Proxy .HTTPSProxy )
165
+ conf .Proxy .NoProxy = anonymize .String (conf .Proxy .NoProxy )
166
+ return conf
167
+ }
168
+
135
169
// ConfigMapAnonymizer implements serialization of configmap
136
170
// and potentially anonymizes if it is a certificate
137
171
type ConfigMapAnonymizer struct {
0 commit comments