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

Ordered helmfile(s) from a directory #160

Merged
merged 3 commits into from
Jun 14, 2018

Conversation

mumoshu
Copy link
Collaborator

@mumoshu mumoshu commented Jun 6, 2018

Resolves #151 #137

main.go Outdated
dir = DefaultHelmfileDirectory
}

if dir != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is clearer

if dir != "" { 
...
else if  fileExists(DefaultHelmfileDirectory) && directoryExists(DefaultHelmfileDirectory) {
...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What would be included in if and else if bodies respectively? We need dir to be set for use in https://github.com/roboll/helmfile/pull/160/files#diff-7ddfb3e035b42cd70649cc33393fe32cR325.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would it look clearer now?

main.go Outdated
return files, nil
}

if fileExists(DefaultHelmfile) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we complain if we have both a helmfile dir and a helmfile? Or should we load both? Currently it would ignore the helmfile and use the helmdir.

Copy link

@gtaylor gtaylor Jun 6, 2018

Choose a reason for hiding this comment

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

That's a sneaky kind of behavior, so whatever we do, I hope we make it explicit and/or noisy. Maybe a warning + using the helmdir? Or an error and immediate exit if we want to really prevent confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Typically with apps that have a conf.d structure, they also support a main config file. That main config file then will then have an option to point to a conf.d folder. For example systemd. Now, I'm not advocating adding this to this PR. As far as I'm concerned, executing one or the other (or even both) is fine by me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the feedbacks! Let me go forward with the immediate exit for now. I want to make it very explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in the last commit

main.go Outdated
existingFile = DeprecatedHelmfile
}

if specifiedPath == "" && existingFile != "" && existingDir != "" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe that specifiedPath == "" is needed in order to allow the user to selectively run helmfile sync for the default helmfile.d or helmfile.yaml, and helmfile sync -f $path for a specific helmfile

Copy link
Contributor

Choose a reason for hiding this comment

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

The logic looks correct after stepping through a bunch of options, but it's very complicated. I think I would move the DefaultHelmfile/DeprecatedHelmfile check as part of the first if else. I also think you can drop the specifiedPath=="" from this if statement as the first function should always set existingDir if specifiedPath is set or return.

And of course I could be missing something on my recommendations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, so this block should be nested inside the } else if pathExists(DefaultHelmfileDirectory) && directoryExists(DefaultHelmfileDirectory) { block in the first if-else?
Sounds good! I'll address it asap. Thanks 🙏

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jun 12, 2018

Can I merge this? 😉

@mumoshu mumoshu changed the title WIP: Ordered helmfile(s) from a directory Ordered helmfile(s) from a directory Jun 12, 2018
@mumoshu
Copy link
Collaborator Author

mumoshu commented Jun 13, 2018

@sstarcher Thanks for the review. I wonder if it's a bit more readable now :)

@osterman
Copy link
Contributor

Itching to use this!!

@mumoshu mumoshu merged commit 2fba241 into roboll:master Jun 14, 2018
@mumoshu mumoshu deleted the ordered-helmfiles-from-dir branch June 14, 2018 13:20
@osterman
Copy link
Contributor

Can we get a new release of helmfile so we can download/install the binary in our scripts?

@alebabai
Copy link

alebabai commented Jul 4, 2018

@mumoshu could you explain a bit how to use helmfile.d?
Because it's seems it doesn't work for me, i'm using Helmfile v0.20.0

So i have helmfile.d dir in current directory (without helmfile.yaml).
I executed $ helmfile sync and get

2018/07/04 14:29:52 err: specified state file helmfile.yaml is not found.

Another question is about path to the values-files if helmfile.d is used.
Will path to the values-files be resolved relatively to helmfile.d folder or execution folder?

@alebabai
Copy link

alebabai commented Jul 4, 2018

It works for helmfile -f helmfile.d/ sync, but didn't catch default folder name automatically.
By the way in this case path to the values-files have been resolved relatively to helmfile.d folder and not relatively to the current execution folder.

@osterman
Copy link
Contributor

osterman commented Jul 10, 2018

@mumoshu

Also, we are not able to use --selector with -f helmfile.d/

kops ➤  chamber exec kops -- helmfile -f helmfile.d/ -l name=portal sync
2018/07/10 19:00:52 Specified selector did not match any releases.

Using any other labels also fail. Using explicit file (e.g. helmfile.d/0620.portal.yaml) works, thus it appears to be a bug with this implementation.

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.

5 participants