Skip to content
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

provider/archive support folders in output_path #8278

Merged
merged 3 commits into from
Aug 18, 2016
Merged

provider/archive support folders in output_path #8278

merged 3 commits into from
Aug 18, 2016

Conversation

nicolai86
Copy link
Contributor

@nicolai86 nicolai86 commented Aug 18, 2016

The archive provider right now relies on FileInfos Name() function, which only returns the base name of theoutput_path, ignoring any folders:

type FileInfo interface {
        Name() string       // base name of the file
        Size() int64        // length in bytes for regular files; system-dependent for others
        Mode() FileMode     // file mode bits
        ModTime() time.Time // modification time
        IsDir() bool        // abbreviation for Mode().IsDir()
        Sys() interface{}   // underlying data source (can return nil)
}

this PR changes to use the output_path directly, allowing archives to be placed in subfolders:

before:

resource "archive_file" "foo" {
  type                    = "zip"
  source_content          = "This is some content"
  source_content_filename = "content.txt"
  output_path             = "example/path/test.zip"
}

throws error that test.zip could not be found

after: creates test.zip in example/path.

FileInfo.Name() returns the basename of the output path, which forces you to
never place archives in subdirectories
@nicolai86 nicolai86 changed the title provider/archive support subdirectory output_paths provider/archive support folders in output_path Aug 18, 2016
@@ -95,9 +97,18 @@ func resourceArchiveFileRead(d *schema.ResourceData, meta interface{}) error {

func resourceArchiveFileUpdate(d *schema.ResourceData, meta interface{}) error {
archiveType := d.Get("type").(string)
outputPath := d.Get("output_path").(string)
output_path := d.Get("output_path").(string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not in favour of this. The camel case is the preferred in Go.

@nicolai86
Copy link
Contributor Author

@kwilczynski agreed. The file used both styles and I wanted a unique way to name the same thing. i can adjust it

@kwilczynski
Copy link
Contributor

@nicolai86 definitely something to fix, go for it :)

@nicolai86
Copy link
Contributor Author

@kwilczynski I've adjusted the variable name now.

@stack72
Copy link
Contributor

stack72 commented Aug 18, 2016

Hi @nicolai86

The PR looks good to me now :) The tests are green as expected:

% make testacc TEST=./builtin/providers/archive TESTARGS='-run=Test'                              1 ↵
==> Checking that code complies with gofmt requirements...
/Users/stacko/Code/go/bin/stringer
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/18 16:33:50 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/archive -v -run=Test -timeout 120m
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestAccArchiveFile_Basic
--- PASS: TestAccArchiveFile_Basic (0.07s)
=== RUN   TestZipArchiver_Content
--- PASS: TestZipArchiver_Content (0.00s)
=== RUN   TestZipArchiver_File
--- PASS: TestZipArchiver_File (0.00s)
=== RUN   TestZipArchiver_Dir
--- PASS: TestZipArchiver_Dir (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/archive    0.093s

Paul

@stack72 stack72 merged commit cb491c4 into hashicorp:master Aug 18, 2016
@nicolai86
Copy link
Contributor Author

🎉

@nicolai86
Copy link
Contributor Author

@stack72 told me he gets permission errors in the example folder since the merge. I'll take a look at this today evening

@stack72
Copy link
Contributor

stack72 commented Aug 18, 2016

thanks @nicolai86

After running the archive tests, when i try and build or run any other tests, i get the following:

% make plugin-dev PLUGIN=provider-aws                                                             1 ↵
/Users/stacko/Code/go/bin/stringer
go generate $(go list ./... | grep -v /terraform/vendor/)
open builtin/providers/archive/example: permission denied
2016/08/18 16:47:28 Failed to discover providers: Failed parsing directory builtin/providers/archive/example: open builtin/providers/archive/example: permission denied
exit status 1
config.go:1: running "go": exit status 1
make: *** [generate] Error 1

kwilczynski pushed a commit to kwilczynski/terraform that referenced this pull request Aug 18, 2016
* provider/archive: use output_path instead of FileInfo

FileInfo.Name() returns the basename of the output path, which forces you to
never place archives in subdirectories

* provider/archive: add test for subdirectory output_path

* provider/archive: camelCase output_path variable
@nicolai86
Copy link
Contributor Author

Okay, the issue is that I'm not giving u+r permission for the test folder.
I'll solve this issue in two ways: a) correct permissions b) use a tmp folder for the output path, this way I also do not pollute the terraform source folders… PR incoming

@nicolai86
Copy link
Contributor Author

I've created a new PR to address the test issue. sorry for the trouble -.-

@nicolai86 nicolai86 deleted the feat/provider-archive-subdirectory branch August 18, 2016 16:45
@stack72
Copy link
Contributor

stack72 commented Aug 18, 2016

You rock @nicolai86 :) Thanks!

@ghost
Copy link

ghost commented Apr 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants