-
Notifications
You must be signed in to change notification settings - Fork 3
implement first pass at cached image data source #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
image, err := envbuilder.RunCacheProbe(ctx, opts) | ||
data.Exists = types.BoolValue(err == nil) | ||
if err != nil { | ||
resp.Diagnostics.AddWarning("Cached image not found", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: only add the warning if it is an apply
, otherwise you get this on terraform plan
:
Plan: 5 to add, 0 to change, 0 to destroy.
╷
│ Warning: Cached image not found
│
│ with data.envbuilder_cached_image.cached,
│ on main.tf line 121, in data "envbuilder_cached_image" "cached":
│ 121: data "envbuilder_cached_image" "cached" {
│
│ --cache-repo must be set when using --get-cached-image
╵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stellar work! ⭐
|
||
.PHONY: update-envbuilder-version | ||
update-envbuilder-version: | ||
go get github.com/coder/envbuilder@main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to update to main or would it be better to default to the latest release version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure what we'll want right now. Let's leave it at main for now and maybe later we can specify a particular version if needed.
tflog.Info(ctx, "set kaniko dir to "+tmpKanikoDir) | ||
defer func() { | ||
kconfig.KanikoDir = oldKanikoDir | ||
tflog.Info(ctx, "restored kaniko dir to "+oldKanikoDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to restore? I'm not saying we should remove it, just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not, but better safe than sorry
opts := eboptions.Options{ | ||
// These options are always required | ||
CacheRepo: data.CacheRepo.ValueString(), | ||
Filesystem: osfs.New("/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe? Should we use the tmpdir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only really matters for the git cloning
InitScript: "", | ||
LayerCacheDir: "", | ||
PostStartScriptPath: "", | ||
PushImage: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIR we conditionally append instructions to the Dockerfile if push image is used, we should make sure we don't get a cache miss due to this. Potentially we should append the instructions always if GetCachedImage: true
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related: #5
Closes #1
Implements reading a cached image data source using
envbuilder.RunCacheProbe
I'm just testing with one Terraform version for now. Later on I want to extract the existing 'happy-path' provider test into a separate integration test.
Note: when seeding the cache, I explicitly do not set
PUSH_IMAGE
to work around an issue with envbuilder creating files owned by root:root. I plan to address this later on by running the provider inside a container, which should work around this issue.