Skip to content
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
41 changes: 39 additions & 2 deletions internal/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Only a single environment may be suitable for an initial test, but for a real sy

applyAll(rootDir, *projectConfig, environments)

// TODO Summary
flog.Infof(":check_mark_button: Done - Summary goes here.")
flog.Infof(":check_mark_button: Done.")

summarizeAll(rootDir, *projectConfig, environments)
}

func applyAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEnvironments []string) {
Expand Down Expand Up @@ -127,3 +128,39 @@ func validateEnvironments(applyEnvironments []string) {
}
}
}

func summarizeAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEnvironments []string) {
flog.Infof("Your projects and infrastructure have been successfully created. Here are some useful links and commands to get you started:")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the Infof statements in this function.. just wanted to get placeholders in to show text at the beginning and end of the summary.


graph := projectConfig.GetDAG()

// Walk the graph of modules and run `make summary`
root := []dag.Vertex{projectconfig.GraphRootName}
graph.DepthFirstWalk(root, func(v dag.Vertex, depth int) error {
// Don't process the root
if depth == 0 {
return nil
}

name := v.(string)
mod := projectConfig.Modules[name]
// Add env vars for the makefile
envList := []string{
fmt.Sprintf("ENVIRONMENT=%s", strings.Join(applyEnvironments, ",")),
fmt.Sprintf("REPOSITORY=%s", mod.Files.Repository),
}

modulePath := module.GetSourceDir(mod.Files.Source)
// Passed in `dir` will only be used to find the project path, not the module path,
// unless the module path is relative
if module.IsLocal(mod.Files.Source) && !filepath.IsAbs(modulePath) {
modulePath = filepath.Join(dir, modulePath)
}

envList = util.AppendProjectEnvToCmdEnv(mod.Parameters, envList)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also pass the environments in so the summary can show accurate info based on what was created.

util.ExecuteCommand(exec.Command("make", "summary"), modulePath, envList)
return nil
})

flog.Infof("Happy coding! :smile:")
}
2 changes: 2 additions & 0 deletions tests/test_data/apply/project1/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
current_dir:
@echo "foo: ${foo}" > project.out
@echo "repo: ${REPOSITORY}" >> project.out

summary:
2 changes: 2 additions & 0 deletions tests/test_data/apply/project2/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
current_dir:
@echo "baz: ${baz}" > project.out

summary: