diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..df37c68 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,15 @@ +on: + pull_request: + +name: "ShellCheck" + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + env: + SHELLCHECK_OPTS: -e SC2154 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03d5018..8ba38e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,12 @@ repos: exclude: ^examples/ - id: terraform_docs exclude: ^examples/ + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: check-merge-conflict + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.7.2 + hooks: + - id: shellcheck diff --git a/README.md b/README.md index 4da8ed5..a5a553c 100644 --- a/README.md +++ b/README.md @@ -45,14 +45,14 @@ You can check the status of the certificate in the Google Cloud Console. | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.2.0 | +| [terraform](#requirement\_terraform) | >= 0.13.0 | | [google](#requirement\_google) | >=4.47.0 | ## Providers | Name | Version | |------|---------| -| [google](#provider\_google) | 4.47.0 | +| [google](#provider\_google) | >=4.47.0 | ## Modules diff --git a/main.tf b/main.tf index 70b43bf..f62f323 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,7 @@ locals { - // The default port that Atlantis runs on is 4141. + # The default port that Atlantis runs on is 4141. atlantis_port = lookup(var.env_vars, "ATLANTIS_PORT", 4141) - // Atlantis its home directory is "/home/atlantis". + # Atlantis its home directory is "/home/atlantis". atlantis_data_dir = lookup(var.env_vars, "ATLANTIS_DATA_DIR", "/home/atlantis") port_name = "atlantis" } @@ -35,8 +35,8 @@ resource "google_compute_instance_template" "atlantis" { machine_type = var.machine_type can_ip_forward = false - // Using the below scheduling configuration, - // the managed instance group will recreate the Spot VM if Compute Engine stops them + # Using the below scheduling configuration, + # the managed instance group will recreate the Spot VM if Compute Engine stops them scheduling { automatic_restart = var.spot_machine_enabled ? false : true preemptible = var.spot_machine_enabled ? true : false @@ -45,7 +45,7 @@ resource "google_compute_instance_template" "atlantis" { instance_termination_action = var.spot_machine_enabled ? "STOP" : null } - // Ephemeral OS boot disk + # Ephemeral OS boot disk disk { source_image = data.google_compute_image.cos.self_link auto_delete = true @@ -61,7 +61,7 @@ resource "google_compute_instance_template" "atlantis" { } } - // Persistent disk for Atlantis + # Persistent disk for Atlantis disk { device_name = "atlantis-disk-0" disk_type = "pd-ssd" @@ -94,8 +94,8 @@ resource "google_compute_instance_template" "atlantis" { project = var.project - // Instance Templates cannot be updated after creation with the Google Cloud Platform API. - // In order to update an Instance Template, Terraform will destroy the existing resource and create a replacement + # Instance Templates cannot be updated after creation with the Google Cloud Platform API. + # In order to update an Instance Template, Terraform will destroy the existing resource and create a replacement lifecycle { create_before_destroy = true } @@ -108,9 +108,9 @@ module "atlantis" { container = { image = var.image securityContext = { - privileged : true + privileged = true } - tty : true + tty = true env = [for key, value in var.env_vars : { name = key value = value diff --git a/startup-script.sh b/startup-script.sh index bd476b7..7a48b05 100644 --- a/startup-script.sh +++ b/startup-script.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Exit immediately if a command returns a non-zero code +set -e + cat > /etc/systemd/system/atlantis-chown-disk.service <