106 lines
3.7 KiB
Ruby
106 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.4.25.tar.gz"
|
|
sha256 "7ad239c3bbdf61ffbefb57ffdb1141da55ec6a8d65b6a48da4ca73479ad6e163"
|
|
license "Apache-2.0"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "9ae1fa3494a977182c71ca2b7724f2abbbe1b40297c4f7570efa9880285c31b7"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8b00a56627008b4d66d2d1c69d7f7e1feeafd082d8877cb2b4d94d78ad020b6b"
|
|
sha256 cellar: :any_skip_relocation, monterey: "e6a872c1467d7abab67602633e811c629fae72af8c3d9156318da3b6b58348bf"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "8f551134f4d97213e4c89deda5eb2e0ce1aac0c86eed34a675abdb488a15b0f2"
|
|
sha256 cellar: :any_skip_relocation, catalina: "abf8800bf67dd0901a8e6e608294a6605f7990e67c01b6995fb887f42a18b729"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "a4af16b6a7274de634b3e80c11c4ab4131e1c76cf19bc9995acca90a950c7ee1"
|
|
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
|
|
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
|