Skip to content

Commit

Permalink
Address review comments to update to latest resource revision upon ch…
Browse files Browse the repository at this point in the history
…annel updates

Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Jul 2, 2024
1 parent 89f16d6 commit 2b8c852
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 244 deletions.
41 changes: 19 additions & 22 deletions docs/resources/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "juju_application" "placement_example" {
}
resource "juju_application" "custom_resources_example" {
name = "placement-example"
name = "custom-resource-example"
model = juju_model.development.name
charm {
name = "hello-kubecon"
Expand Down Expand Up @@ -85,28 +85,25 @@ resource "juju_application" "custom_resources_example" {
- `expose` (Block List) Makes an application publicly available over the network (see [below for nested schema](#nestedblock--expose))
- `name` (String) A custom name for the application deployment. If empty, uses the charm's name.
- `placement` (String) Specify the target location for the application's units
- `resources` (Map of String) Charm resource revisions. Must evaluate to a string. A resource could be a resource revision number or a custom resource.
- `resources` (Map of String) Charm resources. Must evaluate to a string. A resource could be a resource revision number from CharmHub or a custom OCI image resource.
There are a few scenarios that need to be considered:
* If the plan does not specify a resource and resources are added to the plan (as a revision number or a custom resource), specified resources are attached to the application (equivalent to juju attach-resource).
* If the plan does specify resource revisions and if the charm revision or channel is updated, existing resources are kept. (Resources are not detached)
* If the plan does specify resource revisions and resources are removed from the plan:
- If charm revision/channel is updated, the resources associated with the updated charm revision or channel is attached.
- If the charm revision/channel are not updated then the resources associated with the existing charm revision/channel are attached.
* Charm could be deployed without resource, then resource could be added later.
* Resources could be provided in the following formats:
- A custom repository URL
- A files ends with .txt, .json or .yaml
- A resource revision from CharmHub
* Charm could be deployed with resources.
* If the provided resource revision does not exist during initial deployment or update, Client does not start deployment with an error that resource was not found in the store.
* If the provided custom resource does not exist during initial deployment or update, Client start deployment and charm could not be deployed properly and charm will be in error state.
* If the Provided resource type is not correct then Client fails with incorrect resource error for below scenarios:
- An image is expected but file does not include image URL
- A plain text file is expected but a .json file is provided.
* If the provided resource does not exist then Client fails with path is not valid error.
* Changing resources from a file to an int or string does not create any issue. Resources are processed smoothly.
- If provided resource value is changed from an int to a file then the image resource from the file is attached.
- If provided resource value is changed from a file to an int then image revision is attached.
* Charms could be deployed with specifying the resources (from CharmHub or an OCI image repository). If the resources are not specified, the resources which are associated with the Charm in the CharmHub are used.
Resource inputs are provided in a string format.
- Resource revision number from CharmHub (string)
- OCI image information as a URL (string)
- A path of json or yaml file which includes OCI image repository information (string)
* Changing resource input from a revision to a custom OCI resource is processed and updated smoothly according to the provided input.
* Resources could be added to the Terraform plan after deployment.
- If the resources are added to the plan (as a revision number or a custom OCI image resource), specified resources are attached to the application (equivalent to juju attach-resource).
* Charm which includes resources could be updated.
If the plan does specify resource revisions from CharmHub:
- if the charm channel is updated, resources get updated to the latest revision associated with the updated channel.
If the plan does specify custom OCI image resources:
- if the charm channel is updated, existing resources are kept. (Resources are not detached)
* Resources could be removed from the Terraform plan.
If the plan does specify resource revisions from CharmHub or custom OCI images, then resources are removed from the plan:
- If the charm channel is updated, resources get updated to the latest revision associated with the updated charm channel.
- If the charm channel is not updated then the resources get updated to the latest revision associated with the existing charm channel.
- `trust` (Boolean) Set the trust for the application.
- `units` (Number) The number of application units to deploy for the charm.

Expand Down
2 changes: 1 addition & 1 deletion examples/resources/juju_application/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "juju_application" "placement_example" {
}

resource "juju_application" "custom_resources_example" {
name = "placement-example"
name = "custom-resource-example"
model = juju_model.development.name
charm {
name = "hello-kubecon"
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ require (
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
Expand Down
Loading

0 comments on commit 2b8c852

Please sign in to comment.