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

Resource artifactory_artifact should accept file content from variable. #1083

Closed
pascal-hofmann opened this issue Sep 25, 2024 · 10 comments · Fixed by #1149 or #1164
Closed

Resource artifactory_artifact should accept file content from variable. #1083

pascal-hofmann opened this issue Sep 25, 2024 · 10 comments · Fixed by #1149 or #1164
Assignees
Labels
enhancement New feature or request

Comments

@pascal-hofmann
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I want to upload a file to artifactory whose contents depend on terraform resources. I tried using local_file as a workaround to get the data passed to resource artifactory_artifact but during planning terraform bails out with

Error: Invalid file path
[…]
stat ./somefile: no such file or directory

Describe the solution you'd like
Resource artifactory_artifact should have a param content that can be used to pass in the desired file content.

@pascal-hofmann pascal-hofmann added the enhancement New feature or request label Sep 25, 2024
@alexhung
Copy link
Member

@pascal-hofmann Thanks for the suggestion. I've added this to our plan.

@alexhung
Copy link
Member

@alexhung
Copy link
Member

@pascal-hofmann Question: what type of data would you use with this content attribute? Binary? String?

Terraform does not support binary, so the next logical type is string. The more I think about this, the less useful I feel. Uploading a string type artifact seems unusual to me.

@alexhung alexhung added the question Further information is requested label Nov 6, 2024
@RedlineTriad
Copy link

RedlineTriad commented Nov 19, 2024

@pascal-hofmann Question: what type of data would you use with this content attribute? Binary? String?

@alexhung I think it would make the most sense to model this based on the local_file provider which supports content and content_base64 for binary data:
https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file

And I am in the same boat of where having this would make the provider significantly nicer to use.

@RedlineTriad
Copy link

@alexhung Is there something blocking this? This would be a really nice feature for us, since writing to disk with a template, and then uploading that is incredibly painful using terraform and would cause constant diffs.

If it's just low priority then we could also create a jfrog ticket for this.

@alexhung
Copy link
Member

@RedlineTriad I'm curious about the use cases. Is the content some kind of generated data that is not from a file on disk?

@pascal-hofmann
Copy link
Contributor Author

@RedlineTriad I'm curious about the use cases. Is the content some kind of generated data that is not from a file on disk?

Yes, exactly. In our case its fetched via HTTP (via terraform).

@alexhung alexhung removed the question Further information is requested label Dec 10, 2024
@RedlineTriad
Copy link

@RedlineTriad I'm curious about the use cases. Is the content some kind of generated data that is not from a file on disk?

Same for us, we provision repositories using terraform, and want to write an index of the terraform managed repositories as a structured file to artifactory itself, for other systems to consume.

alexhung added a commit that referenced this issue Dec 13, 2024
Add support for base64 string as file content
@RedlineTriad
Copy link

I don't think this works as expected yet. @alexhung

When uploading a file I get the following after downloading it:

--5da9c22582a1b9c03d433ffde2e222cf137873a55be0256848fbf137d5d6
Content-Disposition: form-data; name="/my-file-name.yaml"; filename="artifactory_artifact_133713371337"
Content-Type: text/plain; charset=utf-8

BLA BLA BLA MY CONTENT

--5da9c22582a1b9c03d433ffde2e222cf137873a55be0256848fbf137d5d6--

Somehow mime-headers become part of the file content.

I can even reproduce this with a simple curl, and it seems using form-data for upload is just not a good idea with artifactory:

curl -v -X PUT -H "Authorization: Bearer ${ARTIFACTORY_TOKEN}" -F test.yaml=@./test http://localhost:7010/artifactory/generic-local/test.yaml

Uploaded file:

--------------------------ba6853e227b9088f
Content-Disposition: form-data; name="test.yaml"; filename="test.yaml"
Content-Type: application/octet-stream

test-hello

--------------------------ba6853e227b9088f--

Not sure if it's due to some configuration on our end, but when just using a PUT without form-data it seems to work without issues.

@alexhung
Copy link
Member

alexhung commented Jan 6, 2025

@RedlineTriad Thanks for the report! I've added this to our plan to investigate and fix.

@alexhung alexhung reopened this Jan 6, 2025
alexhung added a commit that referenced this issue Jan 7, 2025
…-request

Replace resty multiparts form upload for artifactory_artifact resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants