From 3f2c3a0eba111ac59176ee28f4e67bb6c0ffe8cb Mon Sep 17 00:00:00 2001 From: Mike Fedosin Date: Mon, 9 Sep 2019 13:02:40 +0200 Subject: [PATCH] OpenStack: remove region from install config This parameter is not used by the installer and completely ignored during the installation, so it just confuses users and should be removed. The real region value is taken from clouds.yaml file. --- Gopkg.lock | 4 +- data/data/openstack/variables-openstack.tf | 5 - docs/user/openstack/customization.md | 2 +- pkg/asset/cluster/openstack/openstack.go | 3 +- pkg/asset/cluster/tfvars.go | 1 - .../installconfig/openstack/openstack.go | 28 --- pkg/tfvars/openstack/openstack.go | 4 +- pkg/types/openstack/metadata.go | 3 +- pkg/types/openstack/platform.go | 1 + .../mock/validvaluesfetcher_generated.go | 15 -- pkg/types/openstack/validation/platform.go | 6 - .../openstack/validation/platform_test.go | 26 --- .../validation/realvalidvaluesfetcher.go | 31 ---- .../validation/validvaluesfetcher.go | 2 - pkg/types/validation/installconfig_test.go | 2 - .../openstack/identity/v3/regions/doc.go | 63 ------- .../openstack/identity/v3/regions/requests.go | 164 ------------------ .../openstack/identity/v3/regions/results.go | 129 -------------- .../openstack/identity/v3/regions/urls.go | 23 --- 19 files changed, 6 insertions(+), 506 deletions(-) delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/requests.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/results.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/urls.go diff --git a/Gopkg.lock b/Gopkg.lock index e5b216dbc2..e9f879fd3c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -336,7 +336,7 @@ [[projects]] branch = "master" - digest = "1:215e0c79e138993bdcc6914d5488284fd04c4b9ab2e15a6b432c49acbed62577" + digest = "1:cefed4accadc52d320ac8aed4fc0cd3abb3d9b01045ad42e7531e5e19774bf81" name = "github.com/gophercloud/gophercloud" packages = [ ".", @@ -349,7 +349,6 @@ "openstack/compute/v2/servers", "openstack/identity/v2/tenants", "openstack/identity/v2/tokens", - "openstack/identity/v3/regions", "openstack/identity/v3/tokens", "openstack/loadbalancer/v2/apiversions", "openstack/loadbalancer/v2/l7policies", @@ -1323,7 +1322,6 @@ "github.com/gophercloud/gophercloud/openstack/common/extensions", "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors", "github.com/gophercloud/gophercloud/openstack/compute/v2/servers", - "github.com/gophercloud/gophercloud/openstack/identity/v3/regions", "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens", "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions", "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers", diff --git a/data/data/openstack/variables-openstack.tf b/data/data/openstack/variables-openstack.tf index 43e6efcc99..6d477deaf6 100644 --- a/data/data/openstack/variables-openstack.tf +++ b/data/data/openstack/variables-openstack.tf @@ -289,11 +289,6 @@ variable "openstack_master_flavor_name" { description = "Instance size for the master node(s). Example: `m1.medium`." } -variable "openstack_region" { - type = string - description = "The target OpenStack region for the cluster." -} - variable "openstack_trunk_support" { type = string diff --git a/docs/user/openstack/customization.md b/docs/user/openstack/customization.md index f05bf3f3c6..f3824f2160 100644 --- a/docs/user/openstack/customization.md +++ b/docs/user/openstack/customization.md @@ -10,7 +10,7 @@ Beyond the [platform-agnostic `install-config.yaml` properties](../customization * `externalNetwork` (required string): The OpenStack external network name to be used for installation. * `lbFloatingIP` (required string): Existing Floating IP to associate with the API load balancer. * `octaviaSupport` (optional string): Whether OpenStack supports Octavia (`1` for true or `0` for false) -* `region` (required string): The OpenStack region where the cluster will be created. +* `region` (deprecated string): The OpenStack region where the cluster will be created. Currently this value is not used by the installer. * `trunkSupport` (optional string): Whether OpenStack ports can be trunked (`1` for true or `0` for false) ## Machine pools diff --git a/pkg/asset/cluster/openstack/openstack.go b/pkg/asset/cluster/openstack/openstack.go index c901c102d1..72bd766d1f 100644 --- a/pkg/asset/cluster/openstack/openstack.go +++ b/pkg/asset/cluster/openstack/openstack.go @@ -10,8 +10,7 @@ import ( // Metadata converts an install configuration to OpenStack metadata. func Metadata(infraID string, config *types.InstallConfig) *openstack.Metadata { return &openstack.Metadata{ - Region: config.Platform.OpenStack.Region, - Cloud: config.Platform.OpenStack.Cloud, + Cloud: config.Platform.OpenStack.Cloud, Identifier: map[string]string{ "openshiftClusterID": infraID, }, diff --git a/pkg/asset/cluster/tfvars.go b/pkg/asset/cluster/tfvars.go index 4728dd08d3..6ea1376601 100644 --- a/pkg/asset/cluster/tfvars.go +++ b/pkg/asset/cluster/tfvars.go @@ -262,7 +262,6 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error { data, err = openstacktfvars.TFVars( masters[0].Spec.ProviderSpec.Value.Object.(*openstackprovider.OpenstackProviderSpec), installConfig.Config.Platform.OpenStack.Cloud, - installConfig.Config.Platform.OpenStack.Region, installConfig.Config.Platform.OpenStack.ExternalNetwork, installConfig.Config.Platform.OpenStack.LbFloatingIP, apiVIP.String(), diff --git a/pkg/asset/installconfig/openstack/openstack.go b/pkg/asset/installconfig/openstack/openstack.go index a6c59f7e6f..ee2f6c0809 100644 --- a/pkg/asset/installconfig/openstack/openstack.go +++ b/pkg/asset/installconfig/openstack/openstack.go @@ -44,33 +44,6 @@ func Platform() (*openstack.Platform, error) { return nil, err } - regionNames, err := validValuesFetcher.GetRegionNames(cloud) - if err != nil { - return nil, err - } - sort.Strings(regionNames) - var region string - err = survey.Ask([]*survey.Question{ - { - Prompt: &survey.Select{ - Message: "Region", - Help: "The OpenStack region to be used for installation.", - Options: regionNames, - }, - Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error { - value := ans.(string) - i := sort.SearchStrings(regionNames, value) - if i == len(regionNames) || regionNames[i] != value { - return errors.Errorf("invalid region name %q, should be one of %+v", value, strings.Join(regionNames, ", ")) - } - return nil - }), - }, - }, ®ion) - if err != nil { - return nil, err - } - networkNames, err := validValuesFetcher.GetNetworkNames(cloud) if err != nil { return nil, err @@ -179,7 +152,6 @@ func Platform() (*openstack.Platform, error) { } return &openstack.Platform{ - Region: region, Cloud: cloud, ExternalNetwork: extNet, FlavorName: flavor, diff --git a/pkg/tfvars/openstack/openstack.go b/pkg/tfvars/openstack/openstack.go index 5b44c41616..6ece5a9e29 100644 --- a/pkg/tfvars/openstack/openstack.go +++ b/pkg/tfvars/openstack/openstack.go @@ -8,7 +8,6 @@ import ( ) type config struct { - Region string `json:"openstack_region,omitempty"` BaseImage string `json:"openstack_base_image,omitempty"` ExternalNetwork string `json:"openstack_external_network,omitempty"` Cloud string `json:"openstack_credentials_cloud,omitempty"` @@ -22,9 +21,8 @@ type config struct { } // TFVars generates OpenStack-specific Terraform variables. -func TFVars(masterConfig *v1alpha1.OpenstackProviderSpec, cloud string, region string, externalNetwork string, lbFloatingIP string, apiVIP string, dnsVIP string, ingressVIP string, trunkSupport string, octaviaSupport string) ([]byte, error) { +func TFVars(masterConfig *v1alpha1.OpenstackProviderSpec, cloud string, externalNetwork string, lbFloatingIP string, apiVIP string, dnsVIP string, ingressVIP string, trunkSupport string, octaviaSupport string) ([]byte, error) { cfg := &config{ - Region: region, BaseImage: masterConfig.Image, ExternalNetwork: externalNetwork, Cloud: cloud, diff --git a/pkg/types/openstack/metadata.go b/pkg/types/openstack/metadata.go index de70338a4b..488248d226 100644 --- a/pkg/types/openstack/metadata.go +++ b/pkg/types/openstack/metadata.go @@ -2,8 +2,7 @@ package openstack // Metadata contains OpenStack metadata (e.g. for uninstalling the cluster). type Metadata struct { - Region string `json:"region"` - Cloud string `json:"cloud"` + Cloud string `json:"cloud"` // Most OpenStack resources are tagged with these tags as identifier. Identifier map[string]string `json:"identifier"` } diff --git a/pkg/types/openstack/platform.go b/pkg/types/openstack/platform.go index 939aa02708..5b20e7103e 100644 --- a/pkg/types/openstack/platform.go +++ b/pkg/types/openstack/platform.go @@ -4,6 +4,7 @@ package openstack // machinesets use. type Platform struct { // Region specifies the OpenStack region where the cluster will be created. + // Deprecated: this value is not used by the installer. Region string `json:"region"` // DefaultMachinePlatform is the default configuration used when diff --git a/pkg/types/openstack/validation/mock/validvaluesfetcher_generated.go b/pkg/types/openstack/validation/mock/validvaluesfetcher_generated.go index e1e2780c3c..72ca47baff 100644 --- a/pkg/types/openstack/validation/mock/validvaluesfetcher_generated.go +++ b/pkg/types/openstack/validation/mock/validvaluesfetcher_generated.go @@ -47,21 +47,6 @@ func (mr *MockValidValuesFetcherMockRecorder) GetCloudNames() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCloudNames", reflect.TypeOf((*MockValidValuesFetcher)(nil).GetCloudNames)) } -// GetRegionNames mocks base method -func (m *MockValidValuesFetcher) GetRegionNames(cloud string) ([]string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRegionNames", cloud) - ret0, _ := ret[0].([]string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetRegionNames indicates an expected call of GetRegionNames -func (mr *MockValidValuesFetcherMockRecorder) GetRegionNames(cloud interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRegionNames", reflect.TypeOf((*MockValidValuesFetcher)(nil).GetRegionNames), cloud) -} - // GetNetworkNames mocks base method func (m *MockValidValuesFetcher) GetNetworkNames(cloud string) ([]string, error) { m.ctrl.T.Helper() diff --git a/pkg/types/openstack/validation/platform.go b/pkg/types/openstack/validation/platform.go index 75dffab5be..b953333631 100644 --- a/pkg/types/openstack/validation/platform.go +++ b/pkg/types/openstack/validation/platform.go @@ -18,12 +18,6 @@ func ValidatePlatform(p *openstack.Platform, n *types.Networking, fldPath *field } else if !isValidValue(p.Cloud, validClouds) { allErrs = append(allErrs, field.NotSupported(fldPath.Child("cloud"), p.Cloud, validClouds)) } else { - validRegions, err := fetcher.GetRegionNames(p.Cloud) - if err != nil { - allErrs = append(allErrs, field.InternalError(fldPath.Child("region"), errors.New("could not retrieve valid regions"))) - } else if !isValidValue(p.Region, validRegions) { - allErrs = append(allErrs, field.NotSupported(fldPath.Child("region"), p.Region, validRegions)) - } validNetworks, err := fetcher.GetNetworkNames(p.Cloud) if err != nil { allErrs = append(allErrs, field.InternalError(fldPath.Child("externalNetwork"), errors.New("could not retrieve valid networks"))) diff --git a/pkg/types/openstack/validation/platform_test.go b/pkg/types/openstack/validation/platform_test.go index 8b0fc3cc61..49f21ab1b0 100644 --- a/pkg/types/openstack/validation/platform_test.go +++ b/pkg/types/openstack/validation/platform_test.go @@ -15,7 +15,6 @@ import ( func validPlatform() *openstack.Platform { return &openstack.Platform{ - Region: "test-region", Cloud: "test-cloud", ExternalNetwork: "test-network", FlavorName: "test-flavor", @@ -27,7 +26,6 @@ func TestValidatePlatform(t *testing.T) { name string platform *openstack.Platform noClouds bool - noRegions bool noNetworks bool noFlavors bool noNetExts bool @@ -39,15 +37,6 @@ func TestValidatePlatform(t *testing.T) { platform: validPlatform(), valid: true, }, - { - name: "missing region", - platform: func() *openstack.Platform { - p := validPlatform() - p.Region = "" - return p - }(), - valid: false, - }, { name: "missing cloud", platform: func() *openstack.Platform { @@ -81,12 +70,6 @@ func TestValidatePlatform(t *testing.T) { noClouds: true, valid: false, }, - { - name: "regions fetch failure", - platform: validPlatform(), - noRegions: true, - valid: false, - }, { name: "networks fetch failure", platform: validPlatform(), @@ -125,15 +108,6 @@ func TestValidatePlatform(t *testing.T) { fetcher.EXPECT().GetCloudNames(). Return([]string{"test-cloud"}, nil) } - if tc.noRegions { - fetcher.EXPECT().GetRegionNames(tc.platform.Cloud). - Return(nil, errors.New("no regions")). - MaxTimes(1) - } else { - fetcher.EXPECT().GetRegionNames(tc.platform.Cloud). - Return([]string{"test-region"}, nil). - MaxTimes(1) - } if tc.noNetworks { fetcher.EXPECT().GetNetworkNames(tc.platform.Cloud). Return(nil, errors.New("no networks")). diff --git a/pkg/types/openstack/validation/realvalidvaluesfetcher.go b/pkg/types/openstack/validation/realvalidvaluesfetcher.go index ec85250cfa..2135065cb1 100644 --- a/pkg/types/openstack/validation/realvalidvaluesfetcher.go +++ b/pkg/types/openstack/validation/realvalidvaluesfetcher.go @@ -5,7 +5,6 @@ import ( "github.com/gophercloud/gophercloud/openstack/common/extensions" "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - "github.com/gophercloud/gophercloud/openstack/identity/v3/regions" "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" netext "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" @@ -35,36 +34,6 @@ func (f realValidValuesFetcher) GetCloudNames() ([]string, error) { return cloudNames, nil } -// GetRegionNames gets the valid region names. -func (f realValidValuesFetcher) GetRegionNames(cloud string) ([]string, error) { - opts := &clientconfig.ClientOpts{ - Cloud: cloud, - } - - conn, err := clientconfig.NewServiceClient("identity", opts) - if err != nil { - return nil, err - } - - listOpts := regions.ListOpts{} - allPages, err := regions.List(conn, listOpts).AllPages() - if err != nil { - return nil, err - } - - allRegions, err := regions.ExtractRegions(allPages) - if err != nil { - return nil, err - } - - regionNames := make([]string, len(allRegions)) - for x, region := range allRegions { - regionNames[x] = region.ID - } - - return regionNames, nil -} - // GetNetworkNames gets the valid network names. func (f realValidValuesFetcher) GetNetworkNames(cloud string) ([]string, error) { opts := &clientconfig.ClientOpts{ diff --git a/pkg/types/openstack/validation/validvaluesfetcher.go b/pkg/types/openstack/validation/validvaluesfetcher.go index 5ed26d1671..1b7d0a31b5 100644 --- a/pkg/types/openstack/validation/validvaluesfetcher.go +++ b/pkg/types/openstack/validation/validvaluesfetcher.go @@ -6,8 +6,6 @@ package validation type ValidValuesFetcher interface { // GetCloudNames gets the valid cloud names. GetCloudNames() ([]string, error) - // GetRegionNames gets the valid region names. - GetRegionNames(cloud string) ([]string, error) // GetNetworkNames gets the valid network names. GetNetworkNames(cloud string) ([]string, error) // GetFlavorNames gets the valid flavor names. diff --git a/pkg/types/validation/installconfig_test.go b/pkg/types/validation/installconfig_test.go index 77e768486f..db70042665 100644 --- a/pkg/types/validation/installconfig_test.go +++ b/pkg/types/validation/installconfig_test.go @@ -106,7 +106,6 @@ func validBareMetalPlatform() *baremetal.Platform { func validOpenStackPlatform() *openstack.Platform { return &openstack.Platform{ - Region: "test-region", Cloud: "test-cloud", ExternalNetwork: "test-network", FlavorName: "test-flavor", @@ -709,7 +708,6 @@ func TestValidateInstallConfig(t *testing.T) { fetcher := mock.NewMockValidValuesFetcher(mockCtrl) fetcher.EXPECT().GetCloudNames().Return([]string{"test-cloud"}, nil).AnyTimes() - fetcher.EXPECT().GetRegionNames(gomock.Any()).Return([]string{"test-region"}, nil).AnyTimes() fetcher.EXPECT().GetNetworkNames(gomock.Any()).Return([]string{"test-network"}, nil).AnyTimes() fetcher.EXPECT().GetFlavorNames(gomock.Any()).Return([]string{"test-flavor"}, nil).AnyTimes() fetcher.EXPECT().GetNetworkExtensionsAliases(gomock.Any()).Return([]string{"trunk"}, nil).AnyTimes() diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/doc.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/doc.go deleted file mode 100644 index a37b05a544..0000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/doc.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Package regions manages and retrieves Regions in the OpenStack Identity Service. - -Example to List Regions - - listOpts := regions.ListOpts{ - ParentRegionID: "RegionOne", - } - - allPages, err := regions.List(identityClient, listOpts).AllPages() - if err != nil { - panic(err) - } - - allRegions, err := regions.ExtractRegions(allPages) - if err != nil { - panic(err) - } - - for _, region := range allRegions { - fmt.Printf("%+v\n", region) - } - -Example to Create a Region - - createOpts := regions.CreateOpts{ - ID: "TestRegion", - Description: "Region for testing" - Extra: map[string]interface{}{ - "email": "testregionsupport@example.com", - } - } - - region, err := regions.Create(identityClient, createOpts).Extract() - if err != nil { - panic(err) - } - -Example to Update a Region - - regionID := "TestRegion" - - // There is currently a bug in Keystone where updating the optional Extras - // attributes set in regions.Create is not supported, see: - // https://bugs.launchpad.net/keystone/+bug/1729933 - updateOpts := regions.UpdateOpts{ - Description: "Updated Description for region", - } - - region, err := regions.Update(identityClient, regionID, updateOpts).Extract() - if err != nil { - panic(err) - } - -Example to Delete a Region - - regionID := "TestRegion" - err := regions.Delete(identityClient, regionID).ExtractErr() - if err != nil { - panic(err) - } -*/ -package regions diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/requests.go deleted file mode 100644 index b5889ad3ec..0000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/requests.go +++ /dev/null @@ -1,164 +0,0 @@ -package regions - -import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" -) - -// ListOptsBuilder allows extensions to add additional parameters to -// the List request -type ListOptsBuilder interface { - ToRegionListQuery() (string, error) -} - -// ListOpts provides options to filter the List results. -type ListOpts struct { - // ParentRegionID filters the response by a parent region ID. - ParentRegionID string `q:"parent_region_id"` -} - -// ToRegionListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToRegionListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - return q.String(), err -} - -// List enumerates the Regions to which the current token has access. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(client) - if opts != nil { - query, err := opts.ToRegionListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return RegionPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// Get retrieves details on a single region, by ID. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - _, r.Err = client.Get(getURL(client, id), &r.Body, nil) - return -} - -// CreateOptsBuilder allows extensions to add additional parameters to -// the Create request. -type CreateOptsBuilder interface { - ToRegionCreateMap() (map[string]interface{}, error) -} - -// CreateOpts provides options used to create a region. -type CreateOpts struct { - // ID is the ID of the new region. - ID string `json:"id,omitempty"` - - // Description is a description of the region. - Description string `json:"description,omitempty"` - - // ParentRegionID is the ID of the parent the region to add this region under. - ParentRegionID string `json:"parent_region_id,omitempty"` - - // Extra is free-form extra key/value pairs to describe the region. - Extra map[string]interface{} `json:"-"` -} - -// ToRegionCreateMap formats a CreateOpts into a create request. -func (opts CreateOpts) ToRegionCreateMap() (map[string]interface{}, error) { - b, err := gophercloud.BuildRequestBody(opts, "region") - if err != nil { - return nil, err - } - - if opts.Extra != nil { - if v, ok := b["region"].(map[string]interface{}); ok { - for key, value := range opts.Extra { - v[key] = value - } - } - } - - return b, nil -} - -// Create creates a new Region. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { - b, err := opts.ToRegionCreateMap() - if err != nil { - r.Err = err - return - } - _, r.Err = client.Post(createURL(client), &b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{201}, - }) - return -} - -// UpdateOptsBuilder allows extensions to add additional parameters to -// the Update request. -type UpdateOptsBuilder interface { - ToRegionUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts provides options for updating a region. -type UpdateOpts struct { - // Description is a description of the region. - Description *string `json:"description,omitempty"` - - // ParentRegionID is the ID of the parent region. - ParentRegionID string `json:"parent_region_id,omitempty"` - - /* - // Due to a bug in Keystone, the Extra column of the Region table - // is not updatable, see: https://bugs.launchpad.net/keystone/+bug/1729933 - // The following lines should be uncommented once the fix is merged. - - // Extra is free-form extra key/value pairs to describe the region. - Extra map[string]interface{} `json:"-"` - */ -} - -// ToRegionUpdateMap formats a UpdateOpts into an update request. -func (opts UpdateOpts) ToRegionUpdateMap() (map[string]interface{}, error) { - b, err := gophercloud.BuildRequestBody(opts, "region") - if err != nil { - return nil, err - } - - /* - // Due to a bug in Keystone, the Extra column of the Region table - // is not updatable, see: https://bugs.launchpad.net/keystone/+bug/1729933 - // The following lines should be uncommented once the fix is merged. - - if opts.Extra != nil { - if v, ok := b["region"].(map[string]interface{}); ok { - for key, value := range opts.Extra { - v[key] = value - } - } - } - */ - - return b, nil -} - -// Update updates an existing Region. -func Update(client *gophercloud.ServiceClient, regionID string, opts UpdateOptsBuilder) (r UpdateResult) { - b, err := opts.ToRegionUpdateMap() - if err != nil { - r.Err = err - return - } - _, r.Err = client.Patch(updateURL(client, regionID), &b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - return -} - -// Delete deletes a region. -func Delete(client *gophercloud.ServiceClient, regionID string) (r DeleteResult) { - _, r.Err = client.Delete(deleteURL(client, regionID), nil) - return -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/results.go deleted file mode 100644 index a60cb34883..0000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/results.go +++ /dev/null @@ -1,129 +0,0 @@ -package regions - -import ( - "encoding/json" - - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/internal" - "github.com/gophercloud/gophercloud/pagination" -) - -// Region helps manage related users. -type Region struct { - // Description describes the region purpose. - Description string `json:"description"` - - // ID is the unique ID of the region. - ID string `json:"id"` - - // Extra is a collection of miscellaneous key/values. - Extra map[string]interface{} `json:"-"` - - // Links contains referencing links to the region. - Links map[string]interface{} `json:"links"` - - // ParentRegionID is the ID of the parent region. - ParentRegionID string `json:"parent_region_id"` -} - -func (r *Region) UnmarshalJSON(b []byte) error { - type tmp Region - var s struct { - tmp - Extra map[string]interface{} `json:"extra"` - } - err := json.Unmarshal(b, &s) - if err != nil { - return err - } - *r = Region(s.tmp) - - // Collect other fields and bundle them into Extra - // but only if a field titled "extra" wasn't sent. - if s.Extra != nil { - r.Extra = s.Extra - } else { - var result interface{} - err := json.Unmarshal(b, &result) - if err != nil { - return err - } - if resultMap, ok := result.(map[string]interface{}); ok { - r.Extra = internal.RemainingKeys(Region{}, resultMap) - } - } - - return err -} - -type regionResult struct { - gophercloud.Result -} - -// GetResult is the response from a Get operation. Call its Extract method -// to interpret it as a Region. -type GetResult struct { - regionResult -} - -// CreateResult is the response from a Create operation. Call its Extract method -// to interpret it as a Region. -type CreateResult struct { - regionResult -} - -// UpdateResult is the response from an Update operation. Call its Extract -// method to interpret it as a Region. -type UpdateResult struct { - regionResult -} - -// DeleteResult is the response from a Delete operation. Call its ExtractErr to -// determine if the request succeeded or failed. -type DeleteResult struct { - gophercloud.ErrResult -} - -// RegionPage is a single page of Region results. -type RegionPage struct { - pagination.LinkedPageBase -} - -// IsEmpty determines whether or not a page of Regions contains any results. -func (r RegionPage) IsEmpty() (bool, error) { - regions, err := ExtractRegions(r) - return len(regions) == 0, err -} - -// NextPageURL extracts the "next" link from the links section of the result. -func (r RegionPage) NextPageURL() (string, error) { - var s struct { - Links struct { - Next string `json:"next"` - Previous string `json:"previous"` - } `json:"links"` - } - err := r.ExtractInto(&s) - if err != nil { - return "", err - } - return s.Links.Next, err -} - -// ExtractRegions returns a slice of Regions contained in a single page of results. -func ExtractRegions(r pagination.Page) ([]Region, error) { - var s struct { - Regions []Region `json:"regions"` - } - err := (r.(RegionPage)).ExtractInto(&s) - return s.Regions, err -} - -// Extract interprets any region results as a Region. -func (r regionResult) Extract() (*Region, error) { - var s struct { - Region *Region `json:"region"` - } - err := r.ExtractInto(&s) - return s.Region, err -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/urls.go deleted file mode 100644 index 150ecc8358..0000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/regions/urls.go +++ /dev/null @@ -1,23 +0,0 @@ -package regions - -import "github.com/gophercloud/gophercloud" - -func listURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("regions") -} - -func getURL(client *gophercloud.ServiceClient, regionID string) string { - return client.ServiceURL("regions", regionID) -} - -func createURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("regions") -} - -func updateURL(client *gophercloud.ServiceClient, regionID string) string { - return client.ServiceURL("regions", regionID) -} - -func deleteURL(client *gophercloud.ServiceClient, regionID string) string { - return client.ServiceURL("regions", regionID) -}