operatemodule

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MsgOK    = color.New(color.FgGreen).Sprint("[OK]")
	MsgWarn  = color.New(color.FgYellow).Sprint("[WARN]")
	MsgError = color.New(color.FgRed).Sprint("[ERROR]")
)

Output message prefixes with colors for better status readability.

Functions

func ApplyNowModuleRelease added in v0.25.0

func ApplyNowModuleRelease(dynamicClient dynamic.Interface, releaseName string) error

ApplyNowModuleRelease adds the apply-now annotation to a module release.

func ApproveModuleRelease added in v0.25.0

func ApproveModuleRelease(dynamicClient dynamic.Interface, releaseName string) error

ApproveModuleRelease adds the approved annotation to a module release.

func CanBeAppliedNow added in v0.25.0

func CanBeAppliedNow(r ModuleReleaseInfo) bool

CanBeAppliedNow returns true for pending releases without apply-now annotation. Used by the apply-now command to filter releases available for immediate deployment.

func CanBeApproved added in v0.25.0

func CanBeApproved(r ModuleReleaseInfo) bool

CanBeApproved returns true for pending releases that are not yet approved. Used by the approve command to filter releases available for approval.

func CompleteForApplyNow added in v0.25.0

func CompleteForApplyNow(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteForApplyNow provides shell completion for the apply-now command. It suggests pending releases that don't have the apply-now annotation.

func CompleteForApprove added in v0.25.0

func CompleteForApprove(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteForApprove provides shell completion for the approve command. It suggests pending releases that are not yet approved.

func FindVersions added in v0.25.0

func FindVersions(dynamicClient dynamic.Interface, moduleName string, match ReleaseMatchFunc) ([]string, error)

FindVersions returns a sorted list of versions for releases matching the predicate. All versions are normalized to have a "v" prefix for consistent completion.

func GetDynamicClient added in v0.25.0

func GetDynamicClient(cmd *cobra.Command) (dynamic.Interface, error)

GetDynamicClient creates a dynamic Kubernetes client from cobra command flags. It reads "kubeconfig" and "context" flags from the command. Dynamic client is required to work with Custom Resources like ModuleRelease and ModuleConfig, which don't have typed clients in client-go.

func ListModuleNames added in v0.25.0

func ListModuleNames(dynamicClient dynamic.Interface) ([]string, error)

ListModuleNames returns a sorted list of unique module names from all releases.

func NormalizeVersion added in v0.25.0

func NormalizeVersion(version string) string

NormalizeVersion ensures the version has a 'v' prefix.

func OperateModule

func OperateModule(dynamicClient dynamic.Interface, name string, moduleState ModuleState) error

func OptionsModule

func OptionsModule(config *rest.Config, kubeCl kubernetes.Interface, pathFromOption string) error

func PrintNearestVersionSuggestions added in v0.25.0

func PrintNearestVersionSuggestions(releases []ModuleReleaseInfo, targetVersion string)

PrintNearestVersionSuggestions prints suggestions for nearest versions.

func PrintNoReleasesHelp added in v0.25.0

func PrintNoReleasesHelp(dynamicClient dynamic.Interface, moduleName string)

PrintNoReleasesHelp prints help when no pending releases are found.

func PrintPendingReleases added in v0.25.0

func PrintPendingReleases(releases []ModuleReleaseInfo)

PrintPendingReleases prints a list of available pending releases.

func PrintSimilarModules added in v0.25.0

func PrintSimilarModules(dynamicClient dynamic.Interface, moduleName string)

PrintSimilarModules prints modules with similar names to help with typos.

func ReleaseNotFoundError added in v0.25.0

func ReleaseNotFoundError(moduleName, version string) error

ReleaseNotFoundError returns a formatted error for a missing release.

func SortReleasesByVersion added in v0.25.0

func SortReleasesByVersion(releases []ModuleReleaseInfo)

SortReleasesByVersion sorts releases by semantic version in ascending order. Falls back to lexicographic comparison if version parsing fails.

func SuggestSuitableReleasesOnNotFound added in v0.25.0

func SuggestSuitableReleasesOnNotFound(dynamicClient dynamic.Interface, moduleName, version string, match ReleaseMatchFunc) error

SuggestSuitableReleasesOnNotFound prints helpful suggestions when a release is not found. It can suggest releases that are available for the given match predicate.

For example, all the releases that are in Pending phase and not yet approved. You can select any rule with the ReleaseMatchFunc predicate.

Types

type ModuleReleaseInfo added in v0.25.0

type ModuleReleaseInfo struct {
	Name       string
	ModuleName string
	Version    string
	Phase      string
	Message    string
	IsApproved bool
	IsApplyNow bool
}

ModuleReleaseInfo contains information about a module release. This is a simplified DTO for use in CLI commands.

func FindReleases added in v0.25.0

func FindReleases(dynamicClient dynamic.Interface, moduleName string, match ReleaseMatchFunc) ([]ModuleReleaseInfo, error)

FindReleases returns releases matching the given predicate, sorted by version. It's simply a filtered version of ListModuleReleases (convenience function).

func GetModuleRelease added in v0.25.0

func GetModuleRelease(dynamicClient dynamic.Interface, moduleName, version string) (*ModuleReleaseInfo, error)

GetModuleRelease returns a specific module release by module name and version.

func ListModuleReleases added in v0.25.0

func ListModuleReleases(dynamicClient dynamic.Interface, moduleName string) ([]ModuleReleaseInfo, error)

ListModuleReleases returns all module releases for a given module name. If moduleName is empty, returns all releases.

type ModuleState

type ModuleState string
const (
	ModuleEnabled  ModuleState = "enabled"
	ModuleDisabled ModuleState = "disabled"
)

type NearestVersions added in v0.25.0

type NearestVersions struct {
	Lower *ModuleReleaseInfo // closest version below target, nil if none exists
	Upper *ModuleReleaseInfo // closest version above target, nil if none exists
}

NearestVersions contains the closest versions below and above a target version.

func FindNearestVersions added in v0.25.0

func FindNearestVersions(releases []ModuleReleaseInfo, targetVersion string) NearestVersions

FindNearestVersions finds the closest versions below and above the target version.

type ReleaseMatchFunc added in v0.25.0

type ReleaseMatchFunc func(r ModuleReleaseInfo) bool

ReleaseMatchFunc is a predicate function for filtering releases. Returns true if the release should be included in the result.

Jump to

Keyboard shortcuts

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