forked from juju/terraform-provider-juju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(update-app-base): add support to update
base
for application c…
…harms This PR adds support to update the base in application charms by requiring a replace in case of a machine charm, and perform the upgrade in case of a k8s charm. re juju#635
- Loading branch information
1 parent
fbd1ccc
commit 19c361e
Showing
4 changed files
with
120 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,37 @@ func TestAcc_CharmUpdates(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAcc_CharmUpdateBase(t *testing.T) { | ||
modelName := acctest.RandomWithPrefix("tf-test-charmbaseupdates") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: frameworkProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccApplicationUpdateBaseCharm(modelName, "[email protected]"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("juju_application.this", "charm.0.base", "[email protected]"), | ||
), | ||
}, | ||
{ | ||
// move to base ubuntu 22 | ||
Config: testAccApplicationUpdateBaseCharm(modelName, "[email protected]"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("juju_application.this", "charm.0.base", "[email protected]"), | ||
), | ||
}, | ||
{ | ||
// move back to latest/stable | ||
Config: testAccApplicationUpdateBaseCharm(modelName, "[email protected]"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("juju_application.this", "charm.0.base", "[email protected]"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAcc_ResourceRevisionUpdatesLXD(t *testing.T) { | ||
if testingCloud != LXDCloudTesting { | ||
t.Skip(t.Name() + " only runs with LXD") | ||
|
@@ -1021,6 +1052,41 @@ func testAccResourceApplicationUpdatesCharm(modelName string, channel string) st | |
} | ||
} | ||
|
||
func testAccApplicationUpdateBaseCharm(modelName string, base string) string { | ||
if testingCloud == LXDCloudTesting { | ||
return fmt.Sprintf(` | ||
resource "juju_model" "this" { | ||
name = %q | ||
} | ||
resource "juju_application" "this" { | ||
model = juju_model.this.name | ||
name = "test-app" | ||
charm { | ||
name = "ubuntu" | ||
base = %q | ||
} | ||
} | ||
`, modelName, base) | ||
} else { | ||
return fmt.Sprintf(` | ||
resource "juju_model" "this" { | ||
name = %q | ||
} | ||
resource "juju_application" "this" { | ||
model = juju_model.this.name | ||
name = "test-app" | ||
charm { | ||
name = "coredns" | ||
channel = "1.25/stable" | ||
base = %q | ||
} | ||
} | ||
`, modelName, base) | ||
} | ||
} | ||
|
||
// testAccResourceApplicationConstraints will return two set for constraint | ||
// applications. The version to be used in K8s sets the juju-external-hostname | ||
// because we set the expose parameter. | ||
|