Skip to content

bug: spec.injectLabels is overwritten if not specified on command line #561

Open
@davidovich

Description

@davidovich

In PR #505, support was added to the tanka cli to control labels injection for the pruning feature.

But a regression was introduced where an already present flag in the spec will not be honoured. If it is set in the spec but not on the command line, the value will always be reset to the default value.

In the code, I believe there is a missing condition to evaluate if the setting was provided in the command line.

The fix is not that trivial, because we don't know if the default value comes from not specifying the value on the command line, or that the user explicitly said --inject-lables=false. Otherwize it would be easy, add tmp.Spec.InjectLabels to the condition:

// incomplete fix, but valid if we know that the user has not specified --inject-labels=false
if tmp.Spec.InjectLabels && tmp.Spec.InjectLabels != cfg.Spec.InjectLabels {
	fmt.Printf("updated spec.injectLabels (`%t` -> `%t`)\n", cfg.Spec.InjectLabels, tmp.Spec.InjectLabels)
	cfg.Spec.InjectLabels = tmp.Spec.InjectLabels
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions