Skip to content

Commit

Permalink
add check for missing kind
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Nov 18, 2020
1 parent ffc1e33 commit ed0674e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
defaultGroupPrefix = "group"
)

var errDuplicatedLicense = errors.New("duplicated license for kind")
var errDuplicatedLicense = errors.New("duplicated license definition")
var errSyntax = errors.New("syntax error")

var image string
Expand Down Expand Up @@ -175,6 +175,10 @@ func parseLicenseFlag(kind string, license []string) (map[string]string, error)
items := strings.SplitN(lic, ":", 2)
switch len(items) {
case 1:
if kind == "" {
log.Errorf("no kind specified for license '%s'", lic)
return nil, errSyntax
}
if _, ok := result[kind]; !ok {
result[kind] = items[0]
} else {
Expand Down Expand Up @@ -215,6 +219,10 @@ func parseNodes(kind string, nodes ...string) ([]nodesDef, error) {
def.numNodes = uint(i)
switch len(items) {
case 1:
if kind == "" {
log.Errorf("no kind specified for nodes '%s'", n)
return nil, errSyntax
}
def.kind = kind
if kind == "srl" {
def.typ = defaultSRLType
Expand All @@ -227,6 +235,10 @@ func parseNodes(kind string, nodes ...string) ([]nodesDef, error) {
def.kind = items[1]
def.typ = defaultSRLType
default:
if kind == "" {
log.Errorf("no kind specified for nodes '%s'", n)
return nil, errSyntax
}
def.kind = kind
def.typ = items[1]
}
Expand Down

0 comments on commit ed0674e

Please sign in to comment.