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
498 changes: 249 additions & 249 deletions deploy-scripts/lib/adapter.sh

Large diffs are not rendered by default.

41 changes: 18 additions & 23 deletions testdata/adapter-configs/cl-deployment/adapter-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
apiVersion: hyperfleet.redhat.com/v1alpha1
kind: AdapterConfig
metadata:
adapter:
name: cl-deployment
labels:
hyperfleet.io/adapter-type: cl-deployment
hyperfleet.io/component: adapter
spec:
adapter:
version: "0.1.0"
#version: "0.1.0"

# Log the full merged configuration after load (default: false)
debugConfig: false
# Log the full merged configuration after load (default: false)
debug_config: false
log:
level: debug

clients:
hyperfleetApi:
baseUrl: CHANGE_ME
version: v1
timeout: 2s
retryAttempts: 3
retryBackoff: exponential
clients:
hyperfleet_api:
base_url: CHANGE_ME
version: v1
timeout: 2s
retry_attempts: 3
retry_backoff: exponential

broker:
subscriptionId: CHANGE_ME
topic: CHANGE_ME
broker:
subscription_id: CHANGE_ME
topic: CHANGE_ME

kubernetes:
apiVersion: "v1"
kubernetes:
api_version: "v1"
252 changes: 123 additions & 129 deletions testdata/adapter-configs/cl-deployment/adapter-task-config.yaml
Original file line number Diff line number Diff line change
@@ -1,136 +1,130 @@
# 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
# 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"
# Preconditions with valid operators and CEL expressions
preconditions:
- name: "clusterStatus"
api_call:
method: "GET"
url: "/clusters/{{ .clusterId }}"
timeout: 10s
retry_attempts: 3
retry_backoff: "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"
- name: "clusterAdapterStatus"
api_call:
method: "GET"
url: "/clusters/{{ .clusterId }}/statuses"
timeout: 10s
retry_attempts: 3
retry_backoff: "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 }}"
# Resources with valid K8s manifests
resources:
- name: "testDeployment"
transport:
client: "kubernetes"
manifest:
ref: "/etc/adapter/deployment.yaml"
discovery:
namespace: "{{ .clusterId }}"
by_selectors:
label_selector:
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\" }}"
# Post-processing with valid CEL expressions
post:
payloads:
- name: "clusterStatusPayload"
build:
adapter: "{{ .adapter.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 }}"
post_actions:
- name: "reportClusterStatus"
api_call:
method: "POST"
url: "/clusters/{{ .clusterId }}/statuses"
headers:
- name: "Content-Type"
value: "application/json"
body: "{{ .clusterStatusPayload }}"
6 changes: 3 additions & 3 deletions testdata/adapter-configs/cl-deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ adapterTaskConfig:
broker:
create: true
googlepubsub:
projectId: CHANGE_ME
subscriptionId: CHANGE_ME
project_id: CHANGE_ME
subscription_id: CHANGE_ME
topic: CHANGE_ME
deadLetterTopic: CHANGE_ME
dead_letter_topic: CHANGE_ME

image:
registry: CHANGE_ME
Expand Down
41 changes: 18 additions & 23 deletions testdata/adapter-configs/cl-job/adapter-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
apiVersion: hyperfleet.redhat.com/v1alpha1
kind: AdapterConfig
metadata:
adapter:
name: cl-job
labels:
hyperfleet.io/adapter-type: cl-job
hyperfleet.io/component: adapter
spec:
adapter:
version: "0.1.0"
#version: "0.1.0"

# Log the full merged configuration after load (default: false)
debugConfig: false
# Log the full merged configuration after load (default: false)
debug_config: false
log:
level: debug

clients:
hyperfleetApi:
baseUrl: CHANGE_ME
version: v1
timeout: 2s
retryAttempts: 3
retryBackoff: exponential
clients:
hyperfleet_api:
base_url: CHANGE_ME
version: v1
timeout: 2s
retry_attempts: 3
retry_backoff: exponential

broker:
subscriptionId: CHANGE_ME
topic: CHANGE_ME
broker:
subscription_id: CHANGE_ME
topic: CHANGE_ME

kubernetes:
apiVersion: "v1"
kubernetes:
api_version: "v1"
Loading