-
Bug
-
Resolution: Unresolved
-
Undefined
-
None
-
None
-
None
-
False
-
-
False
-
?
-
None
-
-
-
-
Important
Currently we are creating a lot of modules in Go, which result in too many single binaries where some of them could served the same purpose, example with create_server and delete_server which can be a single module such as openstack_server.go where the Ansible boolean style can be use:
present: true or false
Also we need to improve the code to use pointer receiver for the openstack/ package in order to share the provider/authentication instead of re-creating a client for each calls.
For example, improve the DstCloud structure to share the provide and add pointer receiver to each functions which required an authentication:
type DstCloud struct { Auth `json:"auth"` RegionName string `json:"region_name"` Interface string `json:"interface"` IdentityAPIVersion int `json:"identity_api_version"` Provider *gophercloud.ProviderClient `json:"-"` }
func (c *DstCloud) CreateVolume(opts VolOpts, setUEFI bool) (*volumes.Volume, error) { client, err := openstack.NewBlockStorageV3(c.Provider, gophercloud.EndpointOpts{ Region: c.RegionName, }) if err != nil { return nil, fmt.Errorf("failed to create block storage client: %w", err) }