Skip to content

Add schemas package for API/Schema versioning scheme#74

Merged
davidallendj merged 3 commits intomainfrom
allend/schemas
Sep 3, 2025
Merged

Add schemas package for API/Schema versioning scheme#74
davidallendj merged 3 commits intomainfrom
allend/schemas

Conversation

@davidallendj
Copy link
Collaborator

@davidallendj davidallendj commented Aug 21, 2025

This PR moves the contents of https://github.com/OpenCHAMI/schemas to SMD to move towards OpenCHAMI/roadmap#78 (comment).

@davidallendj davidallendj marked this pull request as draft August 25, 2025 15:48
@davidallendj
Copy link
Collaborator Author

I moved the repo but haven't update the import references in SMD. I'm going to go ahead and do that real quick for SMD.

Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
@@ -0,0 +1,223 @@
package csm
Copy link
Collaborator

Choose a reason for hiding this comment

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

The hms-xnames project is fairly complete. https://github.com/Cray-HPE/hms-xname
Did you consider using this?

Alternately what you have here is fine. It has the advantage of being simpler and more targeted.

Copy link
Collaborator Author

@davidallendj davidallendj Aug 26, 2025

Choose a reason for hiding this comment

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

Yeah, we use that library in other places but the original schemas repo that we're migrating already had this. I'm not opposed to changing it especially if that means less maintenance burden overall.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might be better to just leave it how it is for now considering ochami is referencing this package.

https://github.com/OpenCHAMI/ochami/blob/e7577b97cedae5d3bc4bf3a514489f46b80b1491/cmd/smd-rfe-add.go#L10
https://github.com/OpenCHAMI/ochami/blob/e7577b97cedae5d3bc4bf3a514489f46b80b1491/pkg/xname/xname.go#L6

On the other hand, it probably wouldn't be that difficult to refactor those instances to use the hms-xname library.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's because I thought we would exclusively stick with our own schemas repo. The only structs in those references are

  • csm.XNameComponents
  • csm.RedfishEndpoint

Both of which probably have parallels in hms-xname. If that's the way we want to go, I don't anticipate that it would be too hard to do it in ochami.

Copy link
Member

Choose a reason for hiding this comment

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

I'd love to deprecate hms-xname altogether. The service should own the schemas it represents.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean, in the context of OpenCHAMI, should SMD "own" the xname schema?


// Envelope structure for schema versioning
type Envelope struct {
SchemaID string `json:"schema_id"`
Copy link
Collaborator

@shunr-hpe shunr-hpe Aug 28, 2025

Choose a reason for hiding this comment

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

Should OpenCHAMI have a recommend property style for json?
What style do you prefer?

At HPE we plan to go with camel case instead of snake case or pascal case in our other products.
For HPE this means

  1. Lower case first letter.
  2. Property characters limited to A-Z, a-z, 0-9.
  3. Abbreviations treated as words. For example we plan to use resourceUri instead of resourceURI.
    This mostly only applies to REST APIs using json. It wouldn't apply to what property style is used in a given language (i.e. go, python, etc.)

In my experience, and as far as I remember, I've only ever used JSON with camel case, which is probably just due to the corner of software development that I've spent my time in. So it's just my subjective preference to use camel case. Snake case seems like an equally reasonable preference for someone to have.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This subject probably should be dealt with in its own RFD and future PRs.
I'm fine with this PR being submitted as is.

Copy link

Choose a reason for hiding this comment

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

Existing code breaking with the Go stdlib initialism convention ("URI" rather than "Uri") has been slowly driving me mad :)

Either way we'd really need some automated way to enforce them; human enforcement of format standards is tedious and inconsistent.

We'd want to set up https://github.com/ldez/tagliatelle in golangci-lint and bring existing code in line, but that'll be a breaking change and would need to be coordinated across repos.

Copy link
Member

Choose a reason for hiding this comment

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

Do you want to propose tagliatelle to our common quality standards at the dev summit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@shunr-hpe I assume you're referring specifically to the JSON tags in this comment right? I think I've seen snake-case consistently used in our repos thus far.

@davidallendj davidallendj merged commit b1262a1 into main Sep 3, 2025
6 checks passed
@davidallendj davidallendj deleted the allend/schemas branch September 3, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants