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.18.0.tar.gz"
sha256 "b2411cf1ab849b6c5c696180eb1c412530da9e7d06fd7e948154415ea535b83c"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "af2b8902255480b5b3e103f0691d288cc55b7217afd4f62b4c3114867bdbedce"
sha256 cellar: :any_skip_relocation, arm64_monterey: "d93feffd8a8f1bb5e90b15240e65b32bb26a6e04475b0cf9f498eff542fce9d4"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "de1fc56ee28ba038329244b0f367597adb99f7c88d328ace97b87ab6b68372d4"
sha256 cellar: :any_skip_relocation, ventura: "af6cb3605d3112fe4e10a1af2f57c7708e2922fe4d1d558da47dc0ca8a024ba4"
sha256 cellar: :any_skip_relocation, monterey: "81cc34710b492269e4cc087e9c645157e9525cc0919c3c905bd4746b5f293baa"
sha256 cellar: :any_skip_relocation, big_sur: "31e08d07eaa61985e029f430b0d0a745493801ab96446009de1cb191ae3c22de"
sha256 cellar: :any_skip_relocation, x86_64_linux: "5ed7e48f75209c7e98630c94b0245b962ea7b5bd915084df7f6bcc5fddbf6ab6"
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