Skip to content

Commit

Permalink
backport of commit fea81ab (#27115)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Cragun <[email protected]>
  • Loading branch information
1 parent 37d6518 commit 1b6e132
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 25 deletions.
14 changes: 8 additions & 6 deletions enos/enos-dev-scenario-pr-replication.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ scenario "dev_pr_replication" {
aws_region = "us-west-2"
aws_ssh_keypair_name = "<YOUR REGION SPECIFIC KEYPAIR NAME>"
aws_ssh_keypair_key_path = "/path/to/your/private/key.pem"
dev_build_local_ui = false
dev_consul_version = "1.18.1"
vault_license_path = "./support/vault.hclic"
vault_product_version = "1.16.2"
Expand Down Expand Up @@ -142,7 +143,7 @@ scenario "dev_pr_replication" {
}

// Begin scenario steps. These are the steps we'll perform to get your cluster up and running.
step "maybe_build_or_find_artifact" {
step "build_or_find_vault_artifact" {
description = <<-EOF
Depending on how we intend to get our Vault artifact, this step either builds vault from our
current branch or finds debian or redhat packages in Artifactory. If we're using a zip bundle
Expand Down Expand Up @@ -174,16 +175,16 @@ scenario "dev_pr_replication" {
tags. If left unset we'll automatically use the build tags that correspond to the edition
variant.
EOF
module = matrix.artifact == "local" ? "build_local" : local.use_artifactory ? "build_artifactory_package" : null
skip_step = matrix.artifact == "zip"
module = matrix.artifact == "local" ? "build_local" : local.use_artifactory ? "build_artifactory_package" : "build_crt"

variables {
// Used for all modules
arch = matrix.arch
edition = matrix.edition
product_version = var.vault_product_version
// Required for the local build which will always result in using a local zip bundle
artifact_path = var.vault_artifact_path
artifact_path = matrix.artifact == "local" ? abspath(var.vault_artifact_path) : null
build_ui = var.dev_build_local_ui
build_tags = var.vault_local_build_tags != null ? var.vault_local_build_tags : global.build_tags[matrix.edition]
goarch = matrix.arch
goos = "linux"
Expand Down Expand Up @@ -486,6 +487,7 @@ scenario "dev_pr_replication" {
depends_on = [
step.create_primary_backend_cluster,
step.create_primary_cluster_targets,
step.build_or_find_vault_artifact,
]

providers = {
Expand All @@ -496,7 +498,7 @@ scenario "dev_pr_replication" {
// We set vault_artifactory_release when we want to get a .deb or .rpm package from Artifactory.
// We set vault_release when we want to get a .zip bundle from releases.hashicorp.com
// We only set one or the other, never both.
artifactory_release = local.use_artifactory ? step.maybe_build_or_find_artifact.release : null
artifactory_release = local.use_artifactory ? step.build_or_find_vault_artifact.release : null
backend_cluster_name = step.create_primary_cluster_backend_targets.cluster_name
backend_cluster_tag_key = global.backend_tag_key
cluster_name = step.create_primary_cluster_targets.cluster_name
Expand Down Expand Up @@ -598,7 +600,7 @@ scenario "dev_pr_replication" {
// We set vault_artifactory_release when we want to get a .deb or .rpm package from Artifactory.
// We set vault_release when we want to get a .zip bundle from releases.hashicorp.com
// We only set one or the other, never both.
artifactory_release = local.use_artifactory ? step.maybe_build_or_find_artifact.release : null
artifactory_release = local.use_artifactory ? step.build_or_find_vault_artifact.release : null
backend_cluster_name = step.create_secondary_cluster_backend_targets.cluster_name
backend_cluster_tag_key = global.backend_tag_key
cluster_name = step.create_secondary_cluster_targets.cluster_name
Expand Down
11 changes: 7 additions & 4 deletions enos/enos-dev-scenario-single-cluster.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ scenario "dev_single_cluster" {
aws_region = "us-west-2"
aws_ssh_keypair_name = "<YOUR REGION SPECIFIC KEYPAIR NAME>"
aws_ssh_keypair_key_path = "/path/to/your/private/key.pem"
dev_build_local_ui = false
dev_consul_version = "1.18.1"
vault_license_path = "./support/vault.hclic"
vault_product_version = "1.16.2"
Expand Down Expand Up @@ -134,7 +135,7 @@ scenario "dev_single_cluster" {
}

// Begin scenario steps. These are the steps we'll perform to get your cluster up and running.
step "maybe_build_or_find_artifact" {
step "build_or_find_vault_artifact" {
description = <<-EOF
Depending on how we intend to get our Vault artifact, this step either builds vault from our
current branch or finds debian or redhat packages in Artifactory. If we're using a zip bundle
Expand Down Expand Up @@ -166,7 +167,7 @@ scenario "dev_single_cluster" {
tags. If left unset we'll automatically use the build tags that correspond to the edition
variant.
EOF
module = matrix.artifact == "local" ? "build_local" : local.use_artifactory ? "build_artifactory_package" : null
module = matrix.artifact == "local" ? "build_local" : local.use_artifactory ? "build_artifactory_package" : "build_crt"
skip_step = matrix.artifact == "zip"

variables {
Expand All @@ -175,8 +176,9 @@ scenario "dev_single_cluster" {
edition = matrix.edition
product_version = var.vault_product_version
// Required for the local build which will always result in using a local zip bundle
artifact_path = var.vault_artifact_path
artifact_path = matrix.artifact == "local" ? abspath(var.vault_artifact_path) : null
build_tags = var.vault_local_build_tags != null ? var.vault_local_build_tags : global.build_tags[matrix.edition]
build_ui = var.dev_build_local_ui
goarch = matrix.arch
goos = "linux"
// Required when using a RPM or Deb package
Expand Down Expand Up @@ -409,6 +411,7 @@ scenario "dev_single_cluster" {
depends_on = [
step.create_backend_cluster,
step.create_vault_cluster_targets,
step.build_or_find_vault_artifact,
]

providers = {
Expand All @@ -419,7 +422,7 @@ scenario "dev_single_cluster" {
// We set vault_artifactory_release when we want to get a .deb or .rpm package from Artifactory.
// We set vault_release when we want to get a .zip bundle from releases.hashicorp.com
// We only set one or the other, never both.
artifactory_release = local.use_artifactory ? step.maybe_build_or_find_artifact.release : null
artifactory_release = local.use_artifactory ? step.build_or_find_vault_artifact.release : null
backend_cluster_name = step.create_vault_cluster_backend_targets.cluster_name
backend_cluster_tag_key = global.backend_tag_key
cluster_name = step.create_vault_cluster_targets.cluster_name
Expand Down
6 changes: 6 additions & 0 deletions enos/enos-dev-variables.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

variable "dev_build_local_ui" {
type = bool
description = "Whether or not to build the web UI when using the local builder var. If the assets have already been built we'll still include them"
default = false
}

variable "dev_config_mode" {
type = string
description = "The method to use when configuring Vault. When set to 'env' we will configure Vault using VAULT_ style environment variables if possible. When 'file' we'll use the HCL configuration file for all configuration options."
Expand Down
17 changes: 13 additions & 4 deletions enos/enos-modules.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,31 @@ module "backend_raft" {
source = "./modules/backend_raft"
}

// Find any artifact in Artifactory. Requires the version, revision, and edition.
module "build_artifactory" {
source = "./modules/build_artifactory_artifact"
}

// Find any released RPM or Deb in Artifactory. Requires the version, edition, distro, and distro
// version.
module "build_artifactory_package" {
source = "./modules/build_artifactory_package"
}

// A shim "build module" suitable for use when using locally pre-built artifacts or a zip bundle
// from releases.hashicorp.com. When using a local pre-built artifact it requires the local
// artifact path. When using a release zip it does nothing as you'll need to configure the
// vault_cluster module with release info instead.
module "build_crt" {
source = "./modules/build_crt"
}

// Build the local branch and package it into a zip artifact. Requires the goarch, goos, build tags,
// and bundle path.
module "build_local" {
source = "./modules/build_local"
}

module "build_artifactory" {
source = "./modules/vault_artifactory_artifact"
}

module "create_vpc" {
source = "./modules/create_vpc"

Expand Down
1 change: 1 addition & 0 deletions enos/modules/build_artifactory_package/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ variable "artifact_path" { default = null }
variable "artifact_type" { default = null }
variable "artifactory_repo" { default = null }
variable "build_tags" { default = null }
variable "build_ui" { default = null }
variable "bundle_path" { default = null }
variable "goarch" { default = null }
variable "goos" { default = null }
Expand Down
1 change: 1 addition & 0 deletions enos/modules/build_crt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ variable "artifactory_token" { default = null }
variable "arch" { default = null }
variable "artifact_path" { default = null }
variable "artifact_type" { default = null }
variable "build_ui" { default = null }
variable "distro" { default = null }
variable "distro_version" { default = null }
variable "edition" { default = null }
Expand Down
19 changes: 13 additions & 6 deletions enos/modules/build_local/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ terraform {
}
}

variable "artifact_path" {
description = "Where to create the zip bundle of the Vault build"
}

variable "build_tags" {
type = list(string)
description = "The build tags to pass to the Go compiler"
}

variable "build_ui" {
type = bool
description = "Whether or not we should build the UI when creating the local build"
default = true
}

variable "goarch" {
type = string
description = "The Go architecture target"
Expand All @@ -31,10 +41,6 @@ variable "artifactory_repo" { default = null }
variable "artifactory_username" { default = null }
variable "artifactory_token" { default = null }
variable "arch" { default = null }
variable "artifact_path" {
type = string
default = "/tmp/vault.zip"
}
variable "artifact_type" { default = null }
variable "distro" { default = null }
variable "distro_version" { default = null }
Expand All @@ -51,8 +57,9 @@ resource "enos_local_exec" "build" {

environment = {
BASE_VERSION = module.local_metadata.version_base
BIN_PATH = "dist"
BUNDLE_PATH = var.artifact_path,
BIN_PATH = abspath("${path.module}/../../../dist")
BUILD_UI = tostring(var.build_ui)
BUNDLE_PATH = abspath(var.artifact_path)
GO_TAGS = join(" ", var.build_tags)
GOARCH = var.goarch
GOOS = var.goos
Expand Down
13 changes: 8 additions & 5 deletions enos/modules/build_local/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export CGO_ENABLED=0

root_dir="$(git rev-parse --show-toplevel)"
pushd "$root_dir" > /dev/null
make ci-build-ui ci-build

: "${BIN_PATH:="dist"}"
: "${BUNDLE_PATH:=$(git rev-parse --show-toplevel)/vault.zip}"
echo "--> Bundling $BIN_PATH/* to $BUNDLE_PATH"
zip -r -j "$BUNDLE_PATH" "$BIN_PATH/"
if [ -n "$BUILD_UI" ] && [ "$BUILD_UI" = "true" ]; then
make ci-build-ui
fi

make ci-build

popd > /dev/null

echo "--> Bundling $BIN_PATH/* to $BUNDLE_PATH"
zip -r -j "$BUNDLE_PATH" "$BIN_PATH/"

0 comments on commit 1b6e132

Please sign in to comment.