homebrew-core/Formula/atmos.rb

105 lines
3.7 KiB
Ruby

class Atmos < Formula
desc "Universal Tool for DevOps and Cloud Automation"
homepage "https://github.com/cloudposse/atmos"
url "https://github.com/cloudposse/atmos/archive/v1.3.26.tar.gz"
sha256 "3340c800791ddad98bb4ae1eb75011411a8b5b21297630855295494f90addf14"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "5de97c4f1e8555e88488283b0f2c4526bc96e64ef2c7765ca8ed2391d547716c"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "2ce242b4785a81517b923aa43bbd7eb4ba0dedbe190b2dda2aaecfce5ad91541"
sha256 cellar: :any_skip_relocation, monterey: "3b2fb5ac8adad60481b41c3d49f6bc85315b2ef53ae3c680b3b719deeedb7df4"
sha256 cellar: :any_skip_relocation, big_sur: "b2e954e82df2eeddd601b2e12b17873f66a6595abd463b9ab2e5be353a8d94f5"
sha256 cellar: :any_skip_relocation, catalina: "b0d9729a264dfa9a288b5ce899d278a3a60caa83bcf5a4413679fd07b797c49c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "54c0d3f179d22c5d08a42387b3d821212187066f5c8e88405787e5d0f2d05089"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args(ldflags: "-s -w -X 'github.com/cloudposse/atmos/cmd.Version=#{version}'")
end
test do
# create basic atmos.yaml
(testpath/"atmos.yaml").write <<~EOT
components:
terraform:
base_path: "./components/terraform"
apply_auto_approve: false
deploy_run_init: true
auto_generate_backend_file: false
helmfile:
base_path: "./components/helmfile"
kubeconfig_path: "/dev/shm"
helm_aws_profile_pattern: "{namespace}-{tenant}-gbl-{stage}-helm"
cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-eks-cluster"
stacks:
base_path: "./stacks"
included_paths:
- "**/*"
excluded_paths:
- "globals/**/*"
- "catalog/**/*"
- "**/*globals*"
name_pattern: "{tenant}-{environment}-{stage}"
logs:
verbose: false
colors: true
EOT
# create scaffold
mkdir_p testpath/"stacks"
mkdir_p testpath/"components/terraform/top-level-component1"
(testpath/"stacks/tenant1-ue2-dev.yaml").write <<~EOT
terraform:
backend_type: s3 # s3, remote, vault, static, etc.
backend:
s3:
encrypt: true
bucket: "eg-ue2-root-tfstate"
key: "terraform.tfstate"
dynamodb_table: "eg-ue2-root-tfstate-lock"
acl: "bucket-owner-full-control"
region: "us-east-2"
role_arn: null
remote:
vault:
vars:
tenant: tenant1
region: us-east-2
environment: ue2
components:
terraform:
top-level-component1: {}
EOT
# create expected file
(testpath/"backend.tf.json").write <<~EOT
{
"terraform": {
"backend": {
"s3": {
"workspace_key_prefix": "top-level-component1",
"acl": "bucket-owner-full-control",
"bucket": "eg-ue2-root-tfstate",
"dynamodb_table": "eg-ue2-root-tfstate-lock",
"encrypt": true,
"key": "terraform.tfstate",
"region": "us-east-2",
"role_arn": null
}
}
}
}
EOT
system bin/"atmos", "terraform", "generate", "backend", "top-level-component1", "--stack", "tenant1-ue2-dev"
actual_json = JSON.parse(File.read(testpath/"components/terraform/top-level-component1/backend.tf.json"))
expected_json = JSON.parse(File.read(testpath/"backend.tf.json"))
assert_equal expected_json["terraform"].to_set, actual_json["terraform"].to_set
end
end