Skip to content

Commit 9b686f9

Browse files
committed
make gen and fix tests
1 parent d69f78b commit 9b686f9

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

docs/resources/cached_image.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The cached image resource can be used to retrieve a cached image produced by env
2525

2626
- `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.
2727
- `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.
28+
- `build_secrets` (Map of String) The secrets to use for the build. This is a map of key-value pairs.
2829
- `cache_ttl_days` (Number) (Envbuilder option) The number of days to use cached layers before expiring them. Defaults to 7 days.
2930
- `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`.
3031
- `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.

internal/provider/cached_image_resource.go

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ func (r *CachedImageResource) Schema(ctx context.Context, req resource.SchemaReq
122122
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.",
123123
Optional: true,
124124
},
125+
"build_secrets": schema.MapAttribute{
126+
MarkdownDescription: "The secrets to use for the build. This is a map of key-value pairs.",
127+
ElementType: types.StringType,
128+
Optional: true,
129+
},
125130
"cache_ttl_days": schema.Int64Attribute{
126131
MarkdownDescription: "(Envbuilder option) The number of days to use cached layers before expiring them. Defaults to 7 days.",
127132
Optional: true,

internal/provider/helpers.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package provider
22

33
import (
44
"fmt"
5+
"slices"
56
"strings"
67

78
eboptions "github.com/coder/envbuilder/options"
@@ -58,6 +59,7 @@ func optionsFromDataModel(data CachedImageResourceModel) (eboptions.Options, dia
5859
for k, v := range buildSecretMap {
5960
buildSecretSlice = append(buildSecretSlice, fmt.Sprintf("%s=%s", k, v))
6061
}
62+
slices.Sort(buildSecretSlice)
6163

6264
opts.BuildSecrets = buildSecretSlice
6365
}
@@ -214,7 +216,7 @@ func overrideOptionsFromExtraEnv(opts *eboptions.Options, extraEnv map[string]st
214216

215217
// XXX: workaround for serpent behaviour where calling Set() on a
216218
// string slice will append instead of replace: set to empty first.
217-
if key == "ENVBUILDER_IGNORE_PATHS" {
219+
if _, ok := optsMap[key].(*serpent.StringArray); ok {
218220
_ = optsMap[key].Set("")
219221
}
220222

internal/provider/provider_internal_test.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func Test_optionsFromDataModel(t *testing.T) {
7070
GitURL: "[email protected]/devcontainer.git",
7171
BaseImageCacheDir: "/tmp/cache",
7272
BuildContextPath: ".",
73-
BuildSecrets: []string{"FOO=bar", "BAZ=qux"},
73+
BuildSecrets: []string{"BAZ=qux", "FOO=bar"}, // Sorted
7474
CacheTTLDays: 7,
7575
DevcontainerDir: ".devcontainer",
7676
DevcontainerJSONPath: ".devcontainer/devcontainer.json",
@@ -96,11 +96,8 @@ func Test_optionsFromDataModel(t *testing.T) {
9696
name: "extra env override",
9797
data: CachedImageResourceModel{
9898
BuilderImage: basetypes.NewStringValue("envbuilder:latest"),
99-
BuildSecrets: basetypes.NewMapValueMust(basetypes.StringType{}, map[string]attr.Value{
100-
"FOO": basetypes.NewStringValue("bar"),
101-
}),
102-
CacheRepo: basetypes.NewStringValue("localhost:5000/cache"),
103-
GitURL: basetypes.NewStringValue("[email protected]/devcontainer.git"),
99+
CacheRepo: basetypes.NewStringValue("localhost:5000/cache"),
100+
GitURL: basetypes.NewStringValue("[email protected]/devcontainer.git"),
104101
ExtraEnv: extraEnvMap(t,
105102
"CODER_AGENT_TOKEN", "token",
106103
"CODER_AGENT_URL", "http://coder",

0 commit comments

Comments
 (0)