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

fix: skips submodule metdata autogen if readme isn't present #1428

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash

# Changing this value will trigger a new release
VERSION=v0.5.4
VERSION=v0.5.5
BINARY=bin/cft
GITHUB_REPO=github.com/GoogleCloudPlatform/cloud-foundation-toolkit
PLATFORMS := linux windows darwin
Expand Down
20 changes: 17 additions & 3 deletions cli/bpmetadata/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func generate(cmd *cobra.Command, args []string) error {
var allBpPaths []string
currBpPath := path.Join(wdPath, mdFlags.path)
allBpPaths = append(allBpPaths, currBpPath)

var errors []string

// if nested, check if modules/ exists and create paths
// for submodules
if mdFlags.nested {
Expand All @@ -77,8 +77,22 @@ func generate(cmd *cobra.Command, args []string) error {
}
}

for _, path := range allBpPaths {
err = generateMetadataForBpPath(path)
for _, modPath := range allBpPaths {
// check if module path has readme.md
_, err := os.Stat(path.Join(modPath, readmeFileName))

// throw an error and exit if root module doesn't have a readme.md
if !strings.Contains(modPath, modulesPath+"/") && err != nil {
return fmt.Errorf("Top-level module does not have a readme. Details: %w\n", err)
}
g-awmalik marked this conversation as resolved.
Show resolved Hide resolved

// log info if a sub-module doesn't have a readme.md and continue
if err != nil {
Log.Info("Skiping metadata for sub-module", "Path:", modPath)
g-awmalik marked this conversation as resolved.
Show resolved Hide resolved
continue
}

err = generateMetadataForBpPath(modPath)
if err != nil {
errors = append(errors, err.Error())
}
Expand Down