mirror of
https://github.com/coder/terraform-provider-envbuilder.git
synced 2025-09-08 09:47:15 +00:00
make gen and fix tests
This commit is contained in:
parent
d69f78b321
commit
9b686f9b08
4 changed files with 12 additions and 7 deletions
docs/resources
internal/provider
|
@ -25,6 +25,7 @@ The cached image resource can be used to retrieve a cached image produced by env
|
|||
|
||||
- `base_image_cache_dir` (String) (Envbuilder option) The path to a directory where the base image can be found. This should be a read-only directory solely mounted for the purpose of caching the base image.
|
||||
- `build_context_path` (String) (Envbuilder option) Can be specified when a DockerfilePath is specified outside the base WorkspaceFolder. This path MUST be relative to the WorkspaceFolder path into which the repo is cloned.
|
||||
- `build_secrets` (Map of String) The secrets to use for the build. This is a map of key-value pairs.
|
||||
- `cache_ttl_days` (Number) (Envbuilder option) The number of days to use cached layers before expiring them. Defaults to 7 days.
|
||||
- `devcontainer_dir` (String) (Envbuilder option) The path to the folder containing the devcontainer.json file that will be used to build the workspace and can either be an absolute path or a path relative to the workspace folder. If not provided, defaults to `.devcontainer`.
|
||||
- `devcontainer_json_path` (String) (Envbuilder option) The path to a devcontainer.json file that is either an absolute path or a path relative to DevcontainerDir. This can be used in cases where one wants to substitute an edited devcontainer.json file for the one that exists in the repo.
|
||||
|
|
|
@ -122,6 +122,11 @@ func (r *CachedImageResource) Schema(ctx context.Context, req resource.SchemaReq
|
|||
MarkdownDescription: "(Envbuilder option) Can be specified when a DockerfilePath is specified outside the base WorkspaceFolder. This path MUST be relative to the WorkspaceFolder path into which the repo is cloned.",
|
||||
Optional: true,
|
||||
},
|
||||
"build_secrets": schema.MapAttribute{
|
||||
MarkdownDescription: "The secrets to use for the build. This is a map of key-value pairs.",
|
||||
ElementType: types.StringType,
|
||||
Optional: true,
|
||||
},
|
||||
"cache_ttl_days": schema.Int64Attribute{
|
||||
MarkdownDescription: "(Envbuilder option) The number of days to use cached layers before expiring them. Defaults to 7 days.",
|
||||
Optional: true,
|
||||
|
|
|
@ -2,6 +2,7 @@ package provider
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
eboptions "github.com/coder/envbuilder/options"
|
||||
|
@ -58,6 +59,7 @@ func optionsFromDataModel(data CachedImageResourceModel) (eboptions.Options, dia
|
|||
for k, v := range buildSecretMap {
|
||||
buildSecretSlice = append(buildSecretSlice, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
slices.Sort(buildSecretSlice)
|
||||
|
||||
opts.BuildSecrets = buildSecretSlice
|
||||
}
|
||||
|
@ -214,7 +216,7 @@ func overrideOptionsFromExtraEnv(opts *eboptions.Options, extraEnv map[string]st
|
|||
|
||||
// XXX: workaround for serpent behaviour where calling Set() on a
|
||||
// string slice will append instead of replace: set to empty first.
|
||||
if key == "ENVBUILDER_IGNORE_PATHS" {
|
||||
if _, ok := optsMap[key].(*serpent.StringArray); ok {
|
||||
_ = optsMap[key].Set("")
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ func Test_optionsFromDataModel(t *testing.T) {
|
|||
GitURL: "git@git.local/devcontainer.git",
|
||||
BaseImageCacheDir: "/tmp/cache",
|
||||
BuildContextPath: ".",
|
||||
BuildSecrets: []string{"FOO=bar", "BAZ=qux"},
|
||||
BuildSecrets: []string{"BAZ=qux", "FOO=bar"}, // Sorted
|
||||
CacheTTLDays: 7,
|
||||
DevcontainerDir: ".devcontainer",
|
||||
DevcontainerJSONPath: ".devcontainer/devcontainer.json",
|
||||
|
@ -96,11 +96,8 @@ func Test_optionsFromDataModel(t *testing.T) {
|
|||
name: "extra env override",
|
||||
data: CachedImageResourceModel{
|
||||
BuilderImage: basetypes.NewStringValue("envbuilder:latest"),
|
||||
BuildSecrets: basetypes.NewMapValueMust(basetypes.StringType{}, map[string]attr.Value{
|
||||
"FOO": basetypes.NewStringValue("bar"),
|
||||
}),
|
||||
CacheRepo: basetypes.NewStringValue("localhost:5000/cache"),
|
||||
GitURL: basetypes.NewStringValue("git@git.local/devcontainer.git"),
|
||||
CacheRepo: basetypes.NewStringValue("localhost:5000/cache"),
|
||||
GitURL: basetypes.NewStringValue("git@git.local/devcontainer.git"),
|
||||
ExtraEnv: extraEnvMap(t,
|
||||
"CODER_AGENT_TOKEN", "token",
|
||||
"CODER_AGENT_URL", "http://coder",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue