Bug 1369679 - Wrong prompt message when passing invalid env name to 'oc set env'
Summary: Wrong prompt message when passing invalid env name to 'oc set env'
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Juan Vallejo
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-24 06:46 UTC by Yadan Pei
Modified: 2016-12-09 21:53 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-09 21:53:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Yadan Pei 2016-08-24 06:46:59 UTC
Description of problem:
When invalid env name is carried in 'oc set env', oc gives incorrect message 

Version-Release number of selected component (if applicable):
oc v1.3.0-alpha.3+9b3ae69
kubernetes v1.3.0+507d3a7


How reproducible:
Always

Steps to Reproduce:
1.Create app resources
# oc process -f /data/src/github.com/openshift/origin/examples/sample-app/application-template-stibuild.json | oc create -f -
2.Add env for rc 'database-1' with correct env name
# oc set env rc/database-1 test=1234 -n yapei-bug
replicationcontroller "database-1" updated
3.Add another env for rc 'database-1' with invalid env name
# oc set env rc/database-1 test@-abc=1234 -n yapei-bug
there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'oc get resource/<resource_name>' instead of 'oc get resource resource/<resource_name>'
4. oc set env rc/database-1 test-ttt=aaa1234
error: ReplicationController "database-1"  is invalid: [spec.template.spec.containers[0].env[6].name: Invalid  value: "test-ttt": must be a C identifier (matching regex  [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName",  spec.template.spec.containers[0].env[6].name: Invalid value: "test-ttt":  must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.  "my_name" or "MyName"]
Duplicate error message is tracked in https://bugzilla.redhat.com/show_bug.cgi?id=1257800

Actual results:
3. Error message is not correct because I didn't specify a resource type as a separate argument:
there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'oc get resource/<resource_name>' instead of 'oc get resource resource/<resource_name>'
4. Gives reasonable error message

Expected results:
3. Should give error message about invalid env name like step4

Additional info:

Comment 1 Juan Vallejo 2016-08-24 21:47:39 UTC
Related PR: https://github.com/openshift/origin/pull/10619

Comment 2 Fabiano Franz 2016-08-26 23:04:06 UTC
Fixed in https://github.com/openshift/origin/pull/10619

Comment 3 Xingxing Xia 2016-08-30 05:35:21 UTC
Fixed in:
openshift v1.3.0-alpha.3+d8c9694
kubernetes v1.3.0+507d3a7
etcd 2.3.0+git

$ oc set env rc/database-1 test-ttt=aaa1234
error: environment variables must be of the form key=value and can only contain letters, numbers, and underscores

Now prompt meaningful error message.


Note You need to log in before you can comment on or make changes to this bug.