Validate project and image stream namespaces and names#2351
Validate project and image stream namespaces and names#2351openshift-bot merged 1 commit intoopenshift:masterfrom liggitt:name_length_validation
Conversation
|
@derekwaynecarr @ncdc PTAL |
|
@ncdc imagestream comments addressed, |
pkg/image/api/helper.go
Outdated
There was a problem hiding this comment.
Each component must be at least 2 chars - meaning both ns and ref.Name
There was a problem hiding this comment.
You can call this if you want https://github.com/docker/distribution/blob/master/registry/api/v2/names.go#L78
|
@ncdc updated to use docker constants/validation |
There was a problem hiding this comment.
This is technically only relevant if the stream is using our internal registry. If spec.dockerImageRepository is set, it's ok to have a 1-char ns or name, since they won't be used in the push/pull spec. Not sure if it's worth making that distinction in the code, however.
There was a problem hiding this comment.
Since they can switch between internal/external post-creation, I'd rather keep this "strict" for now
|
ImageStream & DockerImageReference changes LGTM |
There was a problem hiding this comment.
I don't think you need to change this signature.
On create we call:
https://github.com/openshift/origin/blob/master/pkg/project/registry/project/rest.go#L57
On update we call:
https://github.com/openshift/origin/blob/master/pkg/project/registry/project/rest.go#L67
There was a problem hiding this comment.
This was calling ValidateProject(), and I couldn't tell how it was used: https://github.com/openshift/origin/pull/2351/files#diff-f19a7777a36882029db668a427f950feL71
There was a problem hiding this comment.
It was only used in an examples test, removed the signature change
|
[test] |
|
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/2330/) |
pkg/image/api/helper.go
Outdated
There was a problem hiding this comment.
I think this code is used by things where this is not a safe assumption.
There was a problem hiding this comment.
We had the defaulting for registry/name but not for name. What code do we have that expects no namespace in a pull spec?
There was a problem hiding this comment.
----- Original Message -----
default: return ref, fmt.Errorf("the docker pull spec %q must be two or three segments separated by slashes", spec) }
- if len(ref.Namespace) == 0 {
We had the defaulting for
registry/namebut not forname. What code do we
have that expects no namespace in a pull spec?
Is library even present in v2?
There was a problem hiding this comment.
I'm putting back the "library" defaulting where we had it before, and only validating what they passed.
There was a problem hiding this comment.
Library isn't a strict requirement in v2, but the Docker daemon still prepends library if you only specify foo
There was a problem hiding this comment.
I'm less concerned if they give us an invalid spec and it fails. The crux of this PR was preventing them from giving us namespace/imagestream pieces we would assemble into an invalid image repository
There was a problem hiding this comment.
I'm fine with keeping the library default the way it was originally
|
@smarterclayton, you ok with this now? |
|
@ncdc @smarterclayton backed out the changes in |
|
LGTM |
|
[merge] |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/2052/) (Image: devenv-fedora_1595) |
|
Evaluated for origin up to de47827 |
Merged by openshift-bot
To ensure we end up with valid image repository paths derived from ImageStreams, add the following validation:
To ensure we don't break updating an existing project/namespace that was created with a single character name:
Fixes #1232