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

[apply] execute make in each project #145

Merged
merged 11 commits into from Jun 10, 2020
Merged

[apply] execute make in each project #145

merged 11 commits into from Jun 10, 2020

Conversation

thdaraujo
Copy link
Contributor

@thdaraujo thdaraujo commented Jun 2, 2020

Apply Command [closes #132]

This MR will add the zero apply basic functionality.

zero apply loads the zero-project.yaml config file and executes make on each module folder of a specific project, passing environment variables as received by the command.

The zero-project.yaml file was changed to reflect the spec (link). Notice the change to the modules attribute from a list to just a single map of modulues. See example below:

name: abc

context:

modules:
    infrastructure:
        parameters:
            repoName: infrastructure
            region: us-east-1
            accountId: 12345
            productionHost: something.com
        files:
            dir: infrastructure
            repo: https://github.com/myorg/infrastructure
    aws-eks-stack:
        files:
            dir: zero-aws-eks-stack
            repo: github.com/commitdev/zero-aws-eks-stack
    deployable-backend:
        files:
            dir: zero-deployable-backend
            repo: github.com/commitdev/zero-deployable-backend
    deployable-react-frontend:
        files:
            dir: zero-deployable-react-frontend
            repo: github.com/commitdev/zero-deployable-react-frontend

The struct projectconfig.ZeroProjectConfig that holds the unmarshalled config information was also changed to reflect that.

Some changes to the zero init function were also needed, like marshalling the config context that the user fills in during the execution of init and saving the zero-project.yaml file, and everything related to the struct.

@thdaraujo thdaraujo changed the title [apply] execute make in each project (WIP) [apply] execute make in each project Jun 3, 2020
@thdaraujo thdaraujo force-pushed the ta/make-projects branch 2 times, most recently from 423ea69 to 4d64652 Compare June 4, 2020 19:33
@thdaraujo thdaraujo marked this pull request as ready for review June 6, 2020 03:08
@thdaraujo thdaraujo changed the title (WIP) [apply] execute make in each project [apply] execute make in each project Jun 6, 2020
@thdaraujo thdaraujo self-assigned this Jun 8, 2020
Infrastructure Infrastructure // TODO simplify and flatten / rename?
Context map[string]string
Modules []string
Name string `yaml:"name"`
Copy link
Member

Choose a reason for hiding this comment

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

This will likely cause conflicts with @dtoki 's stuff but we can figure it out.

@@ -0,0 +1,43 @@
package projectconfig
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right place for this. Maybe move to an internal/apply package?

@@ -0,0 +1,65 @@
package context
Copy link
Member

Choose a reason for hiding this comment

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

Move to an internal/apply package?

fmt.Println(`Choose the environments to apply. This will create infrastructure, CI pipelines, etc.
At this point, real things will be generated that may cost money!
Only a single environment may be suitable for an initial test, but for a real system we suggest setting up both staging and production environments.`)
applyEnvironments = promptEnvironments()
Copy link
Member

Choose a reason for hiding this comment

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

This won't affect the value of applyEnvironments in the calling code, but it might be better to merge this and the stuff in the other file into the same package anyway.

@@ -63,11 +63,11 @@ func Init(projectName string, outDir string) *projectconfig.ZeroProjectConfig {
}

// loadAllModules takes a list of module sources, downloads those modules, and parses their config
func loadAllModules(moduleSources []string) map[string]moduleconfig.ModuleConfig {
func loadAllModules(moduleSources projectconfig.Modules) map[string]moduleconfig.ModuleConfig {
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't accept projectconfig.Modules, just a slice of string. At this point there is no project config and all we have are some repo paths.

Copy link
Contributor Author

@thdaraujo thdaraujo Jun 9, 2020

Choose a reason for hiding this comment

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

changed it back to a []string

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, could you remove the changes to the registry section as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Member

@bmonkman bmonkman left a comment

Choose a reason for hiding this comment

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

Some changes requested


// AppendProjectEnvToCmdEnv will add all the keys and values from envMap
// into envList as key-value pair strings (e.g.: "key=value")
func AppendProjectEnvToCmdEnv(envMap map[string]string, envList []string) []string {
Copy link
Member

Choose a reason for hiding this comment

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

This will conflict with a change in David's PR since he also moved this function. But I agree it should be here in util.

Copy link
Member

@bmonkman bmonkman left a comment

Choose a reason for hiding this comment

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

Nice! Thanks!

@thdaraujo thdaraujo merged commit dbfbb43 into master Jun 10, 2020
@thdaraujo thdaraujo deleted the ta/make-projects branch June 10, 2020 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply Command - Execute make in each project
2 participants