Skip to content

Commit 4210f12

Browse files
committed
Removes SupportsProviderSpaces from environs.Networking and
implementations. This method is not actualy required as it is congruent with SupportSpaceDiscovery, which is used instead.
1 parent 89792fe commit 4210f12

File tree

12 files changed

+220
-92
lines changed

12 files changed

+220
-92
lines changed

apiserver/facades/client/spaces/package_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (s *APISuite) SetupMocks(c *gc.C, supportSpaces bool, providerSpaces bool)
7676

7777
mockNetworkEnviron := environmocks.NewMockNetworkingEnviron(ctrl)
7878
mockNetworkEnviron.EXPECT().SupportsSpaces(gomock.Any()).Return(supportSpaces, nil).AnyTimes()
79-
mockNetworkEnviron.EXPECT().SupportsProviderSpaces(gomock.Any()).Return(providerSpaces, nil).AnyTimes()
79+
mockNetworkEnviron.EXPECT().SupportsSpaceDiscovery(gomock.Any()).Return(providerSpaces, nil).AnyTimes()
8080

8181
mockProvider := environmocks.NewMockCloudEnvironProvider(ctrl)
8282
mockProvider.EXPECT().Open(gomock.Any()).Return(mockNetworkEnviron, nil).AnyTimes()

apiserver/facades/client/spaces/spaces.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,20 @@ func (api *API) ensureSpacesAreMutable() error {
531531
func (api *API) ensureSpacesNotProviderSourced() error {
532532
env, err := environs.GetEnviron(api.backing, environs.New)
533533
if err != nil {
534-
return errors.Annotate(err, "getting environ")
534+
return errors.Annotate(err, "retrieving environ")
535+
}
536+
537+
netEnv, ok := env.(environs.NetworkingEnviron)
538+
if !ok {
539+
return errors.NotSupportedf("provider networking")
540+
}
541+
542+
providerSourced, err := netEnv.SupportsSpaceDiscovery(api.context)
543+
if err != nil {
544+
return errors.Trace(err)
535545
}
536-
if environs.SupportsProviderSpaces(api.context, env) {
546+
547+
if providerSourced {
537548
return errors.NotSupportedf("modifying provider-sourced spaces")
538549
}
539550
return nil

environs/mocks/package_mock.go

Lines changed: 2 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

environs/networking.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ type Networking interface {
4848
// unless a general API failure occurs.
4949
SupportsSpaces(ctx context.ProviderCallContext) (bool, error)
5050

51-
// SupportsProviderSpaces returns whether the current environment supports
52-
// provider spaces. Some providers support specific crud actions, like renaming.
53-
// The returned error satisfies errors.IsNotSupported(),
54-
// unless a general API failure occurs.
55-
SupportsProviderSpaces(ctx context.ProviderCallContext) (bool, error)
56-
5751
// SupportsSpaceDiscovery returns whether the current environment
5852
// supports discovering spaces from the provider. The returned error
5953
// satisfies errors.IsNotSupported(), unless a general API failure occurs.
@@ -147,23 +141,6 @@ func SupportsSpaces(ctx context.ProviderCallContext, env BootstrapEnviron) bool
147141
return ok
148142
}
149143

150-
// SupportsSpaces checks if the environment implements NetworkingEnviron
151-
// and also if it supports spaces.
152-
func SupportsProviderSpaces(ctx context.ProviderCallContext, env BootstrapEnviron) bool {
153-
netEnv, ok := supportsNetworking(env)
154-
if !ok {
155-
return false
156-
}
157-
ok, err := netEnv.SupportsProviderSpaces(ctx)
158-
if err != nil {
159-
if !errors.IsNotSupported(err) {
160-
logger.Errorf("checking model provider spaces support failed with: %v", err)
161-
}
162-
return false
163-
}
164-
return ok
165-
}
166-
167144
// SupportsContainerAddresses checks if the environment will let us allocate
168145
// addresses for containers from the host ranges.
169146
func SupportsContainerAddresses(ctx context.ProviderCallContext, env BootstrapEnviron) bool {

0 commit comments

Comments
 (0)