syndesisio / syndesis-rest

The API for Syndesis - a flexible, customizable, cloud-hosted platform that provides core integration capabilities as a service. It leverages Red Hat's existing product architecture using OpenShift Online/Dedicated and Fuse Integration Services.
https://syndesis-staging.b6ff.rh-idev.openshiftapps.com/api/v1/
Apache License 2.0
6 stars 17 forks source link

Sanitize ImageStream names #659

Closed rhuss closed 7 years ago

rhuss commented 7 years ago

The UI will accept spaces in an integration name, but it looks like the back-end doesn't like it.

io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://openshift.default.svc/oapi/v1/namespaces/proj7548/imagestreams. 
Message: ImageStream "My first integration" is invalid: metadata.name: Invalid value: "My first integration": must match "[a-z0-9]+(?:[._-][a-z0-9]+)*". 
Received status: 
Status(apiVersion=v1, code=422, 
details=StatusDetails(causes=[StatusCause(field=metadata.name, message=Invalid value: "My first integration": must match "[a-z0-9]+(?:[._-][a-z0-9]+)*", 
reason=FieldValueInvalid, additionalProperties={})], group=null, kind=ImageStream, 
name=My first integration, retryAfterSeconds=null, additionalProperties={}), kind=Status,
message=ImageStream "My first integration" is invalid: 
metadata.name: Invalid value: "My first integration": must match "[a-z0-9]+(?:[._-][a-z0-9]+)*", metadata=ListMeta(resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).

If spaces are prohibited for integration names then this has to be catched by our validation (which we already have when checking for existing integration names). If spaces are allowed, the openshift resource generation should take care of sanitizing the name for image streams. // @kcbabo

zregvart commented 7 years ago

Should we allow integration names with spaces and sanitize them when creating OpenShift resources?

gashcrumb commented 7 years ago

Yeah, spaces in integration names need to be allowed for sure, I would think converting these to kebab case should do the trick. Ideally it'd be good to decouple the user input as much as possible to the generated resources and map them internally, don't you think?