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

Move version APIs to the specs-go package #214

Merged
merged 7 commits into from
Aug 8, 2024

Conversation

bart0sh
Copy link
Contributor

@bart0sh bart0sh commented Jul 29, 2024

This is a partial fix for #206

@bart0sh bart0sh force-pushed the PR017-move-version-to-go-specs-go branch from f3ac289 to 591c2a0 Compare July 29, 2024 14:35
@bart0sh
Copy link
Contributor Author

bart0sh commented Jul 29, 2024

@elezar @klihub PTAL

@bart0sh bart0sh force-pushed the PR017-move-version-to-go-specs-go branch from 591c2a0 to 1e39659 Compare July 29, 2024 14:52
Copy link
Contributor

@klihub klihub left a comment

Choose a reason for hiding this comment

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

LGTM.

@bart0sh
Copy link
Contributor Author

bart0sh commented Aug 5, 2024

@elezar can you review this PR?

Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

Thanks @bart0sh.

Definitely a great start. I think we can simplify the API that we expose w.r.t the versions and limit it to two functions:

  • ValidateVersion(*Spec) error
  • MinimumRequiredVersion(*Spec) (string, error)

specs-go/version.go Show resolved Hide resolved
pkg/cdi/spec.go Show resolved Hide resolved
pkg/cdi/spec.go Outdated Show resolved Hide resolved
specs-go/version.go Outdated Show resolved Hide resolved
specs-go/parser.go Outdated Show resolved Hide resolved
specs-go/config.go Show resolved Hide resolved
specs-go/version.go Outdated Show resolved Hide resolved
@elezar elezar mentioned this pull request Aug 6, 2024
15 tasks
@bart0sh bart0sh force-pushed the PR017-move-version-to-go-specs-go branch 3 times, most recently from 1ff42ed to 93c6586 Compare August 6, 2024 16:13
Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

Thanks @bart0sh. It's looking a lot cleaner now.

I have some additional comments, but these are mostly limited to docstrings.

pkg/cdi/spec_test.go Show resolved Hide resolved
@@ -525,7 +525,7 @@ func specType(content []byte) string {
}

func TestCurrentVersionIsValid(t *testing.T) {
require.NoError(t, validateVersion(cdi.CurrentVersion))
require.NoError(t, cdi.ValidateVersion(&cdi.Spec{Version: cdi.CurrentVersion}))
}

func TestRequiredVersion(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consider moving these to specs-go/version_test.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would add a bunch of dependencies to specs-go/go.mod/sum, which would make it harder to import into k/k

Copy link
Contributor

@elezar elezar Aug 8, 2024

Choose a reason for hiding this comment

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

That is true. Let's leave it where it is then. does it at least make sense to move them to a version_text.go file in this package then with note on their intent?

Would implementing them in a specs_test package improve the dependency situation?

specs-go/config.go Show resolved Hide resolved
specs-go/parser.go Outdated Show resolved Hide resolved
specs-go/version.go Show resolved Hide resolved
specs-go/version.go Outdated Show resolved Hide resolved
specs-go/version.go Outdated Show resolved Hide resolved
specs-go/version.go Outdated Show resolved Hide resolved
bart0sh and others added 3 commits August 8, 2024 07:02
Signed-off-by: Ed Bartosh <[email protected]>
Co-authored-by: Evan Lezar <[email protected]>
@bart0sh bart0sh force-pushed the PR017-move-version-to-go-specs-go branch from 30d0688 to 54e62a8 Compare August 8, 2024 04:04
pkg/cdi/qualified-device.go Outdated Show resolved Hide resolved
pkg/cdi/spec.go Outdated Show resolved Hide resolved
specs-go/parser.go Outdated Show resolved Hide resolved

import "strings"

// ParseQualifier splits a device qualifier into vendor and class.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's out of scope for this PR, but we may want to be stricter on our language here. In the spec the entity we're parsing here is the Kind, but this public function refers to it as a qualifier. Since we're in the specs package here, do we want to rename this to SplitKind(string) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally it makes sense to me. I'd propose to rename it to ParseKind if you don't mind. And I agree, it's out of scope of this PR.

Copy link
Contributor

@elezar elezar Aug 8, 2024

Choose a reason for hiding this comment

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

OK. Let's do this as a follow-up then. (ParseKind) is fine.

Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

Thanks for this @bart0sh.

I think the last comments I have are minor and can be addressed in follow-ups.

@bart0sh bart0sh force-pushed the PR017-move-version-to-go-specs-go branch from b1e626c to 7dd001f Compare August 8, 2024 12:58
@elezar elezar merged commit 16d0cd1 into cncf-tags:main Aug 8, 2024
7 checks passed
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