Skip to content

Commit

Permalink
func: add providers to enos
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Dec 3, 2024
1 parent eaed7a8 commit c0c6d96
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 12 deletions.
10 changes: 10 additions & 0 deletions enos/enos-terraform.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

terraform {
required_providers {
enos = {
source = "registry.terraform.io/hashicorp-forge/enos"
}
}
}
61 changes: 60 additions & 1 deletion enos/enos-vars.hcl
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
# SPDX-License-Identifier: BUSL-1.1

# Variables for the fetch_artifactory module
variable "artifactory_username" {
type = string
description = "The username to use when connecting to artifactory"
default = null
}

variable "artifactory_token" {
type = string
description = "The token to use when connecting to artifactory"
default = null
sensitive = true
}

variable "artifactory_host" {
type = string
description = "The artifactory host to search for Nomad artifacts"
default = "https://artifactory.hashicorp.engineering/artifactory"
}

variable "artifactory_repo" {
type = string
description = "The artifactory repo to search for Nomad artifacts"
default = "hashicorp-crt-stable-local*"
}

variable "edition" {
type = string
description = "The edition of the binary to search, it can be either CE or ENT"
}

variable "revision" {
type = string
description = "The specific commit of the binary"
}

variable "os" {
type = string
description = "The operative system the binary is needed for"
default = "linux"
}

variable "product_version" {
description = "The version of Nomad we are testing"
type = string
default = null
}

variable "arch" {
description = "The artifactory path to search for Nomad artifacts"
type = string
}

variable "binary_path" {
description = "The path to donwload and unzip the binary"
type = string
default = "/home/ubuntu/nomad"
}
3 changes: 1 addition & 2 deletions enos/modules/fetch_artifactory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ data "enos_artifactory_item" "nomad" {
path = local.path
name = local.artifact_name
properties = tomap({
"commit" = var.revision
"product-name" = var.edition == "ce" ? "nomad" : "nomad-enterprise"
})
}
Expand All @@ -30,4 +29,4 @@ resource "enos_local_exec" "install_binary" {
}

scripts = [abspath("${path.module}/scripts/install.sh")]
}
}
19 changes: 10 additions & 9 deletions enos/modules/fetch_artifactory/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
set -xeuo pipefail

# Variables
OUTPUT="nomad.zip" # Name for the downloaded file
LOCAL_ZIP="nomad.zip" # Name for the downloaded file

# Download the file
wget --header="X-JFrog-Art-Api:$TOKEN" -O- "$OUTPUT" "$URL"
wget --header="X-JFrog-Art-Api:$TOKEN" -O- "$LOCAL_ZIP" "$URL"

# Check if the file was downloaded
if [ $? -nq 0 ]; then
if [ $? -eq 0 ]; then
echo "File downloaded successfully: $LOCAL_ZIP"
else
echo "Error downloading file." >&2
exit 1
fi
Expand All @@ -20,13 +22,12 @@ fi
mkdir -p "$BINARY_PATH"

# Unzip the file
unzip -o "$OUTPUT" -d "$BINARY_PATH"
unzip -o "$LOCAL_ZIP" -d "$BINARY_PATH"

# Check if the file was unzipped
if [ $? -nq 0 ]; then
if [ $? -eq 0 ]; then
echo "File unzipped successfully to $BINARY_PATH"
else
echo "Error unzipping file." >&2
exit 1
fi

# Remove the zip file
rm $OUTPUT
fi

0 comments on commit c0c6d96

Please sign in to comment.