Skip to content

Commit

Permalink
changing naming strategy from arguments.go -> chart_management.go
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasSUSE committed Aug 9, 2024
1 parent 1cd79df commit cac4e42
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions cmd/release/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ 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
}
if !found {
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
}
Expand Down
44 changes: 22 additions & 22 deletions release/charts/arguments.go → release/charts/chart_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}

0 comments on commit cac4e42

Please sign in to comment.