rosa

package
v2.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package rosa provides a way to interact with the Red Hat OpenShift Service on AWS (ROSA) API.

Package rosa provides a way to interact with the Red Hat OpenShift Service on AWS (ROSA) API.

Index

Constants

This section is empty.

Variables

View Source
var MinSupportedVersion = semver.MustParse("4.14.0")

MinSupportedVersion is the minimum supported version for ROSA.

Functions

func CheckExistingScheduledUpgrade

func CheckExistingScheduledUpgrade(client OCMClient, cluster *cmv1.Cluster) (*cmv1.ControlPlaneUpgradePolicy, error)

CheckExistingScheduledUpgrade checks and returns the current upgrade schedule if any.

func CreateAdminUserIfNotExist

func CreateAdminUserIfNotExist(client OCMClient, clusterID, username, password string) error

CreateAdminUserIfNotExist creates a new admin user withe username/password in the cluster if username doesn't already exist. the user is granted admin privileges by being added to a special IDP called `cluster-admin` which will be created if it doesn't already exist.

func CreateUserIfNotExist

func CreateUserIfNotExist(client OCMClient, clusterID string, group, username string) (*cmv1.User, error)

CreateUserIfNotExist creates a new user with `username` and adds it to the group if it doesn't already exist.

func IsNodePoolReady added in v2.4.1

func IsNodePoolReady(nodePool *cmv1.NodePool) bool

IsNodePoolReady checkes whether the nodepool is provisoned and all replicas are available. If autosacling is enabled, NodePool must have replicas >= autosacling.MinReplica to be considered ready.

func MachinePoolSupportedVersionsRange

func MachinePoolSupportedVersionsRange(controlPlaneVersion string) (*semver.Version, *semver.Version, error)

MachinePoolSupportedVersionsRange returns the supported range of versions for a machine pool based on the control plane version.

func NewOCMClient

func NewOCMClient(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (*ocm.Client, error)

NewOCMClient creates a new OCM client.

func RawVersionID

func RawVersionID(version *cmv1.Version) string

RawVersionID returns the rawID from the provided OCM version object.

func ScheduleControlPlaneUpgrade

func ScheduleControlPlaneUpgrade(client OCMClient, cluster *cmv1.Cluster, version string, nextRun time.Time, ack bool) (*cmv1.ControlPlaneUpgradePolicy, error)

ScheduleControlPlaneUpgrade schedules a new control plane upgrade to the specified version at the specified time.

func ScheduleNodePoolUpgrade added in v2.4.1

func ScheduleNodePoolUpgrade(client OCMClient, clusterID string, nodePool *cmv1.NodePool, version string, nextRun time.Time) (*cmv1.NodePoolUpgradePolicy, error)

ScheduleNodePoolUpgrade schedules a new nodePool upgrade to the specified version at the specified time.

Types

type ExternalAuthClient added in v2.5.0

type ExternalAuthClient struct {
	// contains filtered or unexported fields
}

ExternalAuthClient handles externalAuth operations.

func NewExternalAuthClient added in v2.5.0

func NewExternalAuthClient(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (*ExternalAuthClient, error)

NewExternalAuthClient creates and return a new client to handle externalAuth operations.

func (*ExternalAuthClient) Close added in v2.5.0

func (c *ExternalAuthClient) Close() error

Close closes the underlying ocm connection.

func (*ExternalAuthClient) CreateBreakGlassCredential added in v2.5.0

func (c *ExternalAuthClient) CreateBreakGlassCredential(clusterID string, breakGlassCredential *cmv1.BreakGlassCredential) (*cmv1.BreakGlassCredential, error)

CreateBreakGlassCredential creates a break glass credential.

func (*ExternalAuthClient) CreateExternalAuth added in v2.5.0

func (c *ExternalAuthClient) CreateExternalAuth(clusterID string, externalAuth *cmv1.ExternalAuth) (*cmv1.ExternalAuth, error)

CreateExternalAuth creates a new external auth porivder.

func (*ExternalAuthClient) DeleteExternalAuth added in v2.5.0

func (c *ExternalAuthClient) DeleteExternalAuth(clusterID string, externalAuthID string) error

DeleteExternalAuth deletes the specified external auth porivder.

func (*ExternalAuthClient) GetExternalAuth added in v2.5.0

func (c *ExternalAuthClient) GetExternalAuth(clusterID string, externalAuthID string) (*cmv1.ExternalAuth, bool, error)

GetExternalAuth retrieves the specified external auth porivder.

func (*ExternalAuthClient) ListExternalAuths added in v2.5.0

func (c *ExternalAuthClient) ListExternalAuths(clusterID string) ([]*cmv1.ExternalAuth, error)

ListExternalAuths lists all external auth porivder for the cluster.

func (*ExternalAuthClient) PollKubeconfig added in v2.5.0

func (c *ExternalAuthClient) PollKubeconfig(ctx context.Context, clusterID string, credentialID string) (kubeconfig string, err error)

PollKubeconfig continuously polls for the kubeconfig of the provided break glass credential.

func (*ExternalAuthClient) UpdateExternalAuth added in v2.5.0

func (c *ExternalAuthClient) UpdateExternalAuth(clusterID string, externalAuth *cmv1.ExternalAuth) (*cmv1.ExternalAuth, error)

UpdateExternalAuth updates an existing external auth porivder.

type OCMClient added in v2.7.2

type OCMClient interface {
	AckVersionGate(clusterID string, gateID string) error
	AddHTPasswdUser(username string, password string, clusterID string, idpID string) error
	CreateNodePool(clusterID string, nodePool *v1.NodePool) (*v1.NodePool, error)
	CreateIdentityProvider(clusterID string, idp *v1.IdentityProvider) (*v1.IdentityProvider, error)
	CreateCluster(config ocm.Spec) (*v1.Cluster, error)
	CreateUser(clusterID string, group string, user *v1.User) (*v1.User, error)
	DeleteCluster(clusterKey string, bestEffort bool, creator *aws.Creator) (*v1.Cluster, error)
	DeleteNodePool(clusterID string, nodePoolID string) error
	DeleteUser(clusterID string, group string, username string) error
	GetCluster(clusterKey string, creator *aws.Creator) (*v1.Cluster, error)
	GetControlPlaneUpgradePolicies(clusterID string) (controlPlaneUpgradePolicies []*v1.ControlPlaneUpgradePolicy, err error)
	GetHTPasswdUserList(clusterID string, htpasswdIDPId string) (*v1.HTPasswdUserList, error)
	GetIdentityProviders(clusterID string) ([]*v1.IdentityProvider, error)
	GetMissingGateAgreementsHypershift(clusterID string, upgradePolicy *v1.ControlPlaneUpgradePolicy) ([]*v1.VersionGate, error)
	GetNodePool(clusterID string, nodePoolID string) (*v1.NodePool, bool, error)
	GetHypershiftNodePoolUpgrade(clusterID string, clusterKey string, nodePoolID string) (*v1.NodePool, *v1.NodePoolUpgradePolicy, error)
	GetUser(clusterID string, group string, username string) (*v1.User, error)
	ScheduleHypershiftControlPlaneUpgrade(clusterID string, upgradePolicy *v1.ControlPlaneUpgradePolicy) (*v1.ControlPlaneUpgradePolicy, error)
	ScheduleNodePoolUpgrade(clusterID string, nodePoolID string, upgradePolicy *v1.NodePoolUpgradePolicy) (*v1.NodePoolUpgradePolicy, error)
	UpdateNodePool(clusterID string, nodePool *v1.NodePool) (*v1.NodePool, error)
	UpdateCluster(clusterKey string, creator *aws.Creator, config ocm.Spec) error
	ValidateHypershiftVersion(versionRawID string, channelGroup string) (bool, error)
}

OCMClient wraps ocm.Client methods that we use in interface, so we are able to mock it. We should get rid of this once ocm.Client has its own interface.

func NewMockOCMClient added in v2.7.2

func NewMockOCMClient(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (OCMClient, error)

NewMockOCMClient creates a new empty ocm.Client without any real connection.

func NewWrappedOCMClient added in v2.7.2

func NewWrappedOCMClient(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (OCMClient, error)

NewWrappedOCMClient creates a new OCM client wrapped in ocmclient struct that implements OCMClient interface. This is needed to be able to mock OCM in tests. NewOCMClient is left unchanged so we don't change public interface.

type TokenResponse

type TokenResponse struct {
	AccessToken string
	ExpiresIn   time.Duration
}

TokenResponse contains the access token and the duration until it expires.

func RequestToken

func RequestToken(ctx context.Context, apiURL, username, password string, config *restclient.Config) (*TokenResponse, error)

RequestToken requests an OAuth access token for the specified API server using username/password credentials. returns a TokenResponse which contains the AccessToken and the ExpiresIn duration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL