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

Refactor the add model method. #903

Merged
merged 2 commits into from
Mar 9, 2023

Conversation

alesstimec
Copy link
Contributor

Description

The what and why - include a summary of the change, describe what it does, and include relevant motivation and context.

Fixes JIRA/GitHub issue number

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

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

LGTM just curious about the reasoning for the changes. Also some comments that should be fixed.

internal/jimm/model.go Outdated Show resolved Hide resolved
internal/jimm/model.go Outdated Show resolved Hide resolved
}

// WithConfig returns a builder with the specified model config.
func (b *modelBuilder) WithConfig(cfg map[string]interface{}) *modelBuilder {
func (b *model) WithConfig(ctx context.Context, cfg map[string]interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're not using the ctx in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wanted to keep all methods the same by passing in the context in case we want to log anything in them

internal/jimm/model.go Outdated Show resolved Hide resolved
return b.modelInfo
}

func (b *model) withConfigFrom(ctx context.Context, getConfigFunction func(ctx context.Context) (map[string]interface{}, error)) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefit of this function rather than the approach before? I.e. getting the config in the calling code and then calling withConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving more of the logic into the model struct

Copy link
Contributor

@ale8k ale8k left a comment

Choose a reason for hiding this comment

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

Much better

@alesstimec alesstimec merged commit 714ba39 into canonical:main Mar 9, 2023
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.

3 participants