-
Notifications
You must be signed in to change notification settings - Fork 4.7k
build: take referencePolicy into account when resolving istag #12767
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,6 +370,38 @@ func TestInstantiateWithImageTrigger(t *testing.T) { | |
bc = buildConfig | ||
return nil | ||
} | ||
client.GetImageStreamFunc = | ||
func(ctx kapi.Context, name string) (*imageapi.ImageStream, error) { | ||
return &imageapi.ImageStream{ | ||
ObjectMeta: kapi.ObjectMeta{Name: name}, | ||
Status: imageapi.ImageStreamStatus{ | ||
DockerImageRepository: originalImage, | ||
Tags: map[string]imageapi.TagEventList{ | ||
"tag1": { | ||
Items: []imageapi.TagEvent{ | ||
{ | ||
DockerImageReference: "ref/" + name + ":tag1", | ||
}, | ||
}, | ||
}, | ||
"tag2": { | ||
Items: []imageapi.TagEvent{ | ||
{ | ||
DockerImageReference: "ref/" + name + ":tag2", | ||
}, | ||
}, | ||
}, | ||
"tag3": { | ||
Items: []imageapi.TagEvent{ | ||
{ | ||
DockerImageReference: "ref/" + name + ":tag3", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} | ||
generator.Client = client | ||
|
||
req := &buildapi.BuildRequest{ | ||
|
@@ -395,7 +427,7 @@ func TestInstantiateWithImageTrigger(t *testing.T) { | |
if i == tc.triggerIndex { | ||
// Verify that the trigger got updated | ||
if bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID != imageID { | ||
t.Errorf("%s: expeccted trigger at index %d to contain imageID %s", tc.name, i, imageID) | ||
t.Errorf("%s: expected trigger at index %d to contain imageID %s", tc.name, i, imageID) | ||
} | ||
continue | ||
} | ||
|
@@ -405,8 +437,8 @@ func TestInstantiateWithImageTrigger(t *testing.T) { | |
if from == nil { | ||
from = buildutil.GetInputReference(bc.Spec.Strategy) | ||
} | ||
if bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID != ("ref@" + from.Name) { | ||
t.Errorf("%s: expected LastTriggeredImageID for trigger at %d to be %s. Got: %s", tc.name, i, "ref@"+from.Name, bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID) | ||
if bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID != ("ref/" + from.Name) { | ||
t.Errorf("%s: expected LastTriggeredImageID for trigger at %d (%+v) to be %s. Got: %s", tc.name, i, bc.Spec.Triggers[i].ImageChange.From, "ref/"+from.Name, bc.Spec.Triggers[i].ImageChange.LastTriggeredImageID) | ||
} | ||
} | ||
} | ||
|
@@ -447,16 +479,16 @@ func TestInstantiateWithLastVersion(t *testing.T) { | |
func TestInstantiateWithMissingImageStream(t *testing.T) { | ||
g := mockBuildGenerator() | ||
c := g.Client.(Client) | ||
c.GetImageStreamTagFunc = func(ctx kapi.Context, name string) (*imageapi.ImageStreamTag, error) { | ||
return nil, errors.NewNotFound(imageapi.Resource("imagestreamtags"), "testRepo") | ||
c.GetImageStreamFunc = func(ctx kapi.Context, name string) (*imageapi.ImageStream, error) { | ||
return nil, errors.NewNotFound(imageapi.Resource("imagestreams"), "testRepo") | ||
} | ||
g.Client = c | ||
|
||
_, err := g.Instantiate(kapi.NewDefaultContext(), &buildapi.BuildRequest{}) | ||
se, ok := err.(*errors.StatusError) | ||
|
||
if !ok { | ||
t.Errorf("Expected errors.StatusError, got %T", err) | ||
t.Fatalf("Expected errors.StatusError, got %T", err) | ||
} | ||
|
||
if se.ErrStatus.Code != errors.StatusUnprocessableEntity { | ||
|
@@ -1421,7 +1453,7 @@ func TestResolveImageStreamRef(t *testing.T) { | |
Name: imageRepoName + ":" + tagName, | ||
}, | ||
expectedSuccess: true, | ||
expectedDockerRef: latestDockerReference, | ||
expectedDockerRef: dockerReference, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bparees this one is weird... you are trying to resolve the "foo:test" to "foo:latestDockerReference", can you or somebody explain the intention of this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're trying to resolve the image stream tag "testRepo:test" to the docker image reference "latestDockerReference" the intent being to prove we properly convert imagestreamtags (which builds can't consume) to dockerimagereferences (which they can) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you've switched from using the mocked GetImageStreamTagFunc to the GetImageStreamFunc, you're getting different behavior. The GetImageStreamTag func always returned a DockerImageRef of "latestDockerReference" but the GetImageStreamFunc returns two tags, one for dockerReference and one for latestDockerReference. So your change is probably fine. |
||
}, | ||
{ | ||
streamRef: kapi.ObjectReference{ | ||
|
@@ -1445,7 +1477,7 @@ func TestResolveImageStreamRef(t *testing.T) { | |
t.Errorf("Scenario %d: did not get expected error", i) | ||
} | ||
if ref != test.expectedDockerRef { | ||
t.Errorf("Scenario %d: Resolved reference %s did not match expected value %s", i, ref, test.expectedDockerRef) | ||
t.Errorf("Scenario %d: Resolved reference %q did not match expected value %q", i, ref, test.expectedDockerRef) | ||
} | ||
} | ||
} | ||
|
@@ -1554,7 +1586,6 @@ func mockBuildGeneratorForInstantiate() *BuildGenerator { | |
}, | ||
}, nil | ||
} | ||
g.Client = c | ||
return g | ||
} | ||
|
||
|
@@ -1603,7 +1634,7 @@ func mockBuildGenerator() *BuildGenerator { | |
}, | ||
imageapi.DefaultImageTag: { | ||
Items: []imageapi.TagEvent{ | ||
{DockerImageReference: latestDockerReference}, | ||
{DockerImageReference: latestDockerReference, Image: "myid"}, | ||
}, | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparees this looks ugly but I haven't found a better way to inject the tag the trigger expects to change :-)