Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add terraform module #198

Merged
merged 21 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ jobs:
sudo apt install tox
- run: tox -vve argo-controller-lint

terraform-checks:
name: Terraform
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@orfeas-k-add-terraform-checks-reusable-workflow
with:
charm-path: ./charms/argo-controller
model: kubeflow
channel: latest/edge

unit:
name: Unit Tests
runs-on: ubuntu-20.04
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ __pycache__
operators/argo-controller/build
.tox
.idea
venv/
.terraform*
*.tfstate*
3 changes: 3 additions & 0 deletions charms/argo-controller/terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Terraform module for argo-controller

This is a Terraform module facilitating the deployment of argo-controller charm, using the [Terraform juju provider](https://registry.terraform.io/providers/juju/juju/latest/docs).
13 changes: 13 additions & 0 deletions charms/argo-controller/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "juju_application" "argo_controller" {
charm {
name = "argo-controller"
channel = var.channel
revision = var.revision
}
config = var.config
model = var.model_name
name = var.app_name
resources = var.resources
trust = true
units = 1
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
}
17 changes: 17 additions & 0 deletions charms/argo-controller/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
output "app_name" {
value = juju_application.argo_controller.name
}

output "provides" {
value = {
metrics_endpoint = "metrics-endpoint",
grafana_dashboard = "grafana-dashboard"
}
}

output "requires" {
value = {
object_storage = "object-storage",
logging = "logging"
}
}
35 changes: 35 additions & 0 deletions charms/argo-controller/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
variable "app_name" {
description = "Application name"
type = string
default = "argo-controller"
}

variable "channel" {
description = "Charm channel"
type = string
default = null
}

variable "config" {
description = "Map of charm configuration options"
type = map(string)
default = {}
}

variable "model_name" {
description = "Model name"
type = string
}

# TODO: Update to a map of strings, once juju provider 0.14 is released
variable "resources" {
description = "Map of resources revisions"
type = map(number)
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
default = null
}

variable "revision" {
description = "Charm revision"
type = number
default = null
}
9 changes: 9 additions & 0 deletions charms/argo-controller/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.6"
required_providers {
juju = {
source = "juju/juju"
version = "~> 0.13.0"
}
}
}
7 changes: 7 additions & 0 deletions charms/argo-controller/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ deps =
-r requirements-lint.txt
description = Check code against coding style standards

[testenv:tflint]
allowlist_externals =
tflint
commands =
tflint --chdir=terraform --recursive
description = Check Terraform code against coding style standards

[testenv:unit]
commands =
coverage run --source={[vars]src_path} \
Expand Down
Loading