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

feat: function to normalize the spec #30

Merged
merged 1 commit into from
Mar 20, 2024
Merged

feat: function to normalize the spec #30

merged 1 commit into from
Mar 20, 2024

Conversation

johanneswuerbach
Copy link
Contributor

Description

Instead of implementing common concepts like embedding files in each implementation, add a Normalize function, which performs such operations.

What does this PR do?

Move shared functionality (embedding files) into this library.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

loader/normalize.go Outdated Show resolved Hide resolved
README.md Outdated

var srcMap map[string]interface{}
if err = loader.ParseYAML(&srcMap, src); err != nil {
if err := loader.ParseYAML(&srcMap, src); err != nil {
panic(err)
}

var spec score.WorkloadSpec
Copy link
Member

Choose a reason for hiding this comment

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

We should also recommend a call to score-go/schema Validate() before calling map spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

)

// Normalize normalizes the target Workload by:
// * embedding container file sources as content
Copy link
Member

Choose a reason for hiding this comment

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

nit pick: the only other normalisation I can think of so far is setting the protocol and target port in the services block if they aren't defined. Don't have to include them here, as most converters will be doing that by default anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I wasn't really sure if we would add something in the future 🤔

Copy link
Member

@astromechza astromechza left a comment

Choose a reason for hiding this comment

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

LGTM, couple of comments but nothing too important

Signed-off-by: Johannes Würbach <[email protected]>
@johanneswuerbach johanneswuerbach merged commit 620b70b into main Mar 20, 2024
2 checks passed
@johanneswuerbach johanneswuerbach deleted the normalize branch March 20, 2024 12:36
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