Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
57 changes: 57 additions & 0 deletions modules/schemahero_controller/facets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
intent: schemahero-controller
flavor: default
version: '0.1'
description: Deploys SchemaHero controller for automated database schema management
in Kubernetes environments
lifecycle: ENVIRONMENT_BOOTSTRAP
clouds:
- kubernetes
input_type: config
spec:
type: object
properties:
size:
type: object
title: Resource Configuration
description: CPU and memory resource limits for the schemahero controller
properties:
cpu:
type: string
title: CPU Limit
description: CPU resource limit for the schemahero controller
default: 100m
pattern: ^[0-9]+[m]?$
memory:
Comment on lines +18 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

CPU pattern too restrictive for valid Kubernetes quantities

^[0-9]+[m]?$ forbids fractional cores such as 0.5, which are valid CPU requests/limits.
Consider a more permissive regex (or simply rely on Kubernetes validation).

-          pattern: ^[0-9]+[m]?$
+          # Accept integers, millicores (m) and decimal cores (e.g. 0.5)
+          pattern: ^([0-9]+m?|[0-9]*\.[0-9]+)$
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cpu:
type: string
title: CPU Limit
description: CPU resource limit for the schemahero controller
default: 100m
pattern: ^[0-9]+[m]?$
memory:
cpu:
type: string
title: CPU Limit
description: CPU resource limit for the schemahero controller
default: 100m
# Accept integers, millicores (m) and decimal cores (e.g. 0.5)
pattern: ^([0-9]+m?|[0-9]*\.[0-9]+)$
memory:
🤖 Prompt for AI Agents
In modules/schemahero_controller/facets.yaml around lines 18 to 24, the regex
pattern for the CPU limit field is too restrictive and disallows valid
Kubernetes CPU quantities like fractional cores (e.g., 0.5). Update the pattern
to allow decimal numbers with optional 'm' suffix or remove the pattern entirely
to rely on Kubernetes native validation for CPU resource quantities.

type: string
title: Memory Limit
description: Memory resource limit for the schemahero controller
default: 150Mi
pattern: ^[0-9]+[KMGT]?[i]?[Bb]?$
default:
cpu: 100m
memory: 150Mi
required: []
inputs:
kubernetes_details:
type: '@outputs/kubernetes-cluster-details'
optional: false
default:
resource_type: kubernetes_cluster
resource_name: default
displayName: Kubernetes Cluster Details
description: Kubernetes cluster configuration and provider access
providers:
- kubernetes
- helm
outputs:
default:
type: '@outputs/schemahero-controller'
title: SchemaHero Controller Installation
sample:
kind: schemahero-controller
flavor: default
version: '0.1'
spec:
size:
cpu: 100m
memory: 150Mi
29 changes: 29 additions & 0 deletions modules/schemahero_controller/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
locals {
spec = lookup(var.instance, "spec", {})
size = lookup(local.spec, "size", {})
advanced = lookup(var.instance, "advanced", {})
user_supplied_helm_values = lookup(lookup(local.advanced, "default", {}), "values", {})
constructed_helm_values = <<VALUES
resources:
limits:
cpu: ${lookup(local.size, "cpu", "100m")}
memory: ${lookup(local.size, "memory", "150Mi")}
schemahero:
image: facetscloud/schemahero-manager:latest
VALUES
Comment on lines +11 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin the controller image instead of using :latest

Using the latest tag makes upgrades implicit and unreproducible.
Pin to an immutable digest or a semantic version and expose it as a variable.

-schemahero:
-  image: facetscloud/schemahero-manager:latest
+schemahero:
+  # Pinned for deterministic deployments
+  image: facetscloud/schemahero-manager:0.15.4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
schemahero:
image: facetscloud/schemahero-manager:latest
VALUES
schemahero:
# Pinned for deterministic deployments
image: facetscloud/schemahero-manager:0.15.4
VALUES
🤖 Prompt for AI Agents
In modules/schemahero_controller/main.tf around lines 11 to 13, the schemahero
controller image is currently using the `:latest` tag, which makes upgrades
implicit and unreproducible. Replace the `:latest` tag with a specific semantic
version or an immutable digest. Additionally, expose this image tag or digest as
a variable so it can be easily updated and managed.

}

resource "helm_release" "schemahero" {
chart = "${path.module}/schemahero-helm"
name = "schemahero"
atomic = false
cleanup_on_fail = true
namespace = "facets"
values = [local.constructed_helm_values, yamlencode(local.user_supplied_helm_values),
Comment on lines +21 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Parameterise the namespace – avoid hard-coding "facets"

Tie the release to var.environment.namespace (defaulting to "default").
This keeps the module portable across clusters / tenants.

-  namespace       = "facets"
+  namespace       = lookup(var.environment, "namespace", "default")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
namespace = "facets"
values = [local.constructed_helm_values, yamlencode(local.user_supplied_helm_values),
namespace = lookup(var.environment, "namespace", "default")
values = [local.constructed_helm_values, yamlencode(local.user_supplied_helm_values),
🤖 Prompt for AI Agents
In modules/schemahero_controller/main.tf around lines 21 to 22, the namespace is
hard-coded as "facets". Replace the hard-coded string with a reference to
var.environment.namespace, which should default to "default". This change will
parameterize the namespace, making the module more portable across different
clusters or tenants.

yamlencode({
tolerations = concat(var.environment.default_tolerations, var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_tolerations)
nodeSelector = var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_node_selectors
})
Comment on lines +24 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Guard optional maps with lookup/try to prevent runtime crashes

Direct attribute access explodes with "Invalid index" when the key is absent.
Wrap them in try()/lookup() and provide safe fall-backs.

-      tolerations  = concat(var.environment.default_tolerations, var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_tolerations)
-      nodeSelector = var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_node_selectors
+      tolerations = concat(
+        lookup(var.environment, "default_tolerations", []),
+        try(var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_tolerations, [])
+      )
+      nodeSelector = try(var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_node_selectors, {})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tolerations = concat(var.environment.default_tolerations, var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_tolerations)
nodeSelector = var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_node_selectors
})
tolerations = concat(
lookup(var.environment, "default_tolerations", []),
try(var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_tolerations, [])
)
nodeSelector = try(var.inputs.kubernetes_details.attributes.legacy_outputs.facets_dedicated_node_selectors, {})
})
🤖 Prompt for AI Agents
In modules/schemahero_controller/main.tf around lines 24 to 26, the code
directly accesses map attributes which can cause runtime errors if the keys are
missing. To fix this, wrap the map accesses with the Terraform functions try()
or lookup() and provide default fallback values to safely handle absent keys and
prevent "Invalid index" errors.

]
recreate_pods = true
}
4 changes: 4 additions & 0 deletions modules/schemahero_controller/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
output_interfaces = {}
output_attributes = {}
}
11 changes: 11 additions & 0 deletions modules/schemahero_controller/schemahero-helm/.commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends:
- '@commitlint/config-conventional'

rules:
type-enum:
- 2
- always
-
- chore
- feat
- fix
4 changes: 4 additions & 0 deletions modules/schemahero_controller/schemahero-helm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
crds/
templates/
.github/
*.json
12 changes: 12 additions & 0 deletions modules/schemahero_controller/schemahero-helm/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[README.md]
max_line_length = 120
32 changes: 32 additions & 0 deletions modules/schemahero_controller/schemahero-helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
package*.json
node_modules/
.github/
test/
skaffold.yaml
.releaserc.yaml
.editorconfig
.dockerignore

24 changes: 24 additions & 0 deletions modules/schemahero_controller/schemahero-helm/.releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
branches:
- main

tagFormat: "${version}"

plugins:
- '@semantic-release/commit-analyzer'
- 'semantic-release-commitlint'
-
- "@semantic-release/release-notes-generator"
- preset: "conventionalcommits"
-
- "@semantic-release/git"
- assets: []
messsage: false
-
- "@semantic-release/github"
- successComment: false
failComment: false
-
- '@eshepelyuk/semantic-release-helm-oci'
- registry: oci://ghcr.io/schemahero/helm
skipAppVersion: true
Comment on lines +6 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

YAML structure breaks Semantic-Release – plugin entries & “messsage” typo

Several list items are malformed (nested array instead of [plugin, options]) and the key messsage is misspelled, so Semantic-Release will crash on startup.

Minimal fix:

 plugins:
   - '@semantic-release/commit-analyzer'
   - 'semantic-release-commitlint'
-  -
-    - "@semantic-release/release-notes-generator"
-    - preset: "conventionalcommits"
-  -
-    - "@semantic-release/git"
-    - assets: []
-      messsage: false
-  -
-    - "@semantic-release/github"
-    - successComment: false
-      failComment: false
-  -
-    - '@eshepelyuk/semantic-release-helm-oci'
-    - registry: oci://ghcr.io/schemahero/helm
-      skipAppVersion: true
+  - ['@semantic-release/release-notes-generator', {preset: 'conventionalcommits'}]
+  - ['@semantic-release/git', {assets: [], message: false}]
+  - ['@semantic-release/github', {successComment: false, failComment: false}]
+  - ['@eshepelyuk/semantic-release-helm-oci', {registry: 'oci://ghcr.io/schemahero/helm', skipAppVersion: true}]

Without this change, CI/CD will fail at the release step.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
plugins:
- '@semantic-release/commit-analyzer'
- 'semantic-release-commitlint'
-
- "@semantic-release/release-notes-generator"
- preset: "conventionalcommits"
-
- "@semantic-release/git"
- assets: []
messsage: false
-
- "@semantic-release/github"
- successComment: false
failComment: false
-
- '@eshepelyuk/semantic-release-helm-oci'
- registry: oci://ghcr.io/schemahero/helm
skipAppVersion: true
plugins:
- '@semantic-release/commit-analyzer'
- 'semantic-release-commitlint'
- ['@semantic-release/release-notes-generator', {preset: 'conventionalcommits'}]
- ['@semantic-release/git', {assets: [], message: false}]
- ['@semantic-release/github', {successComment: false, failComment: false}]
- ['@eshepelyuk/semantic-release-helm-oci', {registry: 'oci://ghcr.io/schemahero/helm', skipAppVersion: true}]
🤖 Prompt for AI Agents
In modules/schemahero_controller/schemahero-helm/.releaserc.yaml between lines 6
and 23, the YAML structure for the semantic-release plugins is incorrect because
some plugins are defined as nested arrays instead of the correct [plugin,
options] format, and there is a typo in the key "messsage" which should be
"message". Fix the YAML by converting nested arrays into proper mappings with
plugin names as keys and their options as values, and correct the typo
"messsage" to "message" to ensure semantic-release parses the config correctly
and does not crash.


42 changes: 42 additions & 0 deletions modules/schemahero_controller/schemahero-helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v2
name: schemahero
description: Install and configure SchemaHero in Kubernetes.
type: application
version: 0.0.0 # chart version introspected from git release tags
appVersion: 0.13.1
icon: https://raw.githubusercontent.com/schemahero/schemahero/main/artwork/color/svg/schemahero-logomark-color.svg
home: https://github.com/schemahero/schemahero-helm
maintainers:
- name: Ievgenii Shepeliuk
email: [email protected]
url: https://github.com/eshepelyuk
keywords:
- schemahero
- database
- kubernetes
- postgresql
- migration
annotations:
artifacthub.io/links: |
- name: SchemaHero site
url: https://schemahero.io/
- name: SchemaHero sources
url: https://github.com/schemahero/schemahero

artifacthub.io/crds: |
- kind: Database
version: v1alpha4
name: database
displayName: Database
description: Database is the Schema for the databases API
- kind: Migration
version: v1alpha4
name: migration
displayName: Migration
description: Migration is the Schema for the migrations API
- kind: Table
version: v1alpha4
name: table
displayName: Table
description: Table is the Schema for the tables API

Loading
Loading