Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: hyperfleet.redhat.com/v1alpha1
kind: AdapterConfig
metadata:
name: cl-deployment
labels:
hyperfleet.io/adapter-type: cl-deployment
hyperfleet.io/component: adapter
spec:
adapter:
version: "0.1.0"

# Log the full merged configuration after load (default: false)
debugConfig: false

clients:
hyperfleetApi:
baseUrl: CHANGE_ME
version: v1
timeout: 2s
retryAttempts: 3
retryBackoff: exponential

broker:
subscriptionId: CHANGE_ME
topic: CHANGE_ME

kubernetes:
apiVersion: "v1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Simple valid HyperFleet Adapter Configuration for testing

apiVersion: hyperfleet.redhat.com/v1alpha1
kind: AdapterTaskConfig
metadata:
name: cl-deployment
labels:
hyperfleet.io/adapter-type: cl-deployment
hyperfleet.io/component: adapter
spec:
# Parameters with all required variables
params:
- name: "clusterId"
source: "event.id"
type: "string"
required: true

# Preconditions with valid operators and CEL expressions
preconditions:
- name: "clusterStatus"
apiCall:
method: "GET"
url: "/clusters/{{ .clusterId }}"
timeout: 10s
retryAttempts: 3
retryBackoff: "exponential"
capture:
- name: "clusterName"
field: "name"
- name: "generationSpec"
field: "generation"
- name: "readyConditionStatus"
expression: |
status.conditions.filter(c, c.type == "Ready").size() > 0
? status.conditions.filter(c, c.type == "Ready")[0].status
: "False"
# Structured conditions with valid operators
conditions:
- field: "readyConditionStatus"
operator: "equals"
value: "False"

- name: "clusterAdapterStatus"
apiCall:
method: "GET"
url: "/clusters/{{ .clusterId }}/statuses"
timeout: 10s
retryAttempts: 3
retryBackoff: "exponential"
capture:
- name: "clusterJobStatus"
field: "{.items[?(@.adapter=='cl-job')].conditions[?(@.type=='Available')].status}"
conditions:
- field: "clusterJobStatus"
operator: "equals"
value: "True"

# Resources with valid K8s manifests
resources:
- name: "testDeployment"
manifest:
ref: "/etc/adapter/deployment.yaml"
discovery:
namespace: "{{ .clusterId }}"
bySelectors:
labelSelector:
hyperfleet.io/resource-type: "deployment"
hyperfleet.io/cluster-id: "{{ .clusterId }}"

# Post-processing with valid CEL expressions
post:
payloads:
- name: "clusterStatusPayload"
build:
adapter: "{{ .metadata.name }}"
conditions:
# Applied: Deployment successfully created
- type: "Applied"
status:
expression: |
has(resources.testDeployment) ? "True" : "False"
reason:
expression: |
has(resources.testDeployment)
? "DeploymentApplied"
: "DeploymentPending"
message:
expression: |
has(resources.testDeployment)
? "testDeployment manifest applied successfully"
: "testDeployment is pending to be applied"
# Available: Check deployment status conditions
- type: "Available"
status:
expression: |
has(resources.testDeployment) ?
( resources.?testDeployment.?status.?conditions.orValue([]).exists(c, c.type == "Available")
? resources.testDeployment.status.conditions.filter(c, c.type == "Available")[0].status : "Unknown")
: "Unknown"
reason:
expression: |
resources.?testDeployment.?status.?conditions.orValue([]).exists(c, c.type == "Available")
? resources.testDeployment.status.conditions.filter(c, c.type == "Available")[0].reason
: resources.?testDeployment.?status.?conditions.orValue([]).exists(c, c.type == "Progressing" && c.status == "False") ? "DeploymentFailed"
: resources.?testDeployment.?status.hasValue() ? "DeploymentInProgress" : "DeploymentPending"
message:
expression: |
resources.?testDeployment.?status.?conditions.orValue([]).exists(c, c.type == "Available")
? resources.testDeployment.status.conditions.filter(c, c.type == "Available")[0].message
: resources.?testDeployment.?status.?conditions.orValue([]).exists(c, c.type == "Progressing" && c.status == "False") ? "Deployment failed"
: resources.?testDeployment.?status.hasValue() ? "Deployment in progress" : "Deployment is pending"
# Health: Adapter execution status (runtime)
- type: "Health"
status:
expression: |
adapter.?executionStatus.orValue("") == "success" ? "True" : "False"
reason:
expression: |
adapter.?errorReason.orValue("") != "" ? adapter.?errorReason.orValue("") : "Healthy"
message:
expression: |
adapter.?errorMessage.orValue("") != "" ? adapter.?errorMessage.orValue("") : "All adapter operations in progress or completed successfully"
# Event generation ID metadata field needs to use expression to avoid interpolation issues
observed_generation:
expression: "generationSpec"
observed_time: "{{ now | date \"2006-01-02T15:04:05Z07:00\" }}"

postActions:
- name: "reportClusterStatus"
apiCall:
method: "POST"
url: "/clusters/{{ .clusterId }}/statuses"
headers:
- name: "Content-Type"
value: "application/json"
body: "{{ .clusterStatusPayload }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Test deployment template
apiVersion: apps/v1
kind: Deployment
metadata:
name: "test-nginx-{{ .clusterId }}"
namespace: "{{ .clusterId }}"
labels:
hyperfleet.io/cluster-id: "{{ .clusterId }}"
hyperfleet.io/resource-type: "deployment"
annotations:
hyperfleet.io/generation: "{{ .generationSpec }}"
spec:
replicas: 1
selector:
matchLabels:
app: test
hyperfleet.io/cluster-id: "{{ .clusterId }}"
template:
metadata:
labels:
app: test
hyperfleet.io/cluster-id: "{{ .clusterId }}"
spec:
containers:
- name: test
image: nginx:latest
ports:
- containerPort: 80

31 changes: 31 additions & 0 deletions testdata/adapter-configs/clusters-cl-deployment/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
adapterConfig:
create: true
files:
adapter-config.yaml: clusters-cl-deployment/adapter-config.yaml
log:
level: debug

adapterTaskConfig:
create: true
files:
task-config.yaml: clusters-cl-deployment/adapter-task-config.yaml
deployment.yaml: clusters-cl-deployment/adapter-task-resource-deployment.yaml

broker:
create: true
googlepubsub:
projectId: CHANGE_ME
subscriptionId: CHANGE_ME
topic: CHANGE_ME
deadLetterTopic: CHANGE_ME

image:
registry: CHANGE_ME
repository: hyperfleet-adapter
pullPolicy: Always
tag: latest

rbac:
resources:
- deployments
- deployments/status
28 changes: 28 additions & 0 deletions testdata/adapter-configs/clusters-cl-job/adapter-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: hyperfleet.redhat.com/v1alpha1
kind: AdapterConfig
metadata:
name: cl-job
labels:
hyperfleet.io/adapter-type: cl-job
hyperfleet.io/component: adapter
spec:
adapter:
version: "0.1.0"

# Log the full merged configuration after load (default: false)
debugConfig: false

clients:
hyperfleetApi:
baseUrl: CHANGE_ME
version: v1
timeout: 2s
retryAttempts: 3
retryBackoff: exponential

broker:
subscriptionId: CHANGE_ME
topic: CHANGE_ME

kubernetes:
apiVersion: "v1"
Loading