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

WIP: Make dns, post_up and post_down optional #15

Closed
wants to merge 2 commits into from

Conversation

nsg
Copy link

@nsg nsg commented Dec 23, 2021

Proposed Changes

Like we discussed in #14. I have never worked with Home Assistant Addons before so I hope I got everything correct. My initial thought was to make dns, post_up and post_down optional via the schema, changing str to str? in the schema but that just used the default value from options instead. I changed approach to just allow an empty value instead.

DNS

Set the dns list to an empty list, dns: [], this will remove DNS = ... from wg0.conf

PostUP and PostDown

Set the post_up (or post_down) to an empty string, post_up: "", this will remove PostUp = ... from wg0.conf

Related Issues


What do you think? An alternative would to use str? and remove the default values for dns, post_up and post_down from options. That should not break existing installations, but will change the behavior a little. What do you prefer?

@bigmoby
Copy link
Owner

bigmoby commented Dec 24, 2021

Hi @nsg is this PR in WIP or could I review it?

@nsg
Copy link
Author

nsg commented Dec 24, 2021

I did some more experimenting last evening and opened up a PR #16 to share. I also implemented an alternative to this PR with this commit nsg@414f2f9 ... this implements my above mentioned initial thought. I think that's closer to what a user expects, "remove a line of yaml = line removed from wg0.conf" ... this has of course the drawback that we can't use default values for these options, I prefer this solution.

What do you think?


Code samples

How to remove options in this PR:

interface:
  private_key: sEcrEtpRIvatEkey=
  address: 10.0.0.2/24
  dns: []
  post_up: ""
  post_down: ""

How to remove the same options in #16

interface:
  private_key: sEcrEtpRIvatEkey=
  address: 10.0.0.2/24

@bigmoby
Copy link
Owner

bigmoby commented Dec 26, 2021

Hi @nsg thank you so much for your contribute 🙏
In these days I saw both PRs you left WIP and I get several hints from your code. I create the 0.1.9 version of this add-on, I hope you could enjoy it! 👍
Many thanks,
Bigmoby

@bigmoby bigmoby closed this Dec 26, 2021
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.

None yet

2 participants