-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for file projection in run
command
#141
Conversation
What are the semantics of I feel like perhaps we want to approach this in a way that doesn't require a new top level special key? Is there any option for that? Where we could somehow have the consumer ( |
The lack of an "end time" is why I focused on |
I agree with this, FWIW. I'll take a look at this PR today or tomorrow. I have a feeling that I'm going to need to give it some bake time. One aside--I suspect is that it will be a best practice to define things like the contents of the kubeconfig in a "normal" value, then reference that from projections. Maybe I'm wrong about that but it smells promising to me, as the definition can then be shared around various projections as necessary. In this case that might mean defining the files:
KUBECONFIG: ${kubeconfig} |
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.
Overall idea looks great--just one comment on also writing these files in open
when --format
is shell
or dotenv
.
if files, ok := env.Properties["files"].Value.(map[string]esc.Value); ok { | ||
for k, v := range files { | ||
if strValue, ok := v.Value.(string); ok { | ||
file, err := writeTempFile(strValue) | ||
if err != nil { | ||
return err | ||
} | ||
defer func() { | ||
rmErr := envcmd.esc.fs.Remove(file) | ||
contract.IgnoreError(rmErr) | ||
}() | ||
|
||
environ = append(environ, fmt.Sprintf("%v=%v", k, file)) | ||
} | ||
} | ||
} |
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 think that we should also write these files in open
for --format=shell
and --format=dotenv
.
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.
(LMK if you want to have a go at that. if not we can take this as-is and add support for open
in a subsequent PR)
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 would prefer that we tackle it in a follow-up, to keep this PR as focused as possible.
Do we want to stick with |
Personally I'm good with |
7b2db17
to
af83524
Compare
af83524
to
3ab74cd
Compare
Overview
This PR adds support for projecting configuration properties as temporary files, based on a new well-known block called
files
. For each property, a temporary file is created containing the property value, and an environment variable is set pointing to the temporary file. Note that the file contents may be dynamically generated using interpolation.Example
This feature is designed for a key scenario of projecting a
kubeconfig
file based on a Pulumi environment. Here's how that would work:Define an environment:
Run the environment and observe there's a
KUBECONFIG
environment variable that points to a temporary file containing the desired configuration:$ esc run -i eron-kubernetes-test -- sh -c 'cat $KUBECONFIG' apiVersion: v1 clusters: - cluster: ...
This enables: