108 lines
3.8 KiB
Ruby
108 lines
3.8 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.10.3.tar.gz"
|
|
sha256 "420185c52a939c2fcec7183ed5e23eaa2744666a81eb3a4c48b945b4a46690a4"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "ff1899d9ad658b843e7370ec5ec558d37f1260c2e30f1d5c4336cd089c2da18f"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "997f0c79f1412609d6578febee4c1022f9aafb62753a6f68ae7fe0ae2d1673bd"
|
|
sha256 cellar: :any_skip_relocation, monterey: "91fce744386c7db085a98cb7994abd9972cc020096a1a7f577ebd25c8dbe3576"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "bf416104d7750e75f236bedfe646288134ac65320d185ee88fa07c22b3a9c239"
|
|
sha256 cellar: :any_skip_relocation, catalina: "3058f7f3b61ab227316083f0571127538caee790d6d14c03c433d52f1293476a"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "854070b5a68c673becfb8ff461db2bb19d64c782d26163a20cf4b13382372c04"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
system "go", "build", *std_go_args(ldflags: "-s -w -X 'github.com/cloudposse/atmos/cmd.Version=#{version}'")
|
|
|
|
generate_completions_from_executable(bin/"atmos", "completion")
|
|
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
|
|
stage: dev
|
|
|
|
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
|