Skip to content

Conversation

@rh-amarin
Copy link
Contributor

@rh-amarin rh-amarin commented Jan 27, 2026

Introduces a new adapter dev CLI toolset for local adapter development and testing.
This enables developers to validate configurations and dry-run events without requiring:

  • Kubernetes cluster: It uses a mock
  • Message broker: It accepts a cloudEvent from a file
  • HyperFleet API: It reads HTTP responses from a YAML file

2 New Commands

./adapter dev validate - Offline configuration validation

  • Validates YAML syntax and schema structure
  • Checks parameter definitions and references
  • Validates CEL expression syntax
  • Validates Go template variable references
  • Validates Kubernetes manifest structure
  • Supports --strict mode (treats warnings as errors)
  • Output formats: text or json (for CI pipelines)

./adapter dev run - Dry-run event processing

  • Executes the full adapter pipeline in simulation mode
  • No actual Kubernetes API calls (uses dry-run K8s client)
  • No actual HyperFleet API calls (uses mock API client)
  • Displays execution trace for each phase (Parameter Extraction, Preconditions, Resources, Post
    Actions)
  • Supports mock API responses via --mock-api-responses YAML file
  • Supports environment variable loading via --env-file
  • Verbose mode (-v) shows:
    • Rendered Kubernetes manifests
    • Simulated API calls with request body and response body
    • Extracted parameters and phase details

Key Features

  • Mock API Client: Configure custom responses for API endpoints using URL patterns (exact match or
    regex)
  • Dry-Run K8s Client: Records all Kubernetes operations without executing them
  • Execution Tracing: Detailed trace of each execution phase with success/failure status
  • Multiple Output Formats: Human-readable text or JSON for automation

Files Added

  • cmd/adapter/dev.go - Parent dev command
  • cmd/adapter/dev_run.go - Dry-run subcommand
  • cmd/adapter/dev_validate.go - Validation subcommand
  • internal/dev/ - Core dev tooling implementation
  • sample.yaml - Example mock API responses
  • test/cloudevent.example.cluster.json - Example test event

example run:

$> HYPERFLEET_API_VERSION=v1 HYPERFLEET_API_BASE_URL=https://api.example.com ./adapter dev run  -c /User
s/amarin/work/workspaces/github/hyperfleet/hyperfleet-adapter/aadapter/launch-cli/configs/adapter-config
-template.yaml -e ./test/cloudevent.example.cluster.json --mock-api-responses `pwd`/sample.yaml -v     

Dry-Run Execution Results
=========================

Phase: Parameter Extraction [SUCCESS]
  count: 9
  params: map[clusterId:cluster-123 clusterName:<nil> clusterPhase:NotReady clusterStatus:map[cloudProvi
der:aws generation:1 id:cluster-123 kind:Cluster region:us-east-1 status:map[conditions:[map[reason:Clus
terReady status:True type:Available]] phase:NotReady] vpcId:vpc-12345] clusterStatusPayload:{"adapter":"
example-adapter","conditions":[{"message":"Namespace creation in progress","reason":"NamespacePending","
status":"False","type":"Applied"},{"message":"Namespace is not active and ready","reason":"NamespaceNotR
eady","status":"False","type":"Available"},{"message":"All adapter operations completed successfully","r
eason":"Healthy","status":"True","type":"Health"}],"data":{"namespace":{"name":"cluster-123","status":""
}},"observed_generation":1,"observed_time":"2026-01-27T23:43:11+01:00"} generationId:1 hyperfleetApiBase
Url:https://api.example.com hyperfleetApiVersion:v1 metadata:map[labels:map[hyperfleet.io/adapter-type:e
xample hyperfleet.io/component:adapter] name:example-adapter namespace:hyperfleet-system]]

Phase: Preconditions        [SUCCESS]
  count: 1
  matched: 1

Phase: Resources            [DRY-RUN]
  count: 1
  operations: map[create:1]

Phase: Post Actions         [SUCCESS]
  count: 1
  executed: 1

Rendered Manifests:
  [cluster-123]
    apiVersion: v1
    kind: Namespace
    metadata:
        annotations:
            hyperfleet.io/created-by: hyperfleet-adapter
            hyperfleet.io/generation: "1"
        labels:
            hyperfleet.io/cluster-id: cluster-123
            hyperfleet.io/managed-by: example-adapter
            hyperfleet.io/resource-type: namespace
        name: cluster-123
    

API Calls (simulated):
  GET https://api.example.com/api/hyperfleet/v1/clusters/cluster-123
    Response [200]: {"cloudProvider":"aws","generation":1,"id":"cluster-123","kind":"Cluster","region":"
us-east-1","status":{"conditions":[{"reason":"ClusterReady","status":"True","type":"Available"}],"phase"
:"NotReady"}...
  POST https://api.example.com/api/hyperfleet/v1/clusters/cluster-123/statuses
    Request Body: {"adapter":"example-adapter","conditions":[{"message":"Namespace creation in progress"
,"reason":"NamespacePending","status":"False","type":"Applied"},{"message":"Namespace is not active and 
ready","re...
    Response [200]: {"cloudProvider":"aws","generation":1,"id":"cluster-123","kind":"Cluster","region":"
us-east-1","status":{"conditions":[{"reason":"ClusterReady","status":"True","type":"Available"}],"phase"
:"NotReady"}...

@openshift-ci
Copy link

openshift-ci bot commented Jan 27, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link

openshift-ci bot commented Jan 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tirthct for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant