Skip to content

Latest commit

 

History

History
91 lines (61 loc) · 3.74 KB

MICROVERSIONS.md

File metadata and controls

91 lines (61 loc) · 3.74 KB

Microversions

Table of Contents

Introduction

Microversions are an OpenStack API ability which allows developers to add and remove features while still retaining backwards compatibility for all prior versions of the API.

More information can be found here:

Note: these links are not an exhaustive reference for microversions.

Client Configuration

You can set a specific microversion on a Service Client by doing the following:

client, err := openstack.NewComputeV2(providerClient, nil)
client.Microversion = "2.52"

Gophercloud Developer Information

Microversions change several aspects about API interaction.

Existing Fields, New Values

This is when an existing field behaves like an "enum" and a new valid value is possible by setting the client's microversion to a specific version.

An example of this can be seen with Nova/Compute's Server Group policy field and the introduction of the soft-affinity value.

Unless Gophercloud is limiting the valid values that are passed to the Nova/Compute service, no changes are required in Gophercloud.

New Request Fields

This is when a microversion enables a new field to be used in an API request. When implementing this kind of change, it is imperative that the field has the omitempty attribute set. If omitempty is not set, then the field will be used for all microversions and possibly cause an error from the API service. You may need to use a pointer field in order for this to work.

When adding a new field, please make sure to include a GoDoc comment about what microversions the field is valid for.

Please see here for an example.

New Response Fields

This is when a microversion includes new fields in the API response. The correct way of implementing this in Gophercloud is to add the field to the resource's "result" struct (in the results.go file) as a pointer. This way, the developer can check for a nil value to see if the field was set from a microversioned result.

When adding a new field, please make sure to include a GoDoc comment about what microversions the field is valid for.

Please see here for an example.

Modified Response Fields

This is when the new type of the returned field is incompatible with the original type. When this happens, an entire new result struct must be created with new Extract methods to account for both the original result struct and new result struct.

These new structs and methods need to be defined in a new microversions.go file.

Please see here for an example.

Application Developer Information

Gophercloud does not perform any validation checks on the API request to make sure it is valid for a specific microversion. It is up to you to ensure that the API request is using the correct fields and functions for the microversion.