expose: Use separate parameters for default and custom name

This commit is contained in:
kargakis
2015-05-26 14:03:11 +02:00
parent 6fa2777e26
commit 6c85040cef
4 changed files with 77 additions and 22 deletions

View File

@@ -29,7 +29,8 @@ type ServiceGenerator struct{}
func (ServiceGenerator) ParamNames() []GeneratorParam {
return []GeneratorParam{
{"name", true},
{"default-name", true},
{"name", false},
{"selector", true},
{"port", true},
{"labels", false},
@@ -62,8 +63,11 @@ func (ServiceGenerator) Generate(params map[string]string) (runtime.Object, erro
}
name, found := params["name"]
if !found {
return nil, fmt.Errorf("'name' is a required parameter.")
if !found || len(name) == 0 {
name, found = params["default-name"]
if !found || len(name) == 0 {
return nil, fmt.Errorf("'name' is a required parameter.")
}
}
portString, found := params["port"]
if !found {