Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

fix: function for default config#201

Merged
anisatahlil merged 5 commits into
mainfrom
atahlil/defaultConfig
Dec 7, 2021
Merged

fix: function for default config#201
anisatahlil merged 5 commits into
mainfrom
atahlil/defaultConfig

Conversation

@anisatahlil
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of Changes
This is a follow up to address the comments in #197. This change involves adding a function that returns the default config.

Description of how you validated changes

$ agc configure email test@email.com
2021-12-01T09:29:09-08:00 𝒊  Setting user email address to: 'test@email.com'
$ agc configure describe
2021-12-01T09:29:12-08:00 𝒊  Reading user specific configuration
CONFIG
FORMAT  text
USER    test@email.com  test1X6OLM
$ agc 

Checklist

  • If this change would make any existing documentation invalid, I have included those updates within this PR
  • I have added unit tests that prove my fix is effective or that my feature works
  • I have linted my code before raising the PR
  • Title of this Pull Request follows Conventional Commits standard: https://www.conventionalcommits.org/en/v1.0.0/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@anisatahlil anisatahlil temporarily deployed to slack December 1, 2021 17:30 Inactive
@anisatahlil anisatahlil changed the title fix:function for default config fix: function for default config Dec 1, 2021
@anisatahlil anisatahlil closed this Dec 1, 2021
@anisatahlil anisatahlil reopened this Dec 1, 2021
return sanitizedUserName + hash(emailAddress)
}

func defaultConfig() Config {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can just be a variable

@@ -24,13 +24,13 @@ func toYaml(filePath string, configData Config) error {
}

func fromYaml(filePath string) (Config, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The more I read this the less I like it due to the tight coupling to the Config interface. Ideally, this should use Generics which will be released with Go 1.18 in February in 2022.

If we wanted this to read like Go 1.17 code, we should pass in the interface to "fromYaml" which then passes it through to the yaml.Unmarhsal function. This would allow the fromYaml function to be generic as the function name suggests that it is. It isn't a large change so despite it being pre-optimization this is probably the correct path forward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah fromYaml is tightly coupled with the config Interface and generics would help resolve that once that is released. I am okay to pass the interface to set this function on a path to work more generically. But I am also wondering if we have similar functions that can benefit from generics, would need similar changes and if that could perhaps be addressed in a separate PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We would have other code like that but lets keep it simple for now and just address this file for now and address the others as they come up.

@anisatahlil anisatahlil merged commit e6983ae into main Dec 7, 2021
@anisatahlil anisatahlil deleted the atahlil/defaultConfig branch December 7, 2021 23:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants