Fix resolving image name for marker name attribute
The image name was incorrectly extracted from the given reference, yielding a trimmed version of the string and breaking the resulting replacement value. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
parent
7ad4047319
commit
c3fe4e0a77
|
|
@ -158,7 +158,7 @@ func UpdateWithSetters(inpath, outpath string, policies []imagev1alpha1_reflect.
|
|||
// annoyingly, neither the library imported above, nor an
|
||||
// alternative I found, will yield the original image name;
|
||||
// this is an easy way to get it
|
||||
name := image[:len(tag)+1]
|
||||
name := image[:len(image)-len(tag)-1]
|
||||
|
||||
imageSetter := fmt.Sprintf("%s:%s", policy.GetNamespace(), policy.GetName())
|
||||
defs[fieldmeta.SetterDefinitionPrefix+imageSetter] = setterSchema(imageSetter, policy.Status.LatestImage)
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ resources:
|
|||
- unimportant.yaml
|
||||
images:
|
||||
- name: container
|
||||
newName: updated # {"$imagepolicy": "automation-ns:policy:name"}
|
||||
newName: index.repo.fake/updated # {"$imagepolicy": "automation-ns:policy:name"}
|
||||
newTag: v1.0.1 # {"$imagepolicy": "automation-ns:policy:tag"}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: c
|
||||
image: updated:v1.0.1 # {"$imagepolicy": "automation-ns:policy"}
|
||||
image: index.repo.fake/updated:v1.0.1 # {"$imagepolicy": "automation-ns:policy"}
|
||||
- name: d
|
||||
image: image:v1.0.0 # {"$imagepolicy": "automation-ns:unchanged"}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@ var _ = Describe("Update image via kyaml setters2", func() {
|
|||
|
||||
var (
|
||||
policies = []imagev1alpha1_reflect.ImagePolicy{
|
||||
imagev1alpha1_reflect.ImagePolicy{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
|
||||
Namespace: "automation-ns",
|
||||
Name: "policy",
|
||||
},
|
||||
Status: imagev1alpha1_reflect.ImagePolicyStatus{
|
||||
LatestImage: "updated:v1.0.1",
|
||||
LatestImage: "index.repo.fake/updated:v1.0.1",
|
||||
},
|
||||
},
|
||||
imagev1alpha1_reflect.ImagePolicy{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
|
||||
Namespace: "automation-ns",
|
||||
Name: "unchanged",
|
||||
|
|
@ -68,16 +68,16 @@ var _ = Describe("Update image via kyaml setters2", func() {
|
|||
defer os.RemoveAll(tmp)
|
||||
|
||||
policies := []imagev1alpha1_reflect.ImagePolicy{
|
||||
imagev1alpha1_reflect.ImagePolicy{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
|
||||
Namespace: "automation-ns",
|
||||
Name: "policy",
|
||||
},
|
||||
Status: imagev1alpha1_reflect.ImagePolicyStatus{
|
||||
LatestImage: "updated:v1.0.1",
|
||||
LatestImage: "index.repo.fake/updated:v1.0.1",
|
||||
},
|
||||
},
|
||||
imagev1alpha1_reflect.ImagePolicy{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
|
||||
Namespace: "automation-ns",
|
||||
Name: "unchanged",
|
||||
|
|
@ -117,7 +117,7 @@ var _ = Describe("Update image via kyaml setters2", func() {
|
|||
Name: "foo",
|
||||
},
|
||||
}}
|
||||
r, _ := name.ParseReference("updated:v1.0.1")
|
||||
r, _ := name.ParseReference("index.repo.fake/updated:v1.0.1")
|
||||
expectedImageRef := imageRef{r, types.NamespacedName{
|
||||
Name: "policy",
|
||||
Namespace: "automation-ns",
|
||||
|
|
|
|||
Loading…
Reference in New Issue