Skip to content

Commit

Permalink
azurerm_container_app - support for the add sub_path property (#27533)
Browse files Browse the repository at this point in the history
* add sub_path property to container app volume_mount

* Update internal/services/containerapps/container_app_resource_test.go

* Update internal/services/containerapps/helpers/container_apps.go

Co-authored-by: jackofallops <[email protected]>

---------

Co-authored-by: Stergios Gemelas <[email protected]>
Co-authored-by: kt <[email protected]>
Co-authored-by: jackofallops <[email protected]>
  • Loading branch information
4 people authored Feb 7, 2025
1 parent 000440f commit acd0890
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ resource "azurerm_container_app" "test" {
volume_mounts {
name = azurerm_container_app_environment_storage.test.name
path = "/tmp/testdata"
sub_path = "subdirectory"
}
}
Expand All @@ -1372,8 +1373,9 @@ resource "azurerm_container_app" "test" {
cpu = 0.25
memory = "0.5Gi"
volume_mounts {
name = azurerm_container_app_environment_storage.test.name
path = "/tmp/testdata"
name = azurerm_container_app_environment_storage.test.name
path = "/tmp/testdata"
sub_path = "subdirectory"
}
}
Expand Down
24 changes: 20 additions & 4 deletions internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -1533,8 +1533,9 @@ func flattenContainerAppVolumes(input *[]containerapps.Volume) []ContainerVolume
}

type ContainerVolumeMount struct {
Name string `tfschema:"name"`
Path string `tfschema:"path"`
Name string `tfschema:"name"`
Path string `tfschema:"path"`
SubPath string `tfschema:"sub_path"`
}

func ContainerVolumeMountSchema() *pluginsdk.Schema {
Expand All @@ -1556,6 +1557,13 @@ func ContainerVolumeMountSchema() *pluginsdk.Schema {
ValidateFunc: validation.StringIsNotEmpty,
Description: "The path in the container at which to mount this volume.",
},

"sub_path": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Description: "The sub path of the volume to be mounted in the container.",
},
},
},
}
Expand All @@ -1578,6 +1586,12 @@ func ContainerVolumeMountSchemaComputed() *pluginsdk.Schema {
Computed: true,
Description: "The path in the container at which to mount this volume.",
},

"sub_path": {
Type: pluginsdk.TypeString,
Computed: true,
Description: "The sub path of the volume to be mounted in the container.",
},
},
},
}
Expand All @@ -1593,6 +1607,7 @@ func expandContainerVolumeMounts(input []ContainerVolumeMount) *[]containerapps.
volumeMounts = append(volumeMounts, containerapps.VolumeMount{
MountPath: pointer.To(v.Path),
VolumeName: pointer.To(v.Name),
SubPath: pointer.To(v.SubPath),
})
}

Expand All @@ -1607,8 +1622,9 @@ func flattenContainerVolumeMounts(input *[]containerapps.VolumeMount) []Containe
result := make([]ContainerVolumeMount, 0)
for _, v := range *input {
result = append(result, ContainerVolumeMount{
Name: pointer.From(v.VolumeName),
Path: pointer.From(v.MountPath),
Name: pointer.From(v.VolumeName),
Path: pointer.From(v.MountPath),
SubPath: pointer.From(v.SubPath),
})
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/d/container_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ A `volume_mounts` block supports the following:

* `path` - The path in the container at which to mount this volume.

* `sub_path` - The sub path of the volume to be mounted in the container.
---

An `identity` block supports the following:
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/container_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ A `volume_mounts` block supports the following:

* `path` - (Required) The path in the container at which to mount this volume.

* `sub_path` - (Optional) The sub path of the volume to be mounted in the container.
---

An `identity` block supports the following:
Expand Down

0 comments on commit acd0890

Please sign in to comment.