Skip to content

OCM-22845 | feat: return available_channels in the rhcs_version data source#1090

Open
BraeTroutman wants to merge 2 commits intoterraform-redhat:mainfrom
BraeTroutman:OCM-22845/version-chnl
Open

OCM-22845 | feat: return available_channels in the rhcs_version data source#1090
BraeTroutman wants to merge 2 commits intoterraform-redhat:mainfrom
BraeTroutman:OCM-22845/version-chnl

Conversation

@BraeTroutman
Copy link
Contributor

@BraeTroutman BraeTroutman commented Mar 16, 2026

PR Summary

Adds a new available_channels field to the rhcs_version data source, that will allow users of said data source to view the channels on which a particular version is available. This is a direct propogation from the available_channels field from the versions REST API object on the CS side

Detailed Description of the Issue

Users of the rhcs TF provider have the ability to list and filter OCP versions available from the OCM API. This resource, rhcs_versions, currently only returns two computed values: name and id, which can be used in a cluster or machinepool creation.

Now that we have the channel property coming to clusters, users should also be able to see the channels available to a version, so that they can manage the channels they assign to a cluster (if any) in the same declarative way that they manage versions.

Related Issues and PRs

Type of Change

  • feat - adds a new user-facing capability.
  • fix - resolves an incorrect behavior or bug.
  • docs - updates documentation only.
  • style - formatting or naming changes with no logic impact.
  • refactor - code restructuring with no behavior change.
  • test - adds or updates tests only.
  • chore - maintenance work (tooling, housekeeping, non-product code).
  • build - changes build system, packaging, or dependencies for build output.
  • ci - changes CI pipelines, jobs, or automation workflows.
  • perf - improves performance without changing intended behavior.

Previous Behavior

the rhcs_versions data source only computes id and name fields

Behavior After This Change

the available_channels computed field is added to the versions datasource in both item and items types. Behavior of filtering and item vs items population should be unchanged (i.e. they're still populated in the same way. This is tested in the classic subsystem tests)

How to Test (Step-by-Step)

Preconditions

  • valid OCM log in (preferably a client id + client secret) but the output of your ocm token is also valid.

Test Steps

  1. if testing before merge of this PR, run make install to install the local TF provider
  2. create a local terraform directory for testing, e.g. mkdir version-channels-tf
  3. create the following main.tf:
# file: main.tf
terraform {
  required_providers {
    rhcs = {
      source  = "terraform.local/local/rhcs" # note this should be terraform-redhat/rhcs if you're using the official provider
      version = ">= 1.7.5"                                 # this also may need to be updated to match the tagged version if building locally
    }
  }
}

provider "rhcs" {
  client_id     = "***"
  client_secret = "***"
  token_url     = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token"
  url           = "https://api.integration.openshift.com"
}

data "rhcs_versions" "version_info" {
  search = "id = 'openshift-v4.16.50'"
}

output "channels" {
  value = data.rhcs_versions.version_info.item.available_channels
}

Expected Results

When running terraform apply:

channels = tolist([
  "candidate-4.17",
  "candidate-4.18",
  "eus-4.16",
  "eus-4.18",
  "fast-4.17",
  "fast-4.18",
  "stable-4.17",
  "stable-4.18",
])

Currently all versions should have available_channels, so there should be no situation in which this output would be empty: that possibility is nevertheless accounted for in subsystem tests in which the list of available channels is expected to be empty

Proof of the Fix

  • Screenshots:
  • Videos:
  • Logs/CLI output:
  • Other artifacts:

Breaking Changes

  • No breaking changes
  • Yes, this PR introduces a breaking change (describe impact and migration plan below)

Breaking Change Details / Migration Plan

Developer Verification Checklist

  • Commit subject/title follows [JIRA-TICKET] | [TYPE]: <MESSAGE>.
  • PR description clearly explains both what changed and why.
  • Relevant Jira/GitHub issues and related PRs are linked.
  • Tests were added/updated where appropriate.
  • I manually tested the change.
  • make test passes.
  • make fmt passes.
  • make build passes.
  • Documentation was added/updated where appropriate.
  • Any risk, limitation, or follow-up work is documented.

@openshift-ci
Copy link

openshift-ci bot commented Mar 16, 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 olucasfreitas 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

@BraeTroutman BraeTroutman force-pushed the OCM-22845/version-chnl branch 3 times, most recently from b9fa316 to 85d66a7 Compare March 16, 2026 14:49
@BraeTroutman BraeTroutman force-pushed the OCM-22845/version-chnl branch from 85d66a7 to 49a441b Compare March 16, 2026 15:01
@BraeTroutman
Copy link
Contributor Author

/retest-required

Copy link
Contributor

@olucasfreitas olucasfreitas left a comment

Choose a reason for hiding this comment

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

@BraeTroutman Can we add a test case in the subsystem tests, where available_channels is missing or empty in API response to validate edge behavior for this new field?

@BraeTroutman BraeTroutman force-pushed the OCM-22845/version-chnl branch from 49a441b to 0c7750c Compare March 16, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants