Documentation
¶
Index ¶
- Constants
- func CheckHealth(url string) bool
- func GetClusterIDAndHostFromClusterURL(clusterURL string) (string, string, error)
- func GetFormattedError(rsp *http.Response) error
- func GetFreePort() (int, error)
- func MatchBaseDomain(longHostname, baseDomain string) bool
- func ParseParamsFlag(paramsFlag []string) (map[string]string, error)
- func ReadKubeconfigRaw() (api.Config, error)
- func RenderJson(reader io.Reader) error
- func RenderJsonBytes(i interface{}) error
- func RenderTabbedTable(headers []string, data [][]string)
- func RenderTable(headers []string, data [][]string)
- func TryParseBackplaneAPIError(rsp *http.Response) (*BackplaneApi.Error, error)
- func TryPrintAPIError(rsp *http.Response, rawFlag bool) error
- func TryRenderErrorRaw(rsp *http.Response) error
- type BackplaneCluster
- type BackplaneConfiguration
- type ClientUtils
- type DefaultClientUtilsImpl
- func (s *DefaultClientUtilsImpl) GetBackplaneClient(backplaneURL string) (client BackplaneApi.ClientInterface, err error)
- func (s *DefaultClientUtilsImpl) MakeBackplaneAPIClient(base string) (BackplaneApi.ClientWithResponsesInterface, error)
- func (_ *DefaultClientUtilsImpl) MakeBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientWithResponsesInterface, error)
- func (s *DefaultClientUtilsImpl) MakeRawBackplaneAPIClient(base string) (BackplaneApi.ClientInterface, error)
- func (_ *DefaultClientUtilsImpl) MakeRawBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientInterface, error)
- type DefaultOCMInterfaceImpl
- func (*DefaultOCMInterfaceImpl) GetBackplaneURL() (string, error)
- func (*DefaultOCMInterfaceImpl) GetClusterInfoByID(clusterId string) (*cmv1.Cluster, error)
- func (*DefaultOCMInterfaceImpl) GetOCMAccessToken() (*string, error)
- func (*DefaultOCMInterfaceImpl) GetTargetCluster(clusterKey string) (clusterId, clusterName string, err error)
- func (*DefaultOCMInterfaceImpl) IsClusterHibernating(clusterId string) (bool, error)
- func (*DefaultOCMInterfaceImpl) IsProduction() (bool, error)
- type OCMInterface
Constants ¶
const ( ClustersPageSize = 50 ClusterIDRegexp string = "/?backplane/cluster/([a-zA-Z0-9]+)/?" )
Variables ¶
This section is empty.
Functions ¶
func CheckHealth ¶
CheckHealth check if the given url returns http status 200 return false if it not 200 or encounter any error.
func GetClusterIDAndHostFromClusterURL ¶
Cluster URL format: https://api-backplane.apps.com/backplane/cluster/<cluster-id>/
func GetFormattedError ¶
func GetFreePort ¶
GetFreePort asks the OS for an available port to listen to. https://github.com/phayes/freeport/blob/master/freeport.go
func MatchBaseDomain ¶
MatchBaseDomain returns true if the given longHostname matches the baseDomain.
func ReadKubeconfigRaw ¶
func RenderJson ¶
RenderJson is an effectful function that renders the reader as JSON returns err if render fails
func RenderJsonBytes ¶
func RenderJsonBytes(i interface{}) error
RenderJsonBytes is an effectful function that renders the reader as JSON returns err if render fails
func RenderTabbedTable ¶
This renderer only uses tabs and renders based on terminal width available It keeps the first column in it's full length and truncates others
func RenderTable ¶
func TryParseBackplaneAPIError ¶
func TryParseBackplaneAPIError(rsp *http.Response) (*BackplaneApi.Error, error)
func TryRenderErrorRaw ¶
Types ¶
type BackplaneCluster ¶
type BackplaneCluster struct {
ClusterID string
ClusterURL string // for e.g. https://api-backplane.apps.com/backplane/cluster/<cluster-id>/
BackplaneHost string // for e.g. https://api-backplane.apps.com
}
func GetBackplaneCluster ¶
func GetBackplaneCluster(params ...string) (BackplaneCluster, error)
GetBackplaneCluster returns BackplaneCluster, if clusterKey is present it will try to search for cluster otherwise it will load cluster from the kube config file.
func GetBackplaneClusterFromClusterKey ¶
func GetBackplaneClusterFromClusterKey(clusterKey string) (BackplaneCluster, error)
func GetBackplaneClusterFromConfig ¶
func GetBackplaneClusterFromConfig() (BackplaneCluster, error)
type BackplaneConfiguration ¶ added in v0.1.19
type BackplaneConfiguration struct {
URL string
}
type ClientUtils ¶
type ClientUtils interface {
MakeBackplaneAPIClient(base string) (BackplaneApi.ClientWithResponsesInterface, error)
MakeBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientWithResponsesInterface, error)
MakeRawBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientInterface, error)
MakeRawBackplaneAPIClient(base string) (BackplaneApi.ClientInterface, error)
GetBackplaneClient(backplaneURL string) (client BackplaneApi.ClientInterface, err error)
}
var DefaultClientUtils ClientUtils = &DefaultClientUtilsImpl{}
type DefaultClientUtilsImpl ¶
type DefaultClientUtilsImpl struct{}
func (*DefaultClientUtilsImpl) GetBackplaneClient ¶
func (s *DefaultClientUtilsImpl) GetBackplaneClient(backplaneURL string) (client BackplaneApi.ClientInterface, err error)
getBackplaneClient returns authnicated Backplane API client
func (*DefaultClientUtilsImpl) MakeBackplaneAPIClient ¶
func (s *DefaultClientUtilsImpl) MakeBackplaneAPIClient(base string) (BackplaneApi.ClientWithResponsesInterface, error)
func (*DefaultClientUtilsImpl) MakeBackplaneAPIClientWithAccessToken ¶
func (_ *DefaultClientUtilsImpl) MakeBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientWithResponsesInterface, error)
func (*DefaultClientUtilsImpl) MakeRawBackplaneAPIClient ¶
func (s *DefaultClientUtilsImpl) MakeRawBackplaneAPIClient(base string) (BackplaneApi.ClientInterface, error)
func (*DefaultClientUtilsImpl) MakeRawBackplaneAPIClientWithAccessToken ¶
func (_ *DefaultClientUtilsImpl) MakeRawBackplaneAPIClientWithAccessToken(base, accessToken string) (BackplaneApi.ClientInterface, error)
type DefaultOCMInterfaceImpl ¶
type DefaultOCMInterfaceImpl struct{}
func (*DefaultOCMInterfaceImpl) GetBackplaneURL ¶ added in v0.1.19
func (*DefaultOCMInterfaceImpl) GetBackplaneURL() (string, error)
GetBackplaneURL from local settings
func (*DefaultOCMInterfaceImpl) GetClusterInfoByID ¶
func (*DefaultOCMInterfaceImpl) GetClusterInfoByID(clusterId string) (*cmv1.Cluster, error)
GetClusterInfoByID calls the OCM to retrieve the cluster info for a given internal cluster id.
func (*DefaultOCMInterfaceImpl) GetOCMAccessToken ¶
func (*DefaultOCMInterfaceImpl) GetOCMAccessToken() (*string, error)
func (*DefaultOCMInterfaceImpl) GetTargetCluster ¶
func (*DefaultOCMInterfaceImpl) GetTargetCluster(clusterKey string) (clusterId, clusterName string, err error)
GetTargetCluster returns one single cluster based on the search key and survery.
func (*DefaultOCMInterfaceImpl) IsClusterHibernating ¶
func (*DefaultOCMInterfaceImpl) IsClusterHibernating(clusterId string) (bool, error)
IsClusterHibernating returns a boolean to indicate whether the cluster is hibernating
func (*DefaultOCMInterfaceImpl) IsProduction ¶
func (*DefaultOCMInterfaceImpl) IsProduction() (bool, error)
IsProduction checks if OCM is currently in production env
type OCMInterface ¶
type OCMInterface interface {
IsClusterHibernating(clusterId string) (bool, error)
GetTargetCluster(clusterKey string) (clusterId, clusterName string, err error)
GetOCMAccessToken() (*string, error)
GetClusterInfoByID(clusterId string) (*cmv1.Cluster, error)
GetBackplaneURL() (string, error)
IsProduction() (bool, error)
}
var DefaultOCMInterface OCMInterface = &DefaultOCMInterfaceImpl{}