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 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
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
22 changes: 19 additions & 3 deletions cli/bpmetadata/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ func generate(cmd *cobra.Command, args []string) error {

var allBpPaths []string
currBpPath := path.Join(wdPath, mdFlags.path)
allBpPaths = append(allBpPaths, currBpPath)
_, err = os.Stat(path.Join(currBpPath, readmeFileName))

// throw an error and exit if root level readme.md doesn't exist
if err != nil {
return fmt.Errorf("Top-level module does not have a readme. Details: %w\n", err)
}

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 +84,17 @@ 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))

// log info if a sub-module doesn't have a readme.md and continue
if err != nil {
Log.Info("Skipping metadata for sub-module identified as an internal module", "Path:", modPath)
continue
}

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