mirror of
https://github.com/coder/terraform-provider-envbuilder.git
synced 2025-10-09 00:40:19 +00:00
feat: convert datasource to resource (#15)
- Convert datasource to resource - Update examples - Update tests
This commit is contained in:
parent
abf099bf53
commit
ad8b1fda9e
8 changed files with 528 additions and 302 deletions
docs/resources
|
@ -1,32 +1,16 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "envbuilder_cached_image Data Source - envbuilder"
|
||||
page_title: "envbuilder_cached_image Resource - envbuilder"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
The cached image data source can be used to retrieve a cached image produced by envbuilder. Reading from this data source will clone the specified Git repository, read a Devcontainer specification or Dockerfile, and check for its presence in the provided cache repo.
|
||||
The cached image resource can be used to retrieve a cached image produced by envbuilder. Creating this resource will clone the specified Git repository, read a Devcontainer specification or Dockerfile, and check for its presence in the provided cache repo. If any of the layers of the cached image are missing in the provided cache repo, the image will be considered as missing. A cached image in this state will be recreated until found.
|
||||
---
|
||||
|
||||
# envbuilder_cached_image (Data Source)
|
||||
# envbuilder_cached_image (Resource)
|
||||
|
||||
The cached image data source can be used to retrieve a cached image produced by envbuilder. Reading from this data source will clone the specified Git repository, read a Devcontainer specification or Dockerfile, and check for its presence in the provided cache repo.
|
||||
The cached image resource can be used to retrieve a cached image produced by envbuilder. Creating this resource will clone the specified Git repository, read a Devcontainer specification or Dockerfile, and check for its presence in the provided cache repo. If any of the layers of the cached image are missing in the provided cache repo, the image will be considered as missing. A cached image in this state will be recreated until found.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "envbuilder_cached_image" "example" {
|
||||
builder_image = "ghcr.io/coder/envbuilder:latest"
|
||||
git_url = "https://github.com/coder/envbuilder-starter-devcontainer"
|
||||
cache_repo = "localhost:5000/local/test-cache"
|
||||
extra_env = {
|
||||
"ENVBUILDER_VERBOSE" : "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "docker_container" "container" {
|
||||
image = envbuilder_cached_image.example.image
|
||||
env = data.envbuilder_image.cached.env
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
@ -63,7 +47,7 @@ resource "docker_container" "container" {
|
|||
|
||||
### Read-Only
|
||||
|
||||
- `env` (List of String) Computed envbuilder configuration to be set for the container.
|
||||
- `env` (List of String, Sensitive) Computed envbuilder configuration to be set for the container. May contain secrets.
|
||||
- `exists` (Boolean) Whether the cached image was exists or not for the given config.
|
||||
- `id` (String) Cached image identifier. This will generally be the image's SHA256 digest.
|
||||
- `image` (String) Outputs the cached image repo@digest if it exists, and builder image otherwise.
|
Loading…
Add table
Add a link
Reference in a new issue