-
Notifications
You must be signed in to change notification settings - Fork 259
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
Update HCS Schema Files #1914
base: main
Are you sure you want to change the base?
Update HCS Schema Files #1914
Conversation
Run swagger code generator (`swagger-codegen-cli`) on HCS schema (version 2.5) based on Windows Server 2022 (OS build 20348) files to regenerate the hcsschema package (`internal/hcs/schema2`). See for schema version information. https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#schema-version-map (The files show the API version as 2.4, that is controlled by the OpenAPI schema generator, which we have no control over.) Change adds several new schema objects and fields, and updates the types of other fields (eg, `hcsschema.ConsoleSize` is now a `uint16` instead of `int32`). Fix acronym capitalization. Add `internal/hcs/schema2/doc.go` to describe package design considerations, add helper functions, and list files that are manually updated. Added `*_lookup.go` files to augment certain enum types with conversion functions. This is specifically for integer-valued enums, which OpenAPI strips information from in the spec, as well as common enums (ie, `OSType` and `SystemType`) which we convert from strings. Deleted duplicate files, as well as swagger-specific ancillary files (ie, `internal/hcs/schema2/configuration.go`, created by: https://github.com/swagger-api/swagger-codegen/blob/v2.4.32/modules/swagger-codegen/src/main/resources/go/configuration.mustache) Switch from `interface{}` to `json.RawMessage` globally within package to simplify (un)marshalling and pre-compute JSON message components. Add comment to (mostly string) fields with the expected pattern. Signed-off-by: Hamza El-Saawy <[email protected]>
Update package to use new `hcsshema` (`internal/hcs/schema2`) package. Changes are minimal: - Use new constants (eg, `hcsschema.ModifyRequestType_ADD` instead of `guestrequest.RequestTypeAdd`) - Rename certain structs (eg, `hcsschema.VirtualMachineMemory` instead of `hcsschema.Memory2`) - Update certain field types (eg, `uint16` for `hcsschema.SystemTime` fields) Updates to `internal\protocol\guestrequest` and `internal\protocol\guestresource` are deferred for future work, when guest protocol definitions and logic (in `internal\guest\prot` and `internal\guest\bridge`) can be be fully merged with the host code in `internal\hcs\schema2` and `internal\gcs`. Signed-off-by: Hamza El-Saawy <[email protected]>
4d77c84
to
6d73fb4
Compare
a lot of schema definitions are not currently being used. Is the idea to define them anyway for potential 3rd party integrations or? |
we dont really have control over what is generated, since we get everything defined in the schema file |
HCS schema v2 files (
internal/hcs/schema2
) haven't been updated in a while, are missing several types, do not define enum values (eg, ModifyResourceType values are manually defined ininternal\protocol\guestresource
), and default toint32
for all integer-valued fields (eg, hcsschema.ConsoleSize should haveuint16
fields)).This PR is split into 2 PRs:
swagger-codegen-cli
) on HCS schema version 2.5 (based on Windows Server 2022 (OS build 20348)) files to regenerate the hcsschema package (internal/hcs/schema2
). Additionally, add helper functions and manual updates to the package.Additionally, this PR adds a manifest of the files changed (and added) to the schema package (in
doc.go
), so manual updates can be re-applied if the schema files are re-created in the future.Note: The files show the API version as 2.4, that is controlled by the OpenAPI schema generator, which we have no control over.
Additionally, even though schema version 2.5 fields are added, since the API is versioned, no new behavior is introduced when making requests.
The major changes within
internal/hcs/schema2
are:Processor2
is now VirtualMachineProcessor).hcsschema.ConsoleSize
is now auint16
instead ofint32
). This doesn't apply to integer arrays because of limitations in swagger codegen).internal/hcs/schema2/doc.go
to describe package design considerations, add helper functions, and list files that have been manually updated.*_lookup.go
files to augment certain enum types with conversion functions. This is specifically for integer-valued enums, which OpenAPI strips information from in the spec, as well as common enums (ie,OSType
andSystemType
) which we convert from strings.*_extra.go
) files for creating certain request messages.internal/hcs/schema2/configuration.go
, which is never used).interface{}
to*json.RawMessage
globally within package to simplify (un)marshalling, and reduce the number of manual updates needed, since certain instances ofinterface{}
will need it.The generated schema files (re)define types and values manually created in
internal\protocol\guestrequest
andinternal\protocol\guestresource
, but the latter are left for a future PR to consolidate/remove.