Skip to content

Commit

Permalink
refactor: rename getRelease to readOrFetchRelease
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornplusplus committed Dec 8, 2023
1 parent afb4820 commit fe2e425
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/chisel/cmd_cut.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (cmd *cmdCut) Execute(args []string) error {
sliceKeys[i] = sliceKey
}

release, _, err := getRelease(cmd.Release)
release, _, err := readOrFetchRelease(cmd.Release)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/chisel/cmd_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (cmd *infoCmd) Execute(args []string) error {
return ErrExtraArgs
}

release, _, err := getRelease(cmd.Release)
release, _, err := readOrFetchRelease(cmd.Release)
if err != nil {
return err
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/chisel/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ func readReleaseInfo() (label, version string, err error) {
return "", "", fmt.Errorf("cannot infer release via /etc/lsb-release, see the --release option")
}

// getRelease returns the release and release label (e.g. ubuntu-22.04 or
// /path/to/release/dir/ if a directory was passed as input).
func getRelease(releaseStr string) (release *setup.Release, releaseLabel string, err error) {
// readOrFetchRelease takes a release branch name or a release directory path.
// It fetches or reads the chisel-release depending on the nature of input and
// returns the release and release label.
// If the input is empty, it tries to read the release label from the host
// system and fetch the chisel-release accordingly.
func readOrFetchRelease(releaseStr string) (release *setup.Release, releaseLabel string, err error) {
if strings.Contains(releaseStr, "/") {
release, err = setup.ReadRelease(releaseStr)
releaseLabel = releaseStr
Expand Down

0 comments on commit fe2e425

Please sign in to comment.