ocm

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: Apache-2.0 Imports: 34 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ANY                 = "any"
	HibernateCapability = "capability.organization.hibernate_cluster"
	//Pendo Events
	Success   = "Success"
	Failure   = "Failure"
	Response  = "Response"
	ClusterID = "ClusterID"
	Version   = "Version"
	Username  = "Username"
	URL       = "URL"

	OCMRoleLabel  = "sts_ocm_role"
	USERRoleLabel = "sts_user_role"
)
View Source
const AcceleratedComputing = "accelerated_computing"
View Source
const DefaultChannelGroup = "stable"
View Source
const LowestSTSMinor = "4.7"
View Source
const LowestSTSSupport = "4.7.11"

Variables

View Source
var NetworkTypes = []string{"OpenShiftSDN", "OVNKubernetes"}
View Source
var URLAliases = map[string]string{
	"production":  "https://api.openshift.com",
	"staging":     "https://api.stage.openshift.com",
	"integration": "https://api.integration.openshift.com",
}

URLAliases allows the value of the `--env` option to map to the various API URLs.

Functions

func AddClusterFlag added in v1.1.5

func AddClusterFlag(cmd *cobra.Command)

func CheckSupportedVersion added in v1.1.11

func CheckSupportedVersion(clusterVersion string, operatorVersion string) (bool, error)

func ClusterNameValidator added in v1.1.1

func ClusterNameValidator(name interface{}) error

func GetClusterKey added in v1.1.5

func GetClusterKey() (string, error)

func GetEnv added in v1.1.0

func GetEnv() (string, error)

func GetVersionID added in v1.1.0

func GetVersionID(cluster *cmv1.Cluster) string

func GetVersionMinor added in v1.1.10

func GetVersionMinor(ver string) string

func GetVersionMinorList added in v1.1.3

func GetVersionMinorList(ocmClient *Client) (versionList []string, err error)

Get a list of all STS-supported minor versions

func HasSTSSupport added in v1.1.0

func HasSTSSupport(rawID string, channelGroup string) bool

func HasSTSSupportMinor added in v1.1.0

func HasSTSSupportMinor(minor string) bool

func IdentityProviderType

func IdentityProviderType(idp *cmv1.IdentityProvider) string

func IsEmptyCIDR added in v1.1.0

func IsEmptyCIDR(cidr net.IPNet) bool

func IsValidClusterKey

func IsValidClusterKey(clusterKey string) bool

func IsValidClusterName added in v1.1.0

func IsValidClusterName(clusterName string) bool

func IsValidUsername

func IsValidUsername(username string) bool

func Location added in v1.1.0

func Location() (path string, err error)

Location returns the location of the configuration file. If a configuration file already exists in the HOME directory, it uses that, otherwise it prefers to use the XDG config directory.

func RandomLabel added in v1.1.2

func RandomLabel(size int) string

func Remove added in v1.1.0

func Remove() error

Remove removes the configuration file.

func Save added in v1.1.0

func Save(cfg *Config) error

Save saves the given configuration to the configuration file.

func SaveDocument added in v1.1.12

func SaveDocument(doc string, filename string) error

func SetClusterKey added in v1.1.5

func SetClusterKey(key string)

func ValidateAdditionalTrustBundle added in v1.1.6

func ValidateAdditionalTrustBundle(val interface{}) error

func ValidateHTTPProxy added in v1.1.6

func ValidateHTTPProxy(val interface{}) error

func ValidateVersion added in v1.1.3

func ValidateVersion(version string, versionList []string) (string, error)

Validate OpenShift versions

Types

type AddOnParam added in v1.1.0

type AddOnParam struct {
	Key string
	Val string
}

type AddOnResource added in v0.1.10

type AddOnResource struct {
	AddOn     *cmv1.AddOn
	AZType    string
	Available bool
}

type Client added in v1.1.0

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

func CreateNewClientOrExit added in v1.1.10

func CreateNewClientOrExit(logger *logrus.Logger, reporter *reporter.Object) *Client

func (*Client) AckVersionGate added in v1.1.8

func (c *Client) AckVersionGate(
	clusterID string,
	gateID string) error

func (*Client) AcknowledgeGate added in v1.1.8

func (c *Client) AcknowledgeGate(versionGates []*cmv1.VersionGate) (err error)

func (*Client) AddHTPasswdUser added in v1.1.12

func (c *Client) AddHTPasswdUser(username, password, clusterID, idpID string) error

func (*Client) CancelUpgrade added in v1.1.0

func (c *Client) CancelUpgrade(clusterID string) (bool, error)

func (*Client) CheckIfAWSAccountExists added in v1.1.7

func (c *Client) CheckIfAWSAccountExists(orgID string, awsAccountID string) (bool, string, string, error)

func (*Client) CheckRoleExists added in v1.1.7

func (c *Client) CheckRoleExists(orgID string, roleName string, awsAccountID string) (bool, string, string, error)

* We should allow only one role per aws account per organization If the user request same ocm role we should let them proceed to ensure they can add admin role if not exists or attach policies or link etc if the user request diff ocm role name we error out

func (*Client) Close added in v1.1.0

func (c *Client) Close() error

func (*Client) CreateCluster added in v1.1.0

func (c *Client) CreateCluster(config Spec) (*cmv1.Cluster, error)

func (*Client) CreateIdentityProvider added in v1.1.0

func (c *Client) CreateIdentityProvider(clusterID string, idp *cmv1.IdentityProvider) (*cmv1.IdentityProvider, error)

func (*Client) CreateIngress added in v1.1.0

func (c *Client) CreateIngress(clusterID string, ingress *cmv1.Ingress) (*cmv1.Ingress, error)

func (*Client) CreateMachinePool added in v1.1.0

func (c *Client) CreateMachinePool(clusterID string, machinePool *cmv1.MachinePool) (*cmv1.MachinePool, error)

func (*Client) CreateUser added in v1.1.0

func (c *Client) CreateUser(clusterID string, group string, user *cmv1.User) (*cmv1.User, error)

func (*Client) DeleteCluster added in v1.1.0

func (c *Client) DeleteCluster(clusterKey string, creator *aws.Creator) (*cmv1.Cluster, error)

func (*Client) DeleteHTPasswdUser added in v1.1.12

func (c *Client) DeleteHTPasswdUser(username, clusterID string, htpasswdIDP *cmv1.IdentityProvider) error

func (*Client) DeleteIdentityProvider added in v1.1.0

func (c *Client) DeleteIdentityProvider(clusterID string, idpID string) error

func (*Client) DeleteIngress added in v1.1.0

func (c *Client) DeleteIngress(clusterID string, ingressID string) error

func (*Client) DeleteMachinePool added in v1.1.0

func (c *Client) DeleteMachinePool(clusterID string, machinePoolID string) error

func (*Client) DeleteUser added in v1.1.0

func (c *Client) DeleteUser(clusterID string, group string, username string) error

func (*Client) GetAccountLinkedUserRoles added in v1.1.10

func (c *Client) GetAccountLinkedUserRoles(accountID string) ([]string, error)

func (*Client) GetAddOn added in v1.1.0

func (c *Client) GetAddOn(id string) (*cmv1.AddOn, error)

func (*Client) GetAddOnInstallation added in v1.1.0

func (c *Client) GetAddOnInstallation(clusterKey string, creator *aws.Creator,
	addOnID string) (*cmv1.AddOnInstallation, error)

func (*Client) GetAddOnParameters added in v1.1.0

func (c *Client) GetAddOnParameters(clusterID string, addOnID string) (*cmv1.AddOnParameterList, error)

func (*Client) GetAllClusters added in v1.1.5

func (c *Client) GetAllClusters(creator *aws.Creator) (clusters []*cmv1.Cluster, err error)

func (*Client) GetAvailableAddOns added in v1.1.0

func (c *Client) GetAvailableAddOns() ([]*AddOnResource, error)

Get complete list of available add-ons for the current organization

func (*Client) GetAvailableMachineTypes added in v1.1.0

func (c *Client) GetAvailableMachineTypes() (MachineTypeList, error)

func (*Client) GetAvailableUpgrades added in v1.1.0

func (c *Client) GetAvailableUpgrades(versionID string) ([]string, error)

func (*Client) GetCluster added in v1.1.0

func (c *Client) GetCluster(clusterKey string, creator *aws.Creator) (*cmv1.Cluster, error)

func (*Client) GetClusterAddOns added in v1.1.0

func (c *Client) GetClusterAddOns(cluster *cmv1.Cluster) ([]*ClusterAddOn, error)

Get all add-ons available for a cluster

func (*Client) GetClusterByID added in v1.1.5

func (c *Client) GetClusterByID(clusterKey string, creator *aws.Creator) (*cmv1.Cluster, error)

func (*Client) GetClusterState added in v1.1.0

func (c *Client) GetClusterState(clusterID string) (cmv1.ClusterState, error)

func (*Client) GetClusterStatus added in v1.1.0

func (c *Client) GetClusterStatus(clusterID string) (*cmv1.ClusterStatus, error)

func (*Client) GetClusterUsingSubscription added in v1.1.6

func (c *Client) GetClusterUsingSubscription(clusterKey string, creator *aws.Creator) (*amv1.Subscription, error)

func (*Client) GetClusters added in v1.1.0

func (c *Client) GetClusters(creator *aws.Creator, count int) (clusters []*cmv1.Cluster, err error)

* pass 0 to get all clusters

func (*Client) GetConnectionTokens added in v1.1.0

func (c *Client) GetConnectionTokens() (string, string, error)

func (*Client) GetConnectionURL added in v1.1.0

func (c *Client) GetConnectionURL() string

func (*Client) GetCurrentAccount added in v1.1.0

func (c *Client) GetCurrentAccount() (*amsv1.Account, error)

func (*Client) GetCurrentOrganization added in v1.1.0

func (c *Client) GetCurrentOrganization() (id string, externalID string, err error)

func (*Client) GetDefaultClusterFlavors added in v1.1.0

func (c *Client) GetDefaultClusterFlavors(flavour string) (dMachinecidr *net.IPNet, dPodcidr *net.IPNet,
	dServicecidr *net.IPNet, dhostPrefix int)

func (*Client) GetHTPasswdUserList added in v1.1.12

func (c *Client) GetHTPasswdUserList(clusterID, htpasswdIDPId string) (*cmv1.HTPasswdUserList, error)

func (*Client) GetIdentityProviders added in v1.1.0

func (c *Client) GetIdentityProviders(clusterID string) ([]*cmv1.IdentityProvider, error)

func (*Client) GetIngresses added in v1.1.0

func (c *Client) GetIngresses(clusterID string) ([]*cmv1.Ingress, error)

func (*Client) GetInstallLogs added in v1.1.0

func (c *Client) GetInstallLogs(clusterID string, tail int) (logs *cmv1.Log, err error)

func (*Client) GetMachinePools added in v1.1.0

func (c *Client) GetMachinePools(clusterID string) ([]*cmv1.MachinePool, error)

func (*Client) GetMachineTypes added in v1.1.0

func (c *Client) GetMachineTypes() (machineTypes MachineTypeList, err error)

func (*Client) GetMissingGateAgreements added in v1.1.8

func (c *Client) GetMissingGateAgreements(
	clusterID string,
	upgradePolicy *cmv1.UpgradePolicy) ([]*cmv1.VersionGate, error)

func (*Client) GetOrganizationLinkedOCMRoles added in v1.1.10

func (c *Client) GetOrganizationLinkedOCMRoles(orgID string) ([]string, error)

func (*Client) GetPendingClusterForARN added in v1.1.0

func (c *Client) GetPendingClusterForARN(creator *aws.Creator) (cluster *cmv1.Cluster, err error)

Gets only pending non-STS clusters that are installed in the same AWS account

func (*Client) GetRegionList added in v1.1.0

func (c *Client) GetRegionList(multiAZ bool, roleARN string,
	externalID string) (regionList []string, regionAZ map[string]bool, err error)

func (*Client) GetRegions added in v1.1.0

func (c *Client) GetRegions(roleARN string, externalID string) (regions []*cmv1.CloudRegion, err error)

func (*Client) GetScheduledUpgrade added in v1.1.0

func (c *Client) GetScheduledUpgrade(clusterID string) (*cmv1.UpgradePolicy, *cmv1.UpgradePolicyState, error)

func (*Client) GetUninstallLogs added in v1.1.0

func (c *Client) GetUninstallLogs(clusterID string, tail int) (logs *cmv1.Log, err error)

func (*Client) GetUpgradePolicies added in v1.1.0

func (c *Client) GetUpgradePolicies(clusterID string) (upgradePolicies []*cmv1.UpgradePolicy, err error)

func (*Client) GetUser added in v1.1.0

func (c *Client) GetUser(clusterID string, group string, username string) (*cmv1.User, error)

func (*Client) GetUsers added in v1.1.0

func (c *Client) GetUsers(clusterID string, group string) ([]*cmv1.User, error)

func (*Client) GetVersions added in v1.1.0

func (c *Client) GetVersions(channelGroup string) (versions []*cmv1.Version, err error)

func (*Client) HasClusters added in v1.1.0

func (c *Client) HasClusters(creator *aws.Creator) (bool, error)

func (*Client) HibernateCluster added in v1.1.0

func (c *Client) HibernateCluster(clusterID string) error

func (*Client) InstallAddOn added in v1.1.0

func (c *Client) InstallAddOn(clusterKey string, creator *aws.Creator, addOnID string,
	params []AddOnParam) error

func (*Client) IsCapabilityEnabled added in v1.1.0

func (c *Client) IsCapabilityEnabled(capabilityName string, orgID string) (bool, error)

func (*Client) IsHibernateCapabilityEnabled added in v1.1.0

func (c *Client) IsHibernateCapabilityEnabled() error

func (*Client) IsSTSClusterExists added in v1.1.5

func (c *Client) IsSTSClusterExists(creator *aws.Creator, count int, roleARN string) (exists bool, err error)

func (*Client) LinkAccountRole added in v1.1.6

func (c *Client) LinkAccountRole(accountID string, roleARN string) error

func (*Client) LinkOrgToRole added in v1.1.6

func (c *Client) LinkOrgToRole(orgID string, roleARN string) (bool, error)

func (*Client) ListAllOcpGates added in v1.1.8

func (c *Client) ListAllOcpGates(version string) (versionGates []*cmv1.VersionGate, err error)

func (*Client) ListOcpGates added in v1.1.8

func (c *Client) ListOcpGates(version string) (stsVersionGates []*cmv1.VersionGate, err error)

func (*Client) ListStsGates added in v1.1.8

func (c *Client) ListStsGates(version string) (stsVersionGates []*cmv1.VersionGate, err error)

func (*Client) LogEvent added in v1.1.0

func (c *Client) LogEvent(key string, body map[string]string)

func (*Client) PollInstallLogs added in v1.1.0

func (c *Client) PollInstallLogs(clusterID string, cb func(*cmv1.LogGetResponse) bool) (logs *cmv1.Log, err error)

func (*Client) PollUninstallLogs added in v1.1.0

func (c *Client) PollUninstallLogs(clusterID string,
	cb func(*cmv1.LogGetResponse) bool) (logs *cmv1.Log, err error)

func (*Client) ResumeCluster added in v1.1.0

func (c *Client) ResumeCluster(clusterID string) error

func (*Client) ScheduleUpgrade added in v1.1.0

func (c *Client) ScheduleUpgrade(clusterID string, upgradePolicy *cmv1.UpgradePolicy) error

func (*Client) UninstallAddOn added in v1.1.0

func (c *Client) UninstallAddOn(clusterKey string, creator *aws.Creator, addOnID string) error

func (*Client) UnlinkOCMRoleFromOrg added in v1.1.10

func (c *Client) UnlinkOCMRoleFromOrg(orgID string, roleARN string) error

func (*Client) UnlinkUserRoleFromAccount added in v1.1.10

func (c *Client) UnlinkUserRoleFromAccount(accountID string, roleARN string) error

func (*Client) UpdateAddOnInstallation added in v1.1.0

func (c *Client) UpdateAddOnInstallation(clusterKey string, creator *aws.Creator, addOnID string,
	params []AddOnParam) error

func (*Client) UpdateCluster added in v1.1.0

func (c *Client) UpdateCluster(clusterKey string, creator *aws.Creator, config Spec) error

func (*Client) UpdateIngress added in v1.1.0

func (c *Client) UpdateIngress(clusterID string, ingress *cmv1.Ingress) (*cmv1.Ingress, error)

func (*Client) UpdateMachinePool added in v1.1.0

func (c *Client) UpdateMachinePool(clusterID string, machinePool *cmv1.MachinePool) (*cmv1.MachinePool, error)

type ClientBuilder added in v1.1.0

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

ClientBuilder contains the information and logic needed to build a connection to OCM. Don't create instances of this type directly; use the NewClient function instead.

func NewClient added in v1.1.0

func NewClient() *ClientBuilder

NewClient creates a builder that can then be used to configure and build an OCM connection.

func (*ClientBuilder) Build added in v1.1.0

func (b *ClientBuilder) Build() (result *Client, err error)

Build uses the information stored in the builder to create a new OCM connection.

func (*ClientBuilder) Config added in v1.1.0

func (b *ClientBuilder) Config(value *Config) *ClientBuilder

Config sets the configuration that the connection will use to authenticate the user

func (*ClientBuilder) Logger added in v1.1.0

func (b *ClientBuilder) Logger(value *logrus.Logger) *ClientBuilder

Logger sets the logger that the connection will use to send messages to the log. This is mandatory.

type ClusterAddOn

type ClusterAddOn struct {
	ID    string
	Name  string
	State string
}

type Config added in v1.1.0

type Config struct {
	AccessToken  string   `json:"access_token,omitempty"`
	ClientID     string   `json:"client_id,omitempty"`
	ClientSecret string   `json:"client_secret,omitempty"`
	Insecure     bool     `json:"insecure,omitempty"`
	RefreshToken string   `json:"refresh_token,omitempty"`
	Scopes       []string `json:"scopes,omitempty"`
	TokenURL     string   `json:"token_url,omitempty"`
	URL          string   `json:"url,omitempty"`
}

Config is the type used to store the configuration of the client.

func Load added in v1.1.0

func Load() (cfg *Config, err error)

Load loads the configuration from the configuration file. If the configuration file doesn't exist it will return an empty configuration object.

func (*Config) Armed added in v1.1.0

func (c *Config) Armed() (armed bool, err error)

Armed checks if the configuration contains either credentials or tokens that haven't expired, so that it can be used to perform authenticated requests.

func (*Config) Connection added in v1.1.0

func (c *Config) Connection() (connection *sdk.Connection, err error)

Connection creates a connection using this configuration.

func (*Config) GetData added in v1.1.0

func (c *Config) GetData(key string) (value string, err error)

type MachineType added in v1.1.0

type MachineType struct {
	MachineType *cmv1.MachineType
	Available   bool
	// contains filtered or unexported fields
}

func (MachineType) HasQuota added in v1.1.10

func (mt MachineType) HasQuota(multiAZ bool) bool

type MachineTypeList added in v1.1.10

type MachineTypeList []*MachineType

A list of MachineTypes with additional information

func (*MachineTypeList) Filter added in v1.1.10

func (mtl *MachineTypeList) Filter(fn func(*MachineType) bool) MachineTypeList

Filter returns a new MachineTypeList with only elements for which fn returned true

func (*MachineTypeList) Find added in v1.1.10

func (mtl *MachineTypeList) Find(id string) *MachineType

Find returns the first MachineType matching the ID

func (*MachineTypeList) GetAvailableIDs added in v1.1.10

func (mtl *MachineTypeList) GetAvailableIDs(multiAZ bool) (machineTypeList []string)

func (*MachineTypeList) IDs added in v1.1.10

func (mtl *MachineTypeList) IDs() []string

IDs extracts list of IDs from a MachineTypeList

func (*MachineTypeList) UpdateAvailableQuota added in v1.1.10

func (mtl *MachineTypeList) UpdateAvailableQuota(quotaCosts *amsv1.QuotaCostList)

func (*MachineTypeList) ValidateMachineType added in v1.1.10

func (mtl *MachineTypeList) ValidateMachineType(machineType string, multiAZ bool) error

Validate AWS machine type is available with enough quota in the list

type OperatorIAMRole added in v1.1.0

type OperatorIAMRole struct {
	Name      string
	Namespace string
	RoleARN   string
}

type Spec added in v1.1.0

type Spec struct {
	// Basic configs
	Name                      string
	Region                    string
	MultiAZ                   bool
	Version                   string
	ChannelGroup              string
	Expiration                time.Time
	Flavour                   string
	DisableWorkloadMonitoring *bool

	//Encryption
	FIPS           bool
	EtcdEncryption bool
	KMSKeyArn      string
	// Scaling config
	ComputeMachineType string
	ComputeNodes       int
	Autoscaling        bool
	MinReplicas        int
	MaxReplicas        int

	// SubnetIDs
	SubnetIds []string

	// AvailabilityZones
	AvailabilityZones []string

	// Network config
	NetworkType string
	MachineCIDR net.IPNet
	ServiceCIDR net.IPNet
	PodCIDR     net.IPNet
	HostPrefix  int
	Private     *bool
	PrivateLink *bool

	// Properties
	CustomProperties map[string]string

	// User-defined tags for AWS resources
	Tags map[string]string

	// Simulate creating a cluster but don't actually create it
	DryRun *bool

	// Disable SCP checks in the installer by setting credentials mode as mint
	DisableSCPChecks *bool

	// STS
	IsSTS               bool
	RoleARN             string
	ExternalID          string
	SupportRoleARN      string
	OperatorIAMRoles    []OperatorIAMRole
	ControlPlaneRoleARN string
	WorkerRoleARN       string
	Mode                string

	NodeDrainGracePeriodInMinutes float64

	EnableProxy               bool
	HTTPProxy                 *string
	HTTPSProxy                *string
	AdditionalTrustBundleFile *string
	AdditionalTrustBundle     *string
}

Spec is the configuration for a cluster spec.

Jump to

Keyboard shortcuts

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