include:
  - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/apply@$CI_COMMIT_SHA
    inputs:
      image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE
      version: $CI_COMMIT_SHA
      opentofu_version: $OPENTOFU_VERSION
      as: 'setup:apply'
      stage: setup
      root_dir: $TEST_GITLAB_TOFU_ROOT_DIR
      state_name: $TEST_GITLAB_TOFU_STATE_NAME
      no_plan: true
      # Required to run everything immediately, instead of manually.
      rules: [{when: always}]

  - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/validate-plan-destroy@$CI_COMMIT_SHA
    inputs:
      image_registry_base: $GITLAB_OPENTOFU_IMAGE_BASE
      version: $CI_COMMIT_SHA
      opentofu_version: $OPENTOFU_VERSION
      root_dir: $TEST_GITLAB_TOFU_ROOT_DIR
      state_name: $TEST_GITLAB_TOFU_STATE_NAME
      # Required to run everything immediately, instead of manually.
      fmt_rules: [{when: always}]
      validate_rules: [{when: always}]
      plan_rules: [{when: always}]
      destroy_rules: [{when: always}]
      delete_state_rules: [{when: always}]

stages: [setup, validate, build, cleanup]
