Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Add validation for the main.go file present in root directory #1726

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/plugin/v3/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import (
// TODO: remove this when a better solution for using addons is implemented.
const KbDeclarativePatternVersion = "v0.0.0-20200522144838-848d48e5b073"

// DefaultMainPath is default file path of main.go
const DefaultMainPath = "main.go"

type createAPIPlugin struct {
config *config.Config

Expand Down Expand Up @@ -141,6 +144,11 @@ func (p *createAPIPlugin) Validate() error {
return fmt.Errorf("can not have group and domain both empty")
}

// check if main.go is present in the root directory
if _, err := os.Stat(DefaultMainPath); os.IsNotExist(err) {
return fmt.Errorf("%s file should present in the root directory", DefaultMainPath)
}

// TODO: re-evaluate whether y/n input still makes sense. We should probably always
// scaffold the resource and controller.
reader := bufio.NewReader(os.Stdin)
Expand Down