utils

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CurrentLogLevel is the current logging level
	CurrentLogLevel = LogLevelInfo
	// LogOutput is the output writer for logs
	LogOutput io.Writer = os.Stdout
)

Functions

func CheckHarborLogin

func CheckHarborLogin(registry string) error

CheckHarborLogin checks if the user is logged into Harbor

func LogDebug

func LogDebug(format string, args ...interface{})

LogDebug logs a debug message

func LogError

func LogError(format string, args ...interface{})

LogError logs an error message

func LogFatal

func LogFatal(format string, args ...interface{})

LogFatal logs a fatal error and exits

func LogInfo

func LogInfo(format string, args ...interface{})

LogInfo logs an info message

func LogWarning

func LogWarning(format string, args ...interface{})

LogWarning logs a warning message

func MirrorArtifacts

func MirrorArtifacts(manifest *ArtifactManifest, cacheDir, targetRegistry string, options MirrorOptions) error

MirrorArtifacts pushes selected artifacts from the local cache into a target registry. Currently only container images are supported.

func NewDynactlKeychain

func NewDynactlKeychain() authn.Keychain

NewDynactlKeychain returns an authn.Keychain that prefers Docker credentials but falls back to dynactl's credential store.

func PullArtifacts

func PullArtifacts(manifest *ArtifactManifest, outputDir string, options PullOptions) error

PullArtifacts pulls all artifacts specified in the manifest from Harbor

func PullManifestFromRegistry

func PullManifestFromRegistry(reference, outputDir string) error

PullManifestFromRegistry pulls a manifest artifact into the specified directory using the ORAS Go SDK.

func SaveRegistryCredential

func SaveRegistryCredential(registry string, cred RegistryCredential) error

SaveRegistryCredential stores credentials for a registry in the dynactl credential store.

func SetLogLevel

func SetLogLevel(verbosity int)

SetLogLevel sets the current logging level based on verbosity

Types

type ArtifactManifest

type ArtifactManifest struct {
	CustomerID         string    `json:"customer_id"`
	CustomerName       string    `json:"customer_name"`
	ReleaseVersion     string    `json:"release_version"`
	OnboardingDate     string    `json:"onboarding_date"`
	LicenseGeneratedAt *string   `json:"license_generated_at"`
	LicenseExpiry      *string   `json:"license_expiry"`
	MaxUsers           *int      `json:"max_users"`
	SPOC               SPOC      `json:"spoc"`
	Artifacts          Artifacts `json:"artifacts"`
	Images             []string  `json:"images"` // Array of OCI URIs
	Models             []string  `json:"models"` // Array of OCI URIs
	Charts             []Chart   `json:"charts"`
}

ArtifactManifest represents the structure of the manifest file

func LoadManifest

func LoadManifest(filename string) (*ArtifactManifest, error)

LoadManifest loads and parses the manifest file

type Artifacts

type Artifacts struct {
	ChartsRoot string `json:"charts_root"`
	ImagesRoot string `json:"images_root"`
	ModelsRoot string `json:"models_root"`
}

Artifacts represents the root paths for different artifact types

type Chart

type Chart struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	AppVersion string `json:"appVersion"`
	Filename   string `json:"filename"`
	HarborPath string `json:"harbor_path"`
	SHA256     string `json:"sha256"`
	SizeBytes  int64  `json:"size_bytes"`
}

Chart represents a Helm chart with additional metadata

type Component

type Component struct {
	Name      string
	Type      string
	URI       string
	Tag       string
	Digest    string
	MediaType string
}

Component represents a unified artifact component for processing

type ContainerResourceSummary

type ContainerResourceSummary struct {
	Name           string
	RequestsCPU    string
	RequestsMemory string
	RequestsGPU    string
	LimitsCPU      string
	LimitsMemory   string
	LimitsGPU      string
}

ContainerResourceSummary holds resource info for a container

type DeploymentResourceSummary

type DeploymentResourceSummary struct {
	Name       string
	Pods       int32
	Containers []ContainerResourceSummary
}

DeploymentResourceSummary holds resource info for a deployment

type KubernetesChecker

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

KubernetesChecker handles Kubernetes cluster checks

func NewKubernetesChecker

func NewKubernetesChecker() (*KubernetesChecker, error)

NewKubernetesChecker creates a new Kubernetes checker

func (*KubernetesChecker) CheckClusterRBAC

func (kc *KubernetesChecker) CheckClusterRBAC() (string, error)

CheckClusterRBAC checks cluster-level RBAC permissions using SelfSubjectAccessReview

func (*KubernetesChecker) CheckKubernetesVersion

func (kc *KubernetesChecker) CheckKubernetesVersion() (string, error)

CheckKubernetesVersion returns the Kubernetes cluster server version

func (*KubernetesChecker) CheckNamespaceRBAC

func (kc *KubernetesChecker) CheckNamespaceRBAC(namespace string) (string, error)

CheckNamespaceRBAC checks RBAC permissions in the specified namespace using SelfSubjectAccessReview

func (*KubernetesChecker) CheckResources

func (kc *KubernetesChecker) CheckResources(outputFormat string) (string, error)

CheckResources checks available CPU and memory resources

func (*KubernetesChecker) CheckStorageCapacity

func (kc *KubernetesChecker) CheckStorageCapacity() (string, error)

CheckStorageCapacity checks available storage capacity

func (*KubernetesChecker) CheckStorageClassesCompatibility

func (kc *KubernetesChecker) CheckStorageClassesCompatibility() (string, error)

CheckStorageClassesCompatibility checks StorageClasses for common database compatibility

func (*KubernetesChecker) GetNodeResourceUsage

func (kc *KubernetesChecker) GetNodeResourceUsage(nodeName string) (*NodeResourceUsage, error)

GetNodeResourceUsage calculates resource usage percentages for a specific node

func (*KubernetesChecker) ListDeploymentResourceSummaries

func (kc *KubernetesChecker) ListDeploymentResourceSummaries(namespace string) ([]DeploymentResourceSummary, error)

ListDeploymentResourceSummaries lists deployments and summarizes container resource requests/limits

func (*KubernetesChecker) ListNodeInstanceTypes

func (kc *KubernetesChecker) ListNodeInstanceTypes() (map[string]string, error)

ListNodeInstanceTypes returns a mapping of node name to instance type label

type LogLevel

type LogLevel int

LogLevel represents the logging level

const (
	// LogLevelError represents error level logging
	LogLevelError LogLevel = iota
	// LogLevelWarning represents warning level logging
	LogLevelWarning
	// LogLevelInfo represents info level logging
	LogLevelInfo
	// LogLevelDebug represents debug level logging
	LogLevelDebug
)

func LogLevelFromString

func LogLevelFromString(level string) LogLevel

LogLevelFromString converts a string to a LogLevel

type MirrorOptions

type MirrorOptions struct {
	IncludeImages bool
	IncludeModels bool
	IncludeCharts bool
}

MirrorOptions describes which artifact categories to mirror.

func MirrorOptionsFromPull

func MirrorOptionsFromPull(opts PullOptions) MirrorOptions

MirrorOptionsFromPull converts pull options to mirror options.

func NormalizeMirrorOptions

func NormalizeMirrorOptions(opts MirrorOptions) MirrorOptions

NormalizeMirrorOptions ensures at least one artifact category is included.

type NodeResourceUsage

type NodeResourceUsage struct {
	Name                  string
	CPURequests           float64
	CPULimits             float64
	MemoryRequests        float64
	MemoryLimits          float64
	GPURequests           int64
	GPULimits             int64
	CPUAllocatable        float64
	MemoryAllocatable     float64
	GPUAllocatable        int64
	CPURequestsPercent    float64
	CPULimitsPercent      float64
	MemoryRequestsPercent float64
	MemoryLimitsPercent   float64
}

NodeResourceUsage holds resource usage information for a node

type PullOptions

type PullOptions struct {
	IncludeImages bool
	IncludeModels bool
	IncludeCharts bool
}

PullOptions controls which artifact categories are processed.

func NormalizePullOptions

func NormalizePullOptions(opts PullOptions) PullOptions

NormalizePullOptions enables all artifact categories if none are explicitly selected.

type PullResult

type PullResult struct {
	TotalArtifacts int
	SuccessCount   int
	FailedCount    int
	Duration       time.Duration
	Errors         []string
}

PullResult represents the result of pulling artifacts

type RegistryCredential

type RegistryCredential struct {
	Username      string `json:"username,omitempty"`
	Password      string `json:"password,omitempty"`
	IdentityToken string `json:"identity_token,omitempty"`
	AccessToken   string `json:"access_token,omitempty"`
}

RegistryCredential represents the persisted credential fields for a registry.

func GetRegistryCredential

func GetRegistryCredential(registry string) (RegistryCredential, bool, error)

GetRegistryCredential retrieves a credential from the dynactl credential store.

type SPOC

type SPOC struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

SPOC represents the Single Point of Contact

Jump to

Keyboard shortcuts

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