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

Validate zero modules #324

Merged
merged 4 commits into from
Dec 15, 2020
Merged

Validate zero modules #324

merged 4 commits into from
Dec 15, 2020

Conversation

GrooveStomp
Copy link
Contributor

Adds two private functions in 'internal/module_config':

  • func (cfg ModuleConfig) collectMissing() []string
  • func findMissing(reflect.Value, string, string, []string)

These are unexported functions that aid in introspecting a datastructure to see if it has all its expected data.
These functions are implicitly invoked via:

  • func LoadModuleConfig(string) (ModuleConfig, error)

If there are errors then the program aborts with appropriate output.

Adds two private functions in 'internal/module_config':
- func (cfg ModuleConfig) collectMissing() []string
- func findMissing(reflect.Value, string, string, []string)

These are unexported functions that aid in introspecting a datastructure to see if it has all its expected data.
These functions are implicitly invoked via:
- func LoadModuleConfig(string) (ModuleConfig, error)

If there are errors then the program aborts with appropriate output.
func LoadModuleConfig(filePath string) (ModuleConfig, error) {
config := ModuleConfig{}

var required = []string{}
fmt.Printf("%+#v\n", required)
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is not needed anymore? since we're treating non-omitempty as required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for sure! Thanks.

// If the value of the current node is equal to the zero value for its datatype
// and its struct field does *not* have a "omitempty" value, then we assume it
// is missing and add it to the resultset.
func findMissing(obj reflect.Value, path, metadata string, missing *[]string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🕶️ 👍

@GrooveStomp GrooveStomp merged commit c45c39e into main Dec 15, 2020
@GrooveStomp GrooveStomp deleted the 230-validate-zero-modules branch December 15, 2020 19:59
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.

2 participants