Lets say for example, you have a github repo that handles your infrastructure for an application. We'll call this repo infrastructure
. It has some Terraform scripts, some Ansible scripts, etc. Now lets say you want to glue it all together with a Go binary that you build.
If this were Ruby or Python, I would write a simple script with various commands to interface with the above tools, and I would include it with the above repo.
For Go, what is the intended way to accomplish this? Do I:
create a separate repo in my Go workspace called
infrastructure_builder
(for example), then create a binary, and store that in theinfrastructure
repo with my above project?have the Go source files co-exist in the same repo as my
infrastructure
project, and build a binary perhaps on deployment of that project. If I did this, how does that work as far as the Go workspaces?or because I plan to glue this together with Go, simply put all the above
infrastructure
project, in the Go workspace and have the Go source code live alongside it.
Or is there another way of handling this?
评论:
Zikes:
mcandre:I like to use
make
, since it's fairly standard. One of the great things about this is make can assume that Go is installed on the builder machine, so you cango get
other Go tools and run project "scripts" withgo run somescript.go
.
antiphase:To begin with, version control the scripts into some git repositories. Bundle into a Docker container, RPM, DEB, TGZ, or such. Gradually replace each script with a pure Go equivalent.
mcandre:Why, in the name of all that is good and holy, would you put a script into a Docker container?
sacrehubert:Not for transport, for installation. Glue code is a vague term. If the script is meant to function as part of a machine, then install it so. If, on the other hand the script is meant to manage machines, and be invoked by humans, then just keep it in a git repository.
dtirer:To avoid the usual "it works on my machine..." issues.
To clarify what I mean by glue scripts. Before running any terraform commands, we have to make sure that:
terraform init has been run in the correct environment .
that any terraform modules have been downloaded .
we need to grab a couple secrets from AWS Parameter Store that serve as input to Terraform .
etc...
So I'm looking write a script that encapsulates some of these things in single commands like: builder init staging
, and so forth
