utils

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 37 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HypershiftClusterTypeLabel = "ext-hypershift.openshift.io/cluster-type"
	DynatraceTenantKeyLabel    = "dynatrace.regional-tenant"
)
View Source
const (
	JiraHandoverAnnouncementProjectName = "SRE Platform HandOver Announcements"
	JiraBaseURL                         = "https://issues.redhat.com"
	ProductCustomField                  = "customfield_12319040"
	CustomerNameCustomField             = "customfield_12310160"
	ClusterIDCustomField                = "customfield_12316349"
)
View Source
const (
	VersionAPIEndpoint     = "https://api.github.com/repos/openshift/osdctl/releases/latest"
	VersionAddressTemplate = "https://github.com/openshift/osdctl/releases/download/v%s/osdctl_%s_%s_%s.tar.gz" // version, version, GOOS, GOARCH
)
View Source
const ClusterServiceClusterSearch = "id = '%s' or name = '%s' or external_id = '%s'"
View Source
const (
	JiraTokenConfigKey = "jira_token"
)

Variables

View Source
var (
	// GitCommit is the short git commit hash from the environment
	// Will be set during build process via GoReleaser
	// See also: https://pkg.go.dev/cmd/link
	GitCommit string

	// Version is the tag version from the environment
	// Will be set during build process via GoReleaser
	// See also: https://pkg.go.dev/cmd/link
	Version string
)
View Source
var NewJiraClient = func(jiraToken string) (JiraClientInterface, error) {
	return getJiraClient(jiraToken)
}

Factory function

View Source
var ReadBuildInfo = debug.ReadBuildInfo

Functions

func ApplyFilters added in v0.9.6

func ApplyFilters(ocmClient *sdk.Connection, filters []string) ([]*cmv1.Cluster, error)

ApplyFilters retrieves clusters in OCM which match the filters given

func ConfirmPrompt added in v0.17.0

func ConfirmPrompt() bool

func CreateConnection added in v0.9.6

func CreateConnection() (*sdk.Connection, error)

Creates a connection to OCM

func CreateConnectionWithUrl added in v0.52.0

func CreateConnectionWithUrl(OcmUrl string) (*sdk.Connection, error)

Creates a connection to OCM

func CreateIssue added in v0.20.0

func CreateIssue(
	client JiraClientInterface,
	summary, description, ticketType, project string,
	reporter, assignee *jira.User,
	labels []string,
) (*jira.Issue, error)

func FindRouteTableForSubnet added in v0.32.0

func FindRouteTableForSubnet(awsClient aws.Client, subnetID string) (string, error)

func FindRouteTableForSubnetForVerification added in v0.32.0

func FindRouteTableForSubnetForVerification(verificationAwsClient verificationAWSClient, subnetID string) (string, error)

func GenerateQuery added in v0.9.6

func GenerateQuery(clusterIdentifier string) string

GenerateQuery returns an OCM search query to retrieve all clusters matching an expression (ie- "foo%")

func GetAWSAccountIdForCluster added in v0.13.0

func GetAWSAccountIdForCluster(ocmClient *sdk.Connection, clusterID string) (string, error)

func GetAccount added in v0.12.0

func GetAccount(connection *sdk.Connection, key string) (account *amv1.Account, err error)

GetAccount Function allows to get a single account with any identifier (username, ID)

func GetCluster added in v0.9.6

func GetCluster(connection *sdk.Connection, key string) (cluster *cmv1.Cluster, err error)

GetCluster Function allows to get a single cluster with any identifier (displayname, ID, or external ID)

func GetClusterAnyStatus added in v0.13.5

func GetClusterAnyStatus(conn *sdk.Connection, clusterId string) (*cmv1.Cluster, error)

GetClusterAnyStatus returns an OCM cluster object given an OCM connection and cluster id (internal id, external id, and name all supported).

func GetClusterLimitedSupportReasons added in v0.9.6

func GetClusterLimitedSupportReasons(connection *sdk.Connection, clusterID string) ([]*cmv1.LimitedSupportReason, error)

func GetClusters added in v0.9.6

func GetClusters(ocmClient *sdk.Connection, clusterIds []string) []*cmv1.Cluster

func GetCurrentOCMEnv added in v0.13.0

func GetCurrentOCMEnv(connection *sdk.Connection) string

func GetDependencyVersion added in v0.33.0

func GetDependencyVersion(dependencyPath string) (string, error)

func GetDynatraceURLFromLabel added in v0.37.0

func GetDynatraceURLFromLabel(clusterID string) (url string, err error)

func GetHCPNamespace added in v0.37.0

func GetHCPNamespace(clusterId string) (namespace string, err error)

func GetHiveBPClientForCluster added in v0.52.0

func GetHiveBPClientForCluster(clusterID string, options client.Options, elevationReason string, hiveOCMURL string) (client.Client, error)

func GetHiveCluster added in v0.17.0

func GetHiveCluster(clusterId string) (*cmv1.Cluster, error)

func GetHiveClusterWithConn added in v0.52.0

func GetHiveClusterWithConn(clusterId string, clusterOCM *sdk.Connection, hiveOCM *sdk.Connection) (*cmv1.Cluster, error)

Fetch Hive Cluster with provided OCM connections. In the case that the target cluster(stage, integration, etc does not reside in the same OCM env as Hive (prod), separate OCM SDK connections can be provided for accessing each. If nil is provided a temporary connection using the default OCM env vars will be made.

func GetHiveShard added in v0.13.0

func GetHiveShard(clusterID string) (string, error)

Returns the hive shard corresponding to a cluster e.g. https://api.<hive_cluster>.byo5.p1.openshiftapps.com:6443

func GetHiveShardWithConn added in v0.52.0

func GetHiveShardWithConn(clusterID string, conn *sdk.Connection) (string, error)

Returns the hive shard corresponding to a cluster using provided OCM connection e.g. https://api.<hive_cluster>.byo5.p1.openshiftapps.com:6443

func GetInternalClusterID added in v0.49.0

func GetInternalClusterID(ocmClient *sdk.Connection, clusterIdentifier string) (string, error)

func GetJiraIssuesForCluster added in v0.18.0

func GetJiraIssuesForCluster(clusterID, externalClusterID, jiratoken string) ([]jira.Issue, error)

func GetJiraIssuesForClusterWithClient added in v0.45.0

func GetJiraIssuesForClusterWithClient(jiraClient JiraClientInterface, clusterID, externalClusterID string) ([]jira.Issue, error)

func GetJiraSupportExceptionsForOrg added in v0.18.0

func GetJiraSupportExceptionsForOrg(organizationID, jiratoken string) ([]jira.Issue, error)

func GetLatestVersion added in v0.13.5

func GetLatestVersion() (latest string, err error)

getLatestVersion connects to the GitHub API and returns the latest osdctl tag name Interesting Note: GitHub only shows the latest "stable" tag. This means, that tags with a suffix like *-rc.1 are not returned. We will always show the latest stable on master branch.

func GetManagementCluster added in v0.20.0

func GetManagementCluster(clusterId string) (*cmv1.Cluster, error)

GetManagementCluster returns the OCM Cluster object for a provided clusterId

func GetMigration added in v0.47.1

func GetMigration(connection *sdk.Connection, clusterID string) (*cmv1.ClusterMigration, error)

GetMigration function gets the migration info for a cluster

func GetOCMConfigFromEnv added in v0.52.0

func GetOCMConfigFromEnv() (*ocmConfig.Config, error)

Exported function fetch and return OCM config

func GetOCMSdkConnBuilderFromConfig added in v0.52.0

func GetOCMSdkConnBuilderFromConfig(ocmCfg *ocmConfig.Config) (*sdk.ConnectionBuilder, error)

func GetOCMSdkConnBuilderFromFilePath added in v0.52.0

func GetOCMSdkConnBuilderFromFilePath(configFilePath string) (*sdk.ConnectionBuilder, error)

Returns an ocmSdkConnBuilder with initial values read from provided configFilePath.

func GetOCMSdkConnFromFilePath added in v0.52.0

func GetOCMSdkConnFromFilePath(configFilePath string) (*sdk.Connection, error)

Returns an OCM SDK connection using values read from provided configFilePath.

func GetOcmConfigFromFilePath added in v0.52.0

func GetOcmConfigFromFilePath(filePath string) (*ocmConfig.Config, error)

Creates an OCM Config object from values read at provided filePath utils has a local 'copy' of the config struct rather than vendor from "github.com/openshift-online/ocm-cli/pkg/config"

func GetOrganization added in v0.21.0

func GetOrganization(connection *sdk.Connection, key string) (*amv1.Organization, error)

GetOrganization returns an *amv1.Organization given an OCM cluster name, external id, or internal id as key

func GetOrgfromClusterID added in v0.13.7

func GetOrgfromClusterID(ocmClient *sdk.Connection, cluster cmv1.Cluster) (string, error)

func GetRegistryCredentials added in v0.18.0

func GetRegistryCredentials(connection *sdk.Connection, accountId string) ([]*amv1.RegistryCredential, error)

func GetRelatedHandoverAnnouncements added in v0.45.0

func GetRelatedHandoverAnnouncements(clusterID, externalClusterID, jiraToken, orgName, product string, isHCP bool, version string) ([]jira.Issue, error)

func GetServiceCluster added in v0.39.0

func GetServiceCluster(clusterId string) (*cmv1.Cluster, error)

GetServiceCluster returns the hypershift Service Cluster object for a provided HCP clusterId

func GetSubFromClusterID added in v0.44.2

func GetSubFromClusterID(ocmClient *sdk.Connection, cluster cmv1.Cluster) (*amsv1.Subscription, error)

func GetSubscription added in v0.12.0

func GetSubscription(connection *sdk.Connection, key string) (subscription *amv1.Subscription, err error)

GetSubscription Function allows to get a single subscription with any identifier (displayname, ID, internal or external ID)

func GetSupportRoleArnForCluster added in v0.13.0

func GetSupportRoleArnForCluster(ocmClient *sdk.Connection, clusterID string) (string, error)

func IsClusterCCS added in v0.13.0

func IsClusterCCS(ocmClient *sdk.Connection, clusterID string) (bool, error)

func IsHostedCluster added in v0.39.0

func IsHostedCluster(clusterID string) (bool, error)

func IsManagementCluster added in v0.37.0

func IsManagementCluster(clusterID string) (isMC bool, err error)

Sanity Check for MC Cluster

func IsValidClusterKey added in v0.11.0

func IsValidClusterKey(clusterKey string) (err error)

func IsValidKey added in v0.11.0

func IsValidKey(clusterKey string) bool

func PrintClusterReports added in v0.49.0

func PrintClusterReports(reports *backplaneapi.ListReports)

func PrintHandoverAnnouncements added in v0.45.0

func PrintHandoverAnnouncements(issues []jira.Issue)

func PrintJiraIssues added in v0.18.0

func PrintJiraIssues(issues []jira.Issue)

func PrintLimitedSupportReasons added in v0.18.0

func PrintLimitedSupportReasons(limitedSupportReasons []*cmv1.LimitedSupportReason)

func PrintPDAlerts added in v0.18.0

func PrintPDAlerts(incidents map[string][]pd.Incident, serviceIDs []string)

func PrintServiceLogs added in v0.18.0

func PrintServiceLogs(serviceLogs []*v1.LogEntry, verbose bool, sinceDays int)

func SendRequest added in v0.18.0

func SendRequest(request *sdk.Request) (*sdk.Response, error)

func StreamErrorln added in v0.13.0

func StreamErrorln(stream genericclioptions.IOStreams, msg string)

StreamErrorln prints the given error msg using the provided IOStreams

func StreamPrint added in v0.13.0

func StreamPrint(stream genericclioptions.IOStreams, msg string)

StreamPrint prints the given msg using the provided IOStreams

func StreamPrintln added in v0.13.0

func StreamPrintln(stream genericclioptions.IOStreams, msg string)

StreamPrintln appends a newline then prints the given msg using the provided IOStreams

func StreamRead added in v0.13.0

func StreamRead(stream genericclioptions.IOStreams, delim byte) (string, error)

StreamRead retrieves input from the provided IOStreams up to (and including) the delimiter given

Types

type DelayTracker added in v0.32.0

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

func StartDelayTracker added in v0.32.0

func StartDelayTracker(verbose bool, action string) *DelayTracker

func (*DelayTracker) End added in v0.32.0

func (dt *DelayTracker) End()

type JiraClientInterface added in v0.45.0

type JiraClientInterface interface {
	SearchIssues(jql string) ([]jira.Issue, error)
	CreateIssue(issue *jira.Issue) (*jira.Issue, error)
	CreateVersion(version *jira.Version) (*jira.Version, error)
	User() *jira.UserService
	Issue() *jira.IssueService
	Board() *jira.BoardService
	Sprint() *jira.SprintService
}

JiraClientInterface defines the methods we use from go-jira

Directories

Path Synopsis
Package utils is a generated GoMock package.
Package utils is a generated GoMock package.

Jump to

Keyboard shortcuts

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