Skip to content

Commit

Permalink
test: added modules for single function with secret tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-s committed Aug 8, 2024
1 parent bb9518c commit 0cf7d7d
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/modules/single_function_with_secret/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
data "qernal_provider" "digitalocean" {
name = "digitalocean"
}

resource "qernal_function" "function" {
project_id = var.project_id
version = "1.0.0"
name = var.function_name
description = "Hello world"
image = "testcontainers/helloworld:1.1.0"
port = 80
type = "http"

scaling = {
high = 80
low = 20
type = "cpu"
}

size = {
cpu = 128
memory = 128
}
compliance = ["ipv6"] // TODO: allow this to be blank

deployment {
location = {
provider_id = data.qernal_provider.digitalocean.id
country = "GB"
}

replicas = {
min = 1
max = 1
affinity = {
cloud = false
cluster = false
}
}
}

route {
path = "/*"
methods = ["GET", "HEAD"]
weight = 100
}

secrets = [
{
name = "ENV_VAR"
reference = var.secret_reference
}
]
}
11 changes: 11 additions & 0 deletions tests/modules/single_function_with_secret/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "project_id" {
type = string
}

variable "function_name" {
type = string
}

variable "secret_reference" {
type = string
}
59 changes: 59 additions & 0 deletions tests/modules/single_function_with_secret_datasource/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
data "qernal_provider" "digitalocean" {
name = "digitalocean"
}

data "qernal_secret_environment" "env_secret" {
project_id = var.project_id
name = var.secret_name
}

resource "qernal_function" "function" {
project_id = var.project_id
version = "1.0.0"
name = var.function_name
description = "Hello world"
image = "testcontainers/helloworld:1.1.0"
port = 80
type = "http"

scaling = {
high = 80
low = 20
type = "cpu"
}

size = {
cpu = 128
memory = 128
}
compliance = ["ipv6"] // TODO: allow this to be blank

deployment {
location = {
provider_id = data.qernal_provider.digitalocean.id
country = "GB"
}

replicas = {
min = 1
max = 1
affinity = {
cloud = false
cluster = false
}
}
}

route {
path = "/*"
methods = ["GET", "HEAD"]
weight = 100
}

secrets = [
{
name = "ENV_VAR"
reference = qernal_secret_environment.env_secret.reference
}
]
}
11 changes: 11 additions & 0 deletions tests/modules/single_function_with_secret_datasource/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "project_id" {
type = string
}

variable "function_name" {
type = string
}

variable "secret_name" {
type = string
}

0 comments on commit 0cf7d7d

Please sign in to comment.