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

ENG-6658 user defined metadata #197

Merged
merged 22 commits into from
Jul 24, 2020

Conversation

kqdeng
Copy link
Contributor

@kqdeng kqdeng commented Jun 29, 2020

Description

  • Changes the metadata field in the hardware proto to be a string instead of a defined structure.
  • Changes the REST api endpoints and handlers to be manually defined rather than using the ones in the generated gateway files.

Related PRs:
boots: tinkerbell/smee#58
hegel: tinkerbell/hegel#16

Why is this needed

  • Metadata is meant to be a free-for-all space where users can input any data not directly relevant to tink but still used in other parts of the system. As such, it should not have a strictly defined structure.
  • The handlers generated from the proto file works fine, but doesn't allow for much control over how the request body gets parsed and how the response is formatted. As a result, feels very clunky.

Fixes: #199

How Has This Been Tested?

  • Manually using a tinkerbell/packet setup
  • Unit tests for http endpoints

How are existing users impacted? What migration steps/scripts do we need?

Users shouldn't notice a difference in pushing/getting hardware data as compared to before, except that now, any and all fields they've pushed under metadata will actually be stored. No migration needed.

For the push data for the hardware push rest endpoint, there is now no need to wrap the hardware data within {"data": {}}. For usage examples, refer to this gist.

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@mrmrcoleman mrmrcoleman added this to In Progress in Issues List Jul 6, 2020
@nathangoulding nathangoulding changed the title Eng 6658 user defined metadata ENG-6658 user defined metadata Jul 9, 2020
@kqdeng kqdeng force-pushed the ENG-6658-user-defined-metadata branch from f730101 to 76acd64 Compare July 13, 2020 01:20
@kqdeng kqdeng force-pushed the ENG-6658-user-defined-metadata branch from 76acd64 to 17caa6a Compare July 13, 2020 01:24
// writeResponse appends a new line after res
func writeResponse(w http.ResponseWriter, status int, res string) {
w.WriteHeader(status)
if _, err := w.Write([]byte(fmt.Sprintln(res))); err != nil {
Copy link
Contributor Author

@kqdeng kqdeng Jul 13, 2020

Choose a reason for hiding this comment

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

Should I add a new line at the end of a response or just leave res as is? (res is the response string to be printed/written as a response)

@kqdeng kqdeng merged commit 850584d into tinkerbell:master Jul 24, 2020
Issues List automation moved this from In Progress to Just shipped Jul 24, 2020
@kqdeng kqdeng deleted the ENG-6658-user-defined-metadata branch July 24, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Issues List
  
Just shipped
Development

Successfully merging this pull request may close these issues.

Metadata structure should be user defined
2 participants