ocm

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAuthToken added in v1.3.0

func ApplyAuthToken(cfg *ocmconfig.Config, token string)

ApplyAuthToken classifies a raw auth token and sets the appropriate field on the OCM config (RefreshToken or AccessToken).

func AuthenticateAsync added in v1.3.0

func AuthenticateAsync(cfg *ocmconfig.Config) (string, error)

AuthenticateAsync performs browser-based auth code login. This call blocks until the user completes authentication in the browser. Returns the raw auth token string on success.

func CheckTokens added in v1.3.0

func CheckTokens() (*ocmconfig.Config, bool, error)

CheckTokens loads the OCM config and checks if valid tokens exist. Returns the config (with defaults applied), whether tokens are valid, and any error. This is a fast, non-blocking operation.

Types

type Client

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

Client wraps the OCM SDK connection for cluster enrichment.

func NewClient

func NewClient(agentVersion string) (*Client, error)

NewClient creates a real OCM client using the standard config file. Always connects to production OCM. If no valid tokens exist, initiates browser-based auth code login (same flow as ocm-container).

func NewClientFromConfig added in v1.3.0

func NewClientFromConfig(cfg *ocmconfig.Config, agentVersion string) (*Client, error)

NewClientFromConfig builds an OCM client from a pre-loaded config. The config must already have valid tokens set.

func (*Client) Close

func (c *Client) Close()

func (*Client) GetCluster

func (c *Client) GetCluster(ctx context.Context, key string) (*ClusterInfo, error)

func (*Client) GetLimitedSupportHistory

func (c *Client) GetLimitedSupportHistory(ctx context.Context, clusterID string) ([]LimitedSupportReason, error)

func (*Client) GetServiceLogs

func (c *Client) GetServiceLogs(ctx context.Context, clusterID, externalID string) ([]ServiceLog, error)

type ClusterInfo

type ClusterInfo struct {
	ID            string
	ExternalID    string
	Name          string
	DisplayName   string
	State         string
	Region        string
	CloudProvider string
	Version       string
	Hypershift    bool
	CCS           bool
	Organization  string
}

ClusterInfo contains enriched cluster data from the OCM API.

type LimitedSupportReason

type LimitedSupportReason struct {
	ID            string
	Summary       string
	Details       string
	DetectionType string
	CreatedAt     string
}

LimitedSupportReason represents a limited support reason entry.

type MockClient

type MockClient struct {
	Clusters       map[string]*ClusterInfo
	ServiceLogs    map[string][]ServiceLog
	LimitedSupport map[string][]LimitedSupportReason
}

MockClient implements OCMClient for testing and dev mode.

func LoadMockClientFromFixtures

func LoadMockClientFromFixtures(dir string) (*MockClient, error)

LoadMockClientFromFixtures creates a MockClient populated with data from fixture files.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a MockClient with initialized maps.

func (*MockClient) Close

func (m *MockClient) Close()

func (*MockClient) GetCluster

func (m *MockClient) GetCluster(_ context.Context, clusterID string) (*ClusterInfo, error)

func (*MockClient) GetLimitedSupportHistory

func (m *MockClient) GetLimitedSupportHistory(_ context.Context, clusterID string) ([]LimitedSupportReason, error)

func (*MockClient) GetServiceLogs

func (m *MockClient) GetServiceLogs(_ context.Context, clusterID, _ string) ([]ServiceLog, error)

type OCMClient

type OCMClient interface {
	GetCluster(ctx context.Context, clusterID string) (*ClusterInfo, error)
	GetServiceLogs(ctx context.Context, clusterID, externalID string) ([]ServiceLog, error)
	GetLimitedSupportHistory(ctx context.Context, clusterID string) ([]LimitedSupportReason, error)
	Close()
}

OCMClient defines the interface for OCM API operations.

type ServiceLog

type ServiceLog struct {
	Timestamp    string
	Severity     string
	ServiceName  string
	Summary      string
	Description  string
	ClusterID    string
	ClusterUUID  string
	InternalOnly bool
}

ServiceLog represents a single service log entry.

Jump to

Keyboard shortcuts

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