glue scripts in Go, how to package and distribute

blov · · 504 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Lets say for example, you have a github repo that handles your infrastructure for an application. We&#39;ll call this repo <code>infrastructure</code>. 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.</p> <p>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.</p> <p>For Go, what is the intended way to accomplish this? Do I:</p> <ol> <li><p>create a separate repo in my Go workspace called <code>infrastructure_builder</code> (for example), then create a binary, and store that in the <code>infrastructure</code> repo with my above project?</p></li> <li><p>have the Go source files co-exist in the same repo as my <code>infrastructure</code> 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?</p></li> <li><p>or because I plan to glue this together with Go, simply put all the above <code>infrastructure</code> project, in the Go workspace and have the Go source code live alongside it.</p></li> </ol> <p>Or is there another way of handling this?</p> <hr/>**评论:**<br/><br/>Zikes: <pre><p>I like to use <code>make</code>, since it&#39;s fairly standard. One of the great things about this is make can assume that Go is installed on the builder machine, so you can <code>go get</code> other Go tools and run project &#34;scripts&#34; with <code>go run some_script.go</code>.</p></pre>mcandre: <pre><p>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.</p></pre>antiphase_: <pre><p>Why, in the name of all that is good and holy, would you put a script into a Docker container?</p></pre>mcandre: <pre><p>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.</p></pre>sacrehubert: <pre><p>To avoid the usual &#34;it works on <em>my</em> machine...&#34; issues.</p></pre>dtirer: <pre><p>To clarify what I mean by glue scripts. Before running any terraform commands, we have to make sure that:</p> <ul> <li><p>terraform init has been run in the correct environment . </p></li> <li><p>that any terraform modules have been downloaded . </p></li> <li><p>we need to grab a couple secrets from AWS Parameter Store that serve as input to Terraform . </p></li> <li><p>etc... </p></li> </ul> <p>So I&#39;m looking write a script that encapsulates some of these things in single commands like: <code>builder init staging</code>, and so forth</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

504 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传