Skip to content

Commit 774bdcb

Browse files
authored
Merge pull request #798 from mortent/AddCheckBeforeReadingKptfile
Check that we have the path argument before reading Kptfile
2 parents 7b2de70 + 72ac4ec commit 774bdcb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

run/run.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ func GetMain() *cobra.Command {
8686
return err
8787
}
8888

89-
// add openAPI definitions from Kptfile to configured openAPI
90-
if addErr := openapi.AddSchemaFromFile(filepath.Join(args[0], kptfile.KptFileName)); addErr != nil {
91-
// do not throw error if schema doesn't exist or not readable from Kptfile
92-
return nil
89+
if len(args) > 0 {
90+
// add openAPI definitions from Kptfile to configured openAPI
91+
if addErr := openapi.AddSchemaFromFile(filepath.Join(args[0], kptfile.KptFileName)); addErr != nil {
92+
// do not throw error if schema doesn't exist or not readable from Kptfile
93+
return nil
94+
}
9395
}
9496
return nil
9597
}

0 commit comments

Comments
 (0)