Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #310 from containscafeine/ingress_name
Browse files Browse the repository at this point in the history
auto populate ingress name
  • Loading branch information
surajssd committed Oct 5, 2017
2 parents b926376 + 067ae9d commit 38b2b36
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/spec/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ func fixSecrets(secrets []SecretMod, appName string) ([]SecretMod, error) {
return secrets, nil
}

func fixIngresses(ingresses []IngressSpecMod, appName string) ([]IngressSpecMod, error) {
// populate ingress name only if one ingress is specified
if len(ingresses) == 1 && ingresses[0].Name == "" {
ingresses[0].Name = appName
} else if len(ingresses) > 1 {
for i, ing := range ingresses {
if ing.Name == "" {
return nil, fmt.Errorf("name not specified for app.ingresses[%d]", i)
}
}
}
return ingresses, nil
}

func fixContainers(containers []Container, appName string) ([]Container, error) {
// if only one container set name of it as app name
if len(containers) == 1 && containers[0].Name == "" {
Expand Down Expand Up @@ -154,6 +168,12 @@ func (cf *ControllerFields) fixControllerFields() error {
return errors.Wrap(err, "unable to fix secrets")
}

// fix ingresses
cf.Ingresses, err = fixIngresses(cf.Ingresses, cf.Name)
if err != nil {
return errors.Wrap(err, "unable to fix ingresses")
}

return nil
}

Expand Down

0 comments on commit 38b2b36

Please sign in to comment.