Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image override bug for mutate-image in config #982

Conversation

dalbar
Copy link
Member

@dalbar dalbar commented Jan 18, 2022

Changes

Minimal example to reproduce:

package config

import (
	"os"
	"testing"
)

func TestOverrideBug(t *testing.T) {
	cfg := NewDefaultConfig()

	os.Setenv("GIT_CONTAINER_IMAGE", "git-image")
	cfg.SetConfigFromEnv()

	if cfg.GitContainerTemplate.Image != "git-image" {
		t.Fatal("override did not set git image")
	}

	os.Setenv("MUTATE_IMAGE_CONTAINER_TEMPLATE", `{"image":"mutate-image"`)
	cfg.SetConfigFromEnv()

	if cfg.GitContainerTemplate.Image != "git-image" {
		t.Fatalf("mutate image overrides git-template")
	}
}

Fixes bug by overriding the right entry of config instead of the GitContainerTemplate.
It additionally adds previously missing unit tests to make sure that override for mutate-image is sound.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Fixes override bug for `pkg/config`: Setting the environment variabel `MUTATE_IMAGE_CONTAINER_TEMPLATE` now works as intended and does not override `config.GitContainerTemplate`.

/kind bug

Fixes bug by overriding the right entry of `config` instead of the `GitContainerTemplate`.

Adds previously missing unit tests to make sure that override is sound.
@openshift-ci openshift-ci bot added release-note-none Label for when a PR does not need a release note kind/bug Categorizes issue or PR as related to a bug. labels Jan 18, 2022
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2022
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.8.0 milestone Jan 18, 2022
@otaviof
Copy link
Member

otaviof commented Jan 18, 2022

/lgtm

@openshift-ci openshift-ci bot added release-note Label for when a PR has specified a release note and removed release-note-none Label for when a PR does not need a release note labels Jan 18, 2022
@openshift-merge-robot openshift-merge-robot merged commit 5afa4c3 into shipwright-io:main Jan 18, 2022
@dalbar dalbar deleted the bug/mutate-image-template-override branch January 18, 2022 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants