Skip to content

Commit

Permalink
Fix conversion (#2699)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronoff97 authored Mar 1, 2024
1 parent fd31d55 commit 7a30cc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/fix-common-fields.yaml
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: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: fixes an error in conversion from v1alpha1 to v1beta1

# One or more tracking issues related to the change
issues: [2689]

# (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:
2 changes: 1 addition & 1 deletion internal/api/convert/v1alpha.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1beta1.OpenTelemetryColle
out.Spec.OpenTelemetryCommonFields.ManagementState = v1beta1.ManagementStateType(copy.Spec.ManagementState)
out.Spec.OpenTelemetryCommonFields.Resources = copy.Spec.Resources
out.Spec.OpenTelemetryCommonFields.NodeSelector = copy.Spec.NodeSelector
out.Spec.OpenTelemetryCommonFields.Args = copy.Spec.NodeSelector
out.Spec.OpenTelemetryCommonFields.Args = copy.Spec.Args
out.Spec.OpenTelemetryCommonFields.Replicas = copy.Spec.Replicas

if copy.Spec.Autoscaler != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/api/convert/v1alpha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ service:
cfgV1 := v1alpha1.OpenTelemetryCollector{
Spec: v1alpha1.OpenTelemetryCollectorSpec{
Config: config,
Args: map[string]string{
"test": "something",
},
},
}

cfgV2, err := V1Alpha1to2(cfgV1)
assert.Nil(t, err)
assert.NotNil(t, cfgV2)
assert.Equal(t, cfgV1.Spec.Args, cfgV2.Spec.Args)

yamlCfg, err := yaml.Marshal(&cfgV2.Spec.Config)
assert.Nil(t, err)
Expand Down

0 comments on commit 7a30cc9

Please sign in to comment.