utils

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
const (
	JiraTokenConfigKey = "jira_token"
	JiraBaseURL        = "https://issues.redhat.com"
)
View Source
const (
	HypershiftClusterTypeLabel = "ext-hypershift.openshift.io/cluster-type"
	DynatraceTenantKeyLabel    = "sre-capabilities.dtp.tenant"
)
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'"

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 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)

func CreateIssue added in v0.20.0

func CreateIssue(
	service *jira.IssueService,
	summary string,
	description string,
	ticketType string,
	project string,
	reporter *jira.User,
	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 GetHiveCluster added in v0.17.0

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

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 GetJiraClient added in v0.18.0

func GetJiraClient() (*jira.Client, error)

GetJiraClient creates a jira client that connects to https://issues.redhat.com. To work, the jiraToken needs to be set in the config

func GetJiraIssuesForCluster added in v0.18.0

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

func GetJiraSupportExceptionsForOrg added in v0.18.0

func GetJiraSupportExceptionsForOrg(organizationID 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 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 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 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 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 Config added in v0.14.3

type Config struct {
	AccessToken  string   `json:"access_token,omitempty" doc:"Bearer access token."`
	ClientID     string   `json:"client_id,omitempty" doc:"OpenID client identifier."`
	ClientSecret string   `json:"client_secret,omitempty" doc:"OpenID client secret."`
	Insecure     bool     `` /* 142-byte string literal not displayed */
	Password     string   `json:"password,omitempty" doc:"User password."`
	RefreshToken string   `json:"refresh_token,omitempty" doc:"Offline or refresh token."`
	Scopes       []string `` /* 172-byte string literal not displayed */
	TokenURL     string   `json:"token_url,omitempty" doc:"OpenID token URL."`
	URL          string   `` /* 162-byte string literal not displayed */
	User         string   `json:"user,omitempty" doc:"User name."`
	Pager        string   `json:"pager,omitempty" doc:"Pager command, for example 'less'. If empty no pager will be used."`
}

Config describes the OCM client configuration Taken wholesale from openshift-online/ocm-cli

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()

Jump to

Keyboard shortcuts

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