Skip to content

Commit

Permalink
remove unnecessary defaults and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronoff97 authored and swiatekm committed Nov 9, 2023
1 parent 4aeb1df commit 6ef4a87
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
3 changes: 0 additions & 3 deletions cmd/operator-opamp-bridge/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ func TestAgent_onMessage(t *testing.T) {
"namespace: " + testNamespace,
"send_batch_size: 10000",
"processors: []",
"replicas: 1",
"status:",
},
},
Expand Down Expand Up @@ -536,7 +535,6 @@ func TestAgent_onMessage(t *testing.T) {
"namespace: " + testNamespace,
"send_batch_size: 10000",
"processors: []",
"replicas: 1",
"status:",
},
},
Expand All @@ -551,7 +549,6 @@ func TestAgent_onMessage(t *testing.T) {
"namespace: " + testNamespace,
"send_batch_size: 10000",
"processors: []",
"replicas: 1",
"status:",
},
},
Expand Down
15 changes: 0 additions & 15 deletions cmd/operator-opamp-bridge/operator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (c Client) labelSetContainsLabel(instance *v1alpha1.OpenTelemetryCollector,

func (c Client) create(ctx context.Context, name string, namespace string, collector *v1alpha1.OpenTelemetryCollector) error {
// Set the defaults
collector.Default()
collector.TypeMeta.Kind = CollectorResource
collector.TypeMeta.APIVersion = v1alpha1.GroupVersion.String()
collector.ObjectMeta.Name = name
Expand All @@ -94,27 +93,13 @@ func (c Client) create(ctx context.Context, name string, namespace string, colle
collector.ObjectMeta.Labels = map[string]string{}
}
collector.ObjectMeta.Labels[ResourceIdentifierKey] = ResourceIdentifierValue
warnings, err := collector.ValidateCreate()
if err != nil {
return err
}
if warnings != nil {
c.log.Info("Some warnings present on collector", "warnings", warnings)
}
c.log.Info("Creating collector")
return c.k8sClient.Create(ctx, collector)
}

func (c Client) update(ctx context.Context, old *v1alpha1.OpenTelemetryCollector, new *v1alpha1.OpenTelemetryCollector) error {
new.ObjectMeta = old.ObjectMeta
new.TypeMeta = old.TypeMeta
warnings, err := new.ValidateUpdate(old)
if err != nil {
return err
}
if warnings != nil {
c.log.Info("Some warnings present on collector", "warnings", warnings)
}
c.log.Info("Updating collector")
return c.k8sClient.Update(ctx, new)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/operator-opamp-bridge/operator/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func Test_collectorUpdate(t *testing.T) {
var reportingCol v1alpha1.OpenTelemetryCollector
err = yaml.Unmarshal(reportingColConfig, &reportingCol)
require.NoError(t, err, "Should be no error on unmarshal")
reportingCol.Default()
reportingCol.TypeMeta.Kind = CollectorResource
reportingCol.TypeMeta.APIVersion = v1alpha1.GroupVersion.String()
reportingCol.ObjectMeta.Name = "simplest"
Expand Down

0 comments on commit 6ef4a87

Please sign in to comment.