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.10.4.tar.gz"
sha256 "b13fda0fff0504cdd0879ba42bff358ff3150d79642c406a6ba999f9f684fb9e"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "530afb97b227519addf9e52d416640be0aad09dc0ff569fe7aeab1035d6e7599"
sha256 cellar: :any_skip_relocation, arm64_monterey: "426245f48d88c32c428b95f70dc9fff00c1fedf63e0c5b4a07561e18801482eb"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "5d42c31c377a92bf2f0034f32fd37d133d2dff63c5985e0175860108a63b06c3"
sha256 cellar: :any_skip_relocation, monterey: "5dd9417a49b3037f573362172f6d0ac17214a2584aa3baffc79faf0c2b113fea"
sha256 cellar: :any_skip_relocation, big_sur: "caa677afef69e462e9967cfd4b0fcaa140e7febeb169ea728f5b9847d5b97817"
sha256 cellar: :any_skip_relocation, catalina: "e9c09e4a0e41b1e011553a99caac1d002848657feddcf8f7e228d9e59ff4c2c8"
sha256 cellar: :any_skip_relocation, x86_64_linux: "d4d5ccd99206362881e087866f155c0cd9a4e92c021cddb079af5ffa5d47c087"
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