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

(feat) specify root repo path using DEV_REPO_ROOT for debugging #186

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

alexandreLamarre
Copy link

  • Allows specifying relative/absolute root repo paths for debugging by developers

  • correctly pass in configuration.yaml path config flag : places where defaultChartsScriptOptionsFile were used should've been using ChartsScriptOptionsFile instead

configFlag := cli.StringFlag{
		Name:        "config",
		Usage:       "A configuration file with additional options for allowing this branch to interact with other branches",
		TakesFile:   true,
		Destination: &ChartsScriptOptionsFile,
		Value:       defaultChartsScriptOptionsFile,
	}
  • Migrated references of deprecated ioutil package to stable:
    • ioutil.ReadFile -> os.Readfile
    • ioutil.WriteFile -> os.WriteFile
    • ioutil.MkdirTemp -> os.Mkdirtemp

@alexandreLamarre alexandreLamarre requested a review from a team as a code owner February 13, 2025 17:31
This allows debugging multiple charts repos directly from chart-build-scripts repo

Signed-off-by: Alexandre Lamarre <[email protected]>

(fix) duplicate getRepoRoot definitions, centralize to one shared abstraction in main.go

Signed-off-by: Alexandre Lamarre <[email protected]>
logrus.Fatalf("Unable to get current working directory: %s", err)
}

func CheckRCCharts(repoRoot string) map[string][]string {
Copy link
Author

Choose a reason for hiding this comment

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

One of the main reasons, I've removed os.Getwd() definitions in package functions is to get rid of scenarios where all functions are not sharing the same abstraction for the repoRoot -- in the case where we make changes like this one.

In this PR I'm preferring using getRepoRoot() function defined in main.go and passing it through to sub functions as that seemed to be mostly the standard when Arvind was still working on the project

Copy link
Author

Choose a reason for hiding this comment

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

We could also have a shared variable in pkg/charts, along the lines of:

func init() {

  repoRoot, err := os.Getwd()
  if err != nil {
    logrus.Fatal(err)
  } 
  DefaultRepoRoot= repoRoot
}

var (
  // default value
  DefaultRepoRoot = ""
  // flag writes to this one
  RepoRoot = ""
)

which could get passed in / written to as a cli.Flag, and consumers would use as charts.RepoRoot, but I opted for simplicity here

Comment on lines +39 to +42
func InitDependencies(repoRoot string, rootFs billy.Filesystem, branchVersion string, currentChart string) (*Dependencies, error) {
var err error

workDir, err := os.Getwd()
if err != nil {
return nil, err
}
workDir := repoRoot
Copy link
Author

@alexandreLamarre alexandreLamarre Feb 14, 2025

Choose a reason for hiding this comment

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

Could alternatively pass in just the repoRoot string and construct the billy.Filesystem inside this function to avoid duplicate parameters in function signatures, although I was unsure if the workDir should ALWAYS be the repoRoot in the autobumps/lifecycle code

@alexandreLamarre
Copy link
Author

Note this also allows for embedding git submodules which would be useful for integration tests in testify, which I think would both greatly reduce the amount of bugs shipped to charts-build-scripts, but also increase iteration speed

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.

1 participant