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

support missing porter.yaml #3592

Merged
merged 6 commits into from
Sep 20, 2023
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
21 changes: 20 additions & 1 deletion cli/cmd/v2/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ func Apply(ctx context.Context, cliConf config.CLIConfig, client api.Client, por
return errors.New("deployment target id is empty")
}

if len(porterYamlPath) != 0 {
porterYamlExists := len(porterYamlPath) != 0

if porterYamlExists {
_, err = os.Stat(filepath.Clean(porterYamlPath))
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("error checking if porter yaml exists at path %s: %w", porterYamlPath, err)
}
// If a path was specified but the file does not exist, we will not immediately error out.
// This supports users migrated from v1 who use a workflow file that always specifies a porter yaml path
// in the apply command.
porterYamlExists = false
}
}

if porterYamlExists {
porterYaml, err := os.ReadFile(filepath.Clean(porterYamlPath))
if err != nil {
return fmt.Errorf("could not read porter yaml file: %w", err)
Expand Down Expand Up @@ -87,6 +102,10 @@ func Apply(ctx context.Context, cliConf config.CLIConfig, client api.Client, por
color.New(color.FgGreen).Printf("Successfully parsed Porter YAML: applying app \"%s\"\n", appName) // nolint:errcheck,gosec
}

if appName == "" {
return errors.New("App name is empty. Please provide a Porter YAML file specifying the name of the app or set the PORTER_APP_NAME environment variable.")
}

var commitSHA string
if os.Getenv("PORTER_COMMIT_SHA") != "" {
commitSHA = os.Getenv("PORTER_COMMIT_SHA")
Expand Down
Loading