-
Notifications
You must be signed in to change notification settings - Fork 70
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
Container file resource #116
Container file resource #116
Conversation
addc661
to
c3a8592
Compare
I'm wondering why you want to move the file subresource to a seperate resource resource "lxd_container" "container1" {
name = "foobar"
image = "images:alpine/3.5"
profiles = ["default"]
}
resource "lxd_container_file" "file1" {
container_name = "${lxd_container.container1.name}"
remote = "${lxd_container.container1.remote}"
target_file = "/foo/bar.txt"
content = "Hello, World!\n"
create_directories = true
} vs resource "lxd_container" "container1" {
name = "foobar"
image = "images:alpine/3.5/amd64"
profiles = ["default"]
file {
target_file = "/foo/bar.txt"
content = "Hello, World!\n"
create_directories = true
}
} |
@mjrider See my comments in #112 Additionally, when a resource has "sub-resources" that tend to have a one-to-many relationship, they always work better as separate resources in the long term. For example, by having a separate file resource, the file can be treated as a first-class resource and have dedicated |
What would be the problem you see with keeping the original embedded file sub resource along side the standalone resource? |
This commit adds the lxd_container_file resource which can be used to manage individual files in a container.
c3a8592
to
e8d77b6
Compare
Rebased and docs added. |
@jtopjian what do you think about sl1pm4t suggestion for keeping the subresource version , so users can have a choice in what they need/want |
@mjrider That was my intention all along 😄 |
FWIW, I don't mind having only a separate resource. |
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.
LGTM with one tiny typo found.
lxd/shared.go
Outdated
func containerDeleteFile(server lxd.ContainerServer, container string, targetFile string) error { | ||
targetFile, err := filepath.Abs(targetFile) | ||
if err != nil { | ||
return fmt.Errorf("Could not santize destination target %s", targetFile) |
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.
typo - santize
-> sanitize
Sorry for the confusion, when I read through the PR comments on my phone I somehow got the impression you were removing the embedded resource. Might be because there was another PR for deprecated a resource, and I confused the two. Anyway it looks good to me. |
No problem at all! I detailed my plans for this in #112. I should have added those notes here as well, so it's my fault for the confusion. Thank you for catching the typo. |
This commit adds the lxd_container_file resource which can be used
to manage individual files in a container.
This depends on #112
I can rebase afterwards or all 3 commits can be merged here.
Can also add docs once #114 is added.