Skip to content

Releases: redhat-best-practices-for-k8s/certsuite-claim

Initial GoLang Client Bindings

30 Oct 19:57
Compare
Choose a tag to compare
Pre-release
GoLang Language Client Bindings

The whole idea of abstracting `claim-schema.json` using JSON Schema was to
support several client languages.  Since `test-network-function` is written in
GoLang, a GoLang language client (or schema language binding) is needed to use
the Schema.  https://github.com/a-h/generate provides a means for generating
GoLang structs and their corresponding MarshallJSON(...) and
UnmarshallJSON(...) interface implementations for arbitrary JSON Schemas.

The  generator does a great job, but failed to provide a few pieces of
flexibility.  Namely, a-h's `generate` blindly maps JSON Schema `object` types
to GoLang structs.  Since GoLang is strongly typed, this makes sense for the
majority of use cases.  However, since we do not own the schema for some parts
of our claim (i.e., junit results, lshw output, etc.), we actually want to
force GoLang to accept arbitrary JSON input.  Thus, an internal generator was
added to reconfigure certain property types.

Generated code is automatically tested, although the testing is somewhat
limited by the fact that a-h's `generate` sometimes emits non-testable code.
That is fine, as performance is not a concern here, and the compiler is likely
smart enough to elide un-callable code.

Finally, several Makefile targets were abstracted to:
1) generate/install the GoLang language binding based on `json-schema.json`.
2) run `gofmt`
3) run `go lint`
4) build the client
5) run test cases against the built client.

To update the GoLang language bindings, just run `make`.

Signed-off-by: Ryan Goulding <[email protected]>

Initial Definition of a Claim

26 Oct 16:55
0ae6108
Compare
Choose a tag to compare
Pre-release

The initial definition of a test-network-function claim.