From cac4e42497d85182351d9a57cd92625ccc1cddf7 Mon Sep 17 00:00:00 2001 From: nicholasSSUSE Date: Fri, 9 Aug 2024 20:40:12 -0300 Subject: [PATCH] changing naming strategy from arguments.go -> chart_management.go --- cmd/release/cmd/update.go | 6 +-- .../{arguments.go => chart_management.go} | 44 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) rename release/charts/{arguments.go => chart_management.go} (83%) diff --git a/cmd/release/cmd/update.go b/cmd/release/cmd/update.go index c4ff2e8d..24f40a92 100644 --- a/cmd/release/cmd/update.go +++ b/cmd/release/cmd/update.go @@ -66,12 +66,12 @@ var updateChartsCmd = &cobra.Command{ chart = args[1] version = args[2] - found = charts.CheckBranchArgs(branch, rootConfig.Charts.BranchLines) + found = charts.IsBranchAvailable(branch, rootConfig.Charts.BranchLines) if !found { return errors.New("branch not available: " + branch) } - found, err = charts.CheckChartArgs(context.Background(), rootConfig.Charts, chart) + found, err = charts.IsChartAvailable(context.Background(), rootConfig.Charts, chart) if err != nil { return err } @@ -79,7 +79,7 @@ var updateChartsCmd = &cobra.Command{ return errors.New("chart not available: " + chart) } - found, err = charts.CheckVersionArgs(context.Background(), rootConfig.Charts, chart, version) + found, err = charts.IsVersionAvailable(context.Background(), rootConfig.Charts, chart, version) if err != nil { return err } diff --git a/release/charts/arguments.go b/release/charts/chart_management.go similarity index 83% rename from release/charts/arguments.go rename to release/charts/chart_management.go index 778abd1f..9a71092c 100644 --- a/release/charts/arguments.go +++ b/release/charts/chart_management.go @@ -19,22 +19,6 @@ type asset struct { Version string `json:"version"` } -// loadState will load the lifecycle-status state from an existing state.json file at charts repo -func loadState(filePath string) (*status, error) { - s := &status{} - - file, err := os.Open(filePath) - if err != nil { - return nil, err - } - - if err := json.NewDecoder(file).Decode(&s); err != nil { - return nil, err - } - - return s, nil -} - // ChartArgs will return the list of available charts in the current branch func ChartArgs(ctx context.Context, c *config.ChartsRelease) ([]string, error) { assets := filepath.Join(c.Workspace, "assets") @@ -82,8 +66,8 @@ func VersionArgs(ctx context.Context, c *config.ChartsRelease, ch string) ([]str return versions, nil } -// CheckBranchArgs will check if the branch line exists -func CheckBranchArgs(branch string, availableBranches []string) bool { +// IsBranchAvailable will check if the branch line exists +func IsBranchAvailable(branch string, availableBranches []string) bool { for _, b := range availableBranches { if b == branch { return true @@ -93,8 +77,8 @@ func CheckBranchArgs(branch string, availableBranches []string) bool { return false } -// CheckChartArgs will check if the chart exists in the available charts -func CheckChartArgs(ctx context.Context, conf *config.ChartsRelease, ch string) (bool, error) { +// IsChartAvailable will check if the chart exists in the available charts +func IsChartAvailable(ctx context.Context, conf *config.ChartsRelease, ch string) (bool, error) { availableCharts, err := ChartArgs(ctx, conf) if err != nil { return false, err @@ -109,8 +93,8 @@ func CheckChartArgs(ctx context.Context, conf *config.ChartsRelease, ch string) return false, nil } -// CheckVersionArgs exists to be released or forward ported -func CheckVersionArgs(ctx context.Context, conf *config.ChartsRelease, ch, v string) (bool, error) { +// IsVersionAvailable exists to be released or forward ported +func IsVersionAvailable(ctx context.Context, conf *config.ChartsRelease, ch, v string) (bool, error) { availableVersions, err := VersionArgs(ctx, conf, ch) if err != nil { return false, err @@ -124,3 +108,19 @@ func CheckVersionArgs(ctx context.Context, conf *config.ChartsRelease, ch, v str return false, nil } + +// loadState will load the lifecycle-status state from an existing state.json file at charts repo +func loadState(filePath string) (*status, error) { + s := &status{} + + file, err := os.Open(filePath) + if err != nil { + return nil, err + } + + if err := json.NewDecoder(file).Decode(&s); err != nil { + return nil, err + } + + return s, nil +}