Skip to content

Commit

Permalink
Merge pull request juju#13074 from hpidcock/fix-lxd-remotes
Browse files Browse the repository at this point in the history
juju#13074

This change fixes lxd cloud and credential discovery with snap lxd.
It also fixes credential discovery/matching for builtin lxd clouds.

## QA steps

Test localhost/lxd bootstrap
```
snap install lxd
juju bootstrap localhost # and lxd
```

Test bootstrapping remote cluster
```
lxc remote add mylxd 10.10.10.10
juju clouds # should show mylxd as a builtin lxd cloud
juju bootstrap mylxd
```

## Documentation changes

Updates required to lxd documentation.

## Bug reference

N/A
  • Loading branch information
jujubot authored Jun 16, 2021
2 parents 211efbc + 8a61933 commit 81b7632
Show file tree
Hide file tree
Showing 54 changed files with 1,097 additions and 755 deletions.
2 changes: 1 addition & 1 deletion caas/kubernetes/provider/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (environProviderCredentials) CredentialSchemas() map[cloud.AuthType]cloud.C
}

// DetectCredentials is part of the environs.ProviderCredentials interface.
func (environProviderCredentials) DetectCredentials() (*cloud.CloudCredential, error) {
func (environProviderCredentials) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
clientConfigFunc, err := clientconfig.NewClientConfigReader(constants.CAASProviderType)
if err != nil {
return nil, errors.Trace(err)
Expand Down
2 changes: 1 addition & 1 deletion caas/kubernetes/provider/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *credentialsSuite) TestDetectCredentials(c *gc.C) {
Name: "config",
Data: singleConfigYAML,
})
creds, err := s.provider.DetectCredentials()
creds, err := s.provider.DetectCredentials("")
c.Assert(err, jc.ErrorIsNil)
c.Assert(creds.DefaultRegion, gc.Equals, "")
expected := cloud.NewNamedCredential(
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/cloud/detectcredentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (c *detectCredentialsCommand) Run(ctxt *cmd.Context) error {
continue
}
if detectCredentials, ok := provider.(environs.ProviderCredentials); ok {
detected, err := detectCredentials.DetectCredentials()
detected, err := detectCredentials.DetectCredentials("")
if err != nil && !errors.IsNotFound(err) {
logger.Errorf("could not detect credentials for provider %q: %v", providerName, err)
continue
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/cloud/detectcredentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type mockProvider struct {
credSchemas *map[jujucloud.AuthType]jujucloud.CredentialSchema
}

func (p *mockProvider) DetectCredentials() (*jujucloud.CloudCredential, error) {
func (p *mockProvider) DetectCredentials(cloudName string) (*jujucloud.CloudCredential, error) {
if len(p.detectedCreds.AuthCredentials) == 0 {
return nil, errors.NotFoundf("credentials")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/juju/commands/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ func (noCredentialsProvider) DetectRegions() ([]cloud.Region, error) {
return []cloud.Region{{Name: "region"}}, nil
}

func (noCredentialsProvider) DetectCredentials() (*cloud.CloudCredential, error) {
func (noCredentialsProvider) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
return nil, errors.NotFoundf("credentials")
}

Expand All @@ -2400,7 +2400,7 @@ func (manyCredentialsProvider) DetectRegions() ([]cloud.Region, error) {
return []cloud.Region{{Name: "region"}}, nil
}

func (manyCredentialsProvider) DetectCredentials() (*cloud.CloudCredential, error) {
func (manyCredentialsProvider) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
return &cloud.CloudCredential{
AuthCredentials: map[string]cloud.Credential{
"one": cloud.NewCredential("one", nil),
Expand All @@ -2426,7 +2426,7 @@ func (f fileCredentialProvider) DetectRegions() ([]cloud.Region, error) {
return []cloud.Region{{Name: "region"}}, nil
}

func (f fileCredentialProvider) DetectCredentials() (*cloud.CloudCredential, error) {
func (f fileCredentialProvider) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
credential := cloud.NewCredential(cloud.JSONFileAuthType,
map[string]string{"file": f.testFileName})
cc := &cloud.CloudCredential{AuthCredentials: map[string]cloud.Credential{
Expand Down
70 changes: 44 additions & 26 deletions cmd/juju/common/cloudprovider_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions cmd/juju/common/credentialstore_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/juju/controller/addmodel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ type fakeProvider struct {
detected *cloud.CloudCredential
}

func (p *fakeProvider) DetectCredentials() (*cloud.CloudCredential, error) {
func (p *fakeProvider) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
p.MethodCall(p, "DetectCredentials")
return p.detected, p.NextErr()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/modelcmd/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ type mockEnvironProvider struct {
environs.EnvironProvider
}

func (p *mockEnvironProvider) DetectCredentials() (*cloud.CloudCredential, error) {
func (p *mockEnvironProvider) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
return cloud.NewEmptyCloudCredential(), nil
}

Expand Down
Loading

0 comments on commit 81b7632

Please sign in to comment.