Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature implementation: release list charts #456

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

nicholasSUSE
Copy link
Contributor

@nicholasSUSE nicholasSUSE commented Jul 26, 2024

Issue:

#445

Solution:

After implementing: rancher/charts-build-scripts#144

This is the integration between:

  • charts-build-scripts command lifecycle-status
  • ecm-distro-tools command release list charts

Result example:

The logs printed by lifecycle-status are printed to the terminal and the saved log files path is also printed in the terminal:

.
.
.

time=2024-07-26T18:11:33-03:00 level=info msg=Assets to be RELEASED

time=2024-07-26T18:11:33-03:00 level=info msg=rancher-istio

__________________________________________________________________
time=2024-07-26T18:11:33-03:00 level=info msg=Assets to be FORWARD-PORTED

time=2024-07-26T18:11:33-03:00 level=info msg=rancher-istio
time=2024-07-26T18:11:33-03:00 level=info msg=saving app state to state.json file
time=2024-07-26T18:11:33-03:00 level=info msg=saved state file successfully

generated log files for inspection at: 
/home/nick/WORK/SOFTWARE/go/src/github.com/release-work/charts/logs/

@nicholasSUSE nicholasSUSE changed the title Release list charts Feature implementation: release list charts Jul 26, 2024
Short: "List Charts assets versions state for release process",
RunE: func(cmd *cobra.Command, args []string) error {

var branch, chart string = "", ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take advantage of the "0 value" and update this to be

var branch string
var chart string

We don't need to explicitly set the new string to ""

return errors.New("verify your config file, chart configuration not implemented correctly, you must insert workspace path and your forked repo url")
}

err := charts.ListLifecycleStatus(context.Background(), config, branch, chart)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can return here and remove the code underneath.

cmd/release/cmd/list.go Show resolved Hide resolved
"os/exec"
"strings"

ecmConfig "github.com/rancher/ecm-distro-tools/cmd/release/config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need the import alias?

Copy link
Contributor Author

@nicholasSUSE nicholasSUSE Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briandowns
To be honest, I copied it from:
release/k3s/k3s.go but I can remove it.
I just wanted to follow the pattern that was already there from the example I caught.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid import aliases if the imported package name doesn't conflict with any other imported or existing symbol.


// ListLifecycleStatus prints the lifecycle status of the charts
func ListLifecycleStatus(ctx context.Context, c *ecmConfig.ChartsRelease, branch, chart string) error {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this new line.

release/charts/charts.go Show resolved Hide resolved
}

// change working dir to the charts repo
err = os.Chdir(chartsRepoPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the if check up a line and scope lock the err value. Please do this for all calls that return a single err value.

release/charts/charts.go Show resolved Hide resolved
release/charts/charts.go Show resolved Hide resolved
}

err := executeChartsBuildScripts(c.Workspace, "lifecycle-status", branchArg, chartArg)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to: runChartsBuild. The previous name leaks implementation detail that could change in the future. This new name still conveys the idea and allows us to change from scripts to programs and exec model.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this isn't updating but it doesn't appear as though this has been completed.

@nicholasSUSE nicholasSUSE force-pushed the release-list-charts branch 2 times, most recently from d0537ea to 937541b Compare July 26, 2024 21:46
return err
}

fmt.Printf("generated log files for inspection at: \n%s\n", c.Workspace+"/logs/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this in favor of printing output from the calling code of this function. Library code shouldn't be putting anything to a log or STDOUT unless in debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briandowns I removed the print from here to the parent calling function, please check if this is right now.

@nicholasSUSE
Copy link
Contributor Author

@briandowns all fixes implemented.

Use: "charts [branch] [charts](optional)",
Short: "List Charts assets versions state for release process",
RunE: func(cmd *cobra.Command, args []string) error {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing but remove this empty line.

return response, nil
}

func runChartsBuildScripts(chartsRepoPath string, args ...string) ([]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had left a comment about changing the name but I guess not. Please change this to be runChartsBuild

// save current working dir
ecmWorkDir, err := os.Getwd()
if err != nil {
return []byte{}, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can/should return nil here rather than having an unnecessary allocation.

@nicholasSUSE nicholasSUSE merged commit 0e0019a into rancher:master Aug 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants