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

Create config directory if it doesn't exist #124

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

cblecker
Copy link
Member

What type of PR is this?

bug

What this PR does / Why we need it?

When setting a config option, if the directory doesn't exist you'll get an error. This ensures the directory is created. Will return an error if it can't create the directory.

Which Jira/Github issue(s) does this PR fix?

Resolves #

Special notes for your reviewer

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2023

Codecov Report

Merging #124 (ba26a7b) into main (d933c9e) will decrease coverage by 0.27%.
The diff coverage is 0.00%.

❗ Current head ba26a7b differs from pull request most recent head 4468110. Consider uploading reports for the commit 4468110 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   49.65%   49.38%   -0.27%     
==========================================
  Files          43       43              
  Lines        2761     2776      +15     
==========================================
  Hits         1371     1371              
- Misses       1158     1173      +15     
  Partials      232      232              
Impacted Files Coverage Δ
cmd/ocm-backplane/config/set.go 16.66% <0.00%> (-6.42%) ⬇️

@@ -43,6 +44,13 @@ func setConfig(cmd *cobra.Command, args []string) error {
bpConfig.SessionDirectory = viper.GetString("session-dir")
}

// Create config directory if it doesn't exist
if dir, err := os.Stat(path.Dir(configPath)); os.IsNotExist(err) || !dir.IsDir() {
if err := os.Mkdir(path.Dir(configPath), 0750); err != nil {
Copy link

Choose a reason for hiding this comment

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

Should this be MkDirAll just in case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for asking that question. I had originally done this, but then thought to myself that what if you typo that directory.. do you want it creating a long tree because you typoed the early folder name if you set BACKPLANE_CONFIG explicitly.

The only way to know for sure the intent is to ask the user.. So now I do! And if they confirm, then I'm now using MkdirAll

Copy link

Choose a reason for hiding this comment

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

Awesome, looks good!

@cblecker cblecker force-pushed the config-dir branch 2 times, most recently from ba26a7b to b164c27 Compare June 14, 2023 00:00
@bmeng
Copy link
Contributor

bmeng commented Jun 14, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bmeng, cblecker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 14, 2023

@cblecker: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit b7d3f1a into openshift:main Jun 14, 2023
@cblecker cblecker deleted the config-dir branch June 14, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants