homebrew-core/Formula/atmos.rb

109 lines
3.9 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.16.0.tar.gz"
sha256 "63dffb8c7bb695ce6e750ec4fc4c196ff4cdb7f165d772bc4a9889ecf5949330"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "693c3e0f00ed561c86cc3e09c7925e9d359f4ebbb70cee842721e1e05aaf3126"
sha256 cellar: :any_skip_relocation, arm64_monterey: "a3678a42f612a8bfac6a68398c8017d020731bac272bb24cfc0716163101153e"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "6f87e437746a7e646741b2f12b72d8c4dd0cfd0e365b0d35e4edd406c4cda6f9"
sha256 cellar: :any_skip_relocation, ventura: "d3f143f4cf75bb9746cf1dc8b71bd919bfe71512b40559cf7c9ad2d7f00ec0ba"
sha256 cellar: :any_skip_relocation, monterey: "73c626dead84a4bdd70a94980432f718d1e26a44c4965af8468159191959c69e"
sha256 cellar: :any_skip_relocation, big_sur: "c84a778a9cd72a09cb9879044a191ad808c48381d9e3da70f35681f02df70c30"
sha256 cellar: :any_skip_relocation, x86_64_linux: "160619973410a931cc10d42134f2808340cc4e4543fad140116ab2d56909247d"
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