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

Bug 1420976 - Support passing reference-policy in import-image command #13339

Merged
merged 2 commits into from
Mar 15, 2017

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Mar 10, 2017

@soltysh
Copy link
Contributor Author

soltysh commented Mar 10, 2017

[test]

@soltysh
Copy link
Contributor Author

soltysh commented Mar 10, 2017

@openshift/api-review for the api change, ReferencePolicy in ImageImportSpec

@soltysh
Copy link
Contributor Author

soltysh commented Mar 10, 2017

Forgot about updating completions.

@smarterclayton
Copy link
Contributor

API change approved

@soltysh
Copy link
Contributor Author

soltysh commented Mar 10, 2017

I've rebased and re-pushed. I can't reproduce that pkg/api/serialization_test.go failure locally :/

@@ -52,6 +52,7 @@ func NewCmdImportImage(fullName string, f *clientcmd.Factory, out, errout io.Wri
cmd.Flags().StringVar(&opts.From, "from", "", "A Docker image repository to import images from")
cmd.Flags().BoolVar(&opts.Confirm, "confirm", false, "If true, allow the image stream import location to be set or changed")
cmd.Flags().BoolVar(&opts.All, "all", false, "If true, import all tags from the provided source on creation or if --from is specified")
cmd.Flags().StringVar(&opts.ReferencePolicy, "reference-policy", sourceReferencePolicy, "Allow to request pullthrough for external image when set to 'local'. Defaults to 'source'.")
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be constants, i.e. Local and Source

Copy link
Contributor Author

@soltysh soltysh Mar 13, 2017

Choose a reason for hiding this comment

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

// IncludeManifest determines if the manifest for each image is returned in the response
IncludeManifest bool `json:"includeManifest,omitempty" protobuf:"varint,4,opt,name=includeManifest"`
IncludeManifest bool `json:"includeManifest,omitempty" protobuf:"varint,5,opt,name=includeManifest"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Yo can't do this - you just broke the protobuf serialization. Never change the tag number on a field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooops... my bad. Fixing right away.

@soltysh
Copy link
Contributor Author

soltysh commented Mar 13, 2017

Comments addressed.

@@ -118,6 +123,10 @@ func (o *ImportImageOptions) Validate(cmd *cobra.Command) error {
return kcmdutil.UsageError(cmd, "you must specify the name of an image stream")
}

if len(o.ReferencePolicy) > 0 && o.All {
Copy link
Contributor

Choose a reason for hiding this comment

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

open an issue about adding support for this in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would you wanted to work? It's not a problem to support this right away. The thing is that all tags will get the same reference policy, including overwriting current ones.

Copy link

Choose a reason for hiding this comment

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

The thing is that all tags will get the same reference policy, including overwriting current ones.

@soltysh I believe that's how it's supposed to work. Can you make it happen in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that's not a problem. Will update.

Copy link

Choose a reason for hiding this comment

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

Thanks!

@@ -440,16 +463,13 @@ func (o *ImportImageOptions) newImageStream() (*imageapi.ImageStream, *imageapi.
Kind: "DockerImage",
Name: from,
},
ReferencePolicy: imageapi.TagReferencePolicy{
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess this should not be set at all if the reference policy is not set...

i would check below this and generate the ReferencePolicy only if len(referencePolicy) > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sgtm

@@ -498,6 +525,9 @@ func (o *ImportImageOptions) newImageStreamImportTags(stream *imageapi.ImageStre
},
To: &kapi.LocalObjectReference{Name: tag},
ImportPolicy: imageapi.TagImportPolicy{Insecure: insecure},
ReferencePolicy: imageapi.TagReferencePolicy{
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

k

@@ -338,6 +339,28 @@ func TestCreateImageImport(t *testing.T) {
ImportPolicy: imageapi.TagImportPolicy{Insecure: false},
}},
},
"import tag setting referencePolicy": {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add test with invalid reference policy? (optional ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor Author

@soltysh soltysh Mar 13, 2017

Choose a reason for hiding this comment

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

On second thought, I don't check Validate anywhere, so I'll drop the idea ;)

@soltysh
Copy link
Contributor Author

soltysh commented Mar 13, 2017

The empty tag reference comments addressed. Rest is either under discussion or will not be fixed.

@soltysh
Copy link
Contributor Author

soltysh commented Mar 14, 2017

@miminar comment addressed.

Copy link

@miminar miminar left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 26e9be3

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/182/) (Base Commit: f617108)

@soltysh
Copy link
Contributor Author

soltysh commented Mar 14, 2017

[merge]

@soltysh
Copy link
Contributor Author

soltysh commented Mar 14, 2017

Flake #13386

[merge]

@soltysh
Copy link
Contributor Author

soltysh commented Mar 15, 2017

Looks like #11016.

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 26e9be3

@openshift-bot
Copy link
Contributor

openshift-bot commented Mar 15, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/90/) (Base Commit: 41a0dbd) (Image: devenv-rhel7_6070)

@openshift-bot openshift-bot merged commit 0009bfa into openshift:master Mar 15, 2017
@soltysh soltysh deleted the bug1420976 branch March 15, 2017 09:32
@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 15, 2017 via email

@soltysh
Copy link
Contributor Author

soltysh commented Mar 15, 2017

We need to start doing image prepulling and simplify the number of images we use

When and where?

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 15, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants