Skip to content

Commit

Permalink
Rename Update to Upsert, make Upsert/Remove private
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Oct 21, 2020
1 parent d77d0ae commit 03fc0de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions pkg/config/otelconfig/otelconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ func create(jaeger *v1.Jaeger, component string, otelConfig map[string]interface
}, nil
}

// Update injects required flags and objects to the common spec.
func Update(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec, args *[]string) {
func upsert(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec, args *[]string) {
volumes := []corev1.Volume{{
Name: volumeName(jaeger, component),
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -137,8 +136,7 @@ func Update(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec
*args = append(*args, configFlagWithFile)
}

// Remove the OTEL volume/mount for the given component from the common spec. If args is provided, remove the config entry from it
func Remove(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec, args *[]string) {
func remove(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec, args *[]string) {
name := volumeName(jaeger, component)

volumes := []corev1.Volume{}
Expand Down Expand Up @@ -171,9 +169,9 @@ func Remove(jaeger *v1.Jaeger, component string, commonSpec *v1.JaegerCommonSpec
// Sync creates, updates or deletes spec and args entries for the component based on the given instance, opts and configuration.
func Sync(jaeger *v1.Jaeger, component string, opts v1.Options, cfg map[string]interface{}, spec *v1.JaegerCommonSpec, args *[]string) {
if ShouldCreate(jaeger, opts, cfg) {
Update(jaeger, component, spec, args)
upsert(jaeger, component, spec, args)
} else {
Remove(jaeger, component, spec, args)
remove(jaeger, component, spec, args)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/config/otelconfig/otelconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestUpdate(t *testing.T) {
j := v1.NewJaeger(types.NamespacedName{Name: "jaeger"})
args := []string{}
commonSpec := &v1.JaegerCommonSpec{}
Update(j, "agent", commonSpec, &args)
upsert(j, "agent", commonSpec, &args)
assert.Equal(t, []string{"--config=/etc/jaeger/otel/config.yaml"}, args)
assert.Equal(t, "jaeger-agent-otel-config", commonSpec.Volumes[0].Name)
assert.Equal(t, "jaeger-agent-otel-config", commonSpec.VolumeMounts[0].Name)
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestSyncShouldUpdate(t *testing.T) {
opts := v1.NewOptions(map[string]interface{}{})
cfg := map[string]interface{}{"theconfig": "somevalue"}

// test, cross-testing with Update
// test, cross-testing with upsert
Sync(j, "agent", opts, cfg, commonSpec, &args)

// verify
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestSyncShouldRemove(t *testing.T) {
opts := v1.NewOptions(map[string]interface{}{"config": "/etc/config.yaml"})
cfg := map[string]interface{}{"theconfig": "somevalue"}

// test, cross-testing with Remove
// test, cross-testing with remove
Sync(j, "agent", opts, cfg, commonSpec, &args)

// verify
Expand Down

0 comments on commit 03fc0de

Please sign in to comment.