-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Importing a model owned by a local Juju user requires the use of the --switch-owner CLI flag to change the model owner in jimm to a new external user. This change doesn't propagate to the Juju controller so there needs to be a lot of complex logic to ensure we replace all results containing the old user with the new one. That was not being done and as a result, things like listing application offers were not working. This change allows models created by local Juju users to keep their model owner tag in JIMM. Although JIMM normally deals with external users, there is no reason it can't also hold local users for cases of model imports. To handle the cloud-credential of an imported model where JIMM is not aware of the local user's credentials, we allow the value of the cloud-credential in JIMM to be nil. This works out because we fetch model info from the controller anyway.
- Loading branch information
Showing
19 changed files
with
110 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ func TestControllerModels(t *testing.T) { | |
Owner: u1, | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
} | ||
c.Assert(db.Create(&m1).Error, qt.IsNil) | ||
u2, err := dbmodel.NewIdentity("[email protected]") | ||
|
@@ -103,7 +103,7 @@ func TestControllerModels(t *testing.T) { | |
Owner: *u2, | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
} | ||
c.Assert(db.Create(&m2).Error, qt.IsNil) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ func TestRecreateDeletedModel(t *testing.T) { | |
Name: "test-1", | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
} | ||
c.Assert(db.Create(&m1).Error, qt.IsNil) | ||
|
||
|
@@ -55,7 +55,7 @@ func TestRecreateDeletedModel(t *testing.T) { | |
Name: "test-1", | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
} | ||
c.Check(db.Create(&m2).Error, qt.ErrorMatches, `.*violates unique constraint "unique_model_names".*`) | ||
|
||
|
@@ -78,7 +78,7 @@ func TestModel(t *testing.T) { | |
Owner: u, | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
Life: state.Alive.String(), | ||
} | ||
c.Assert(db.Create(&m).Error, qt.IsNil) | ||
|
@@ -131,7 +131,7 @@ func TestModelUniqueConstraint(t *testing.T) { | |
Owner: u, | ||
Controller: ctl1, | ||
CloudRegion: cl1.Regions[0], | ||
CloudCredential: cred1, | ||
CloudCredential: &cred1, | ||
Life: state.Alive.String(), | ||
} | ||
c.Assert(db.Create(&m1).Error, qt.IsNil) | ||
|
@@ -145,7 +145,7 @@ func TestModelUniqueConstraint(t *testing.T) { | |
Owner: u, | ||
Controller: ctl2, | ||
CloudRegion: cl2.Regions[0], | ||
CloudCredential: cred2, | ||
CloudCredential: &cred2, | ||
Life: state.Alive.String(), | ||
} | ||
c.Assert(db.Create(&m2).Error, qt.ErrorMatches, `ERROR: duplicate key value violates unique constraint .*`) | ||
|
@@ -178,7 +178,7 @@ func TestToJujuModel(t *testing.T) { | |
Owner: u, | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
Life: state.Alive.String(), | ||
} | ||
m.CloudRegion.Cloud = cl | ||
|
@@ -205,7 +205,7 @@ func TestToJujuModelSummary(t *testing.T) { | |
Owner: u, | ||
Controller: ctl, | ||
CloudRegion: cl.Regions[0], | ||
CloudCredential: cred, | ||
CloudCredential: &cred, | ||
Life: state.Alive.String(), | ||
} | ||
m.CloudRegion.Cloud = cl | ||
|
@@ -376,11 +376,7 @@ func TestModelFromJujuModelInfo(t *testing.T) { | |
Name: "test-cloud", | ||
}, | ||
}, | ||
CloudCredential: dbmodel.CloudCredential{ | ||
Name: "test-cred", | ||
CloudName: "test-cloud", | ||
Owner: *i, | ||
}, | ||
CloudCredential: nil, | ||
OwnerIdentityName: "[email protected]", | ||
Life: state.Alive.String(), | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.