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

Add auth header support. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmeulen
Copy link
Contributor

@dmeulen dmeulen commented Sep 11, 2024

This makes it possible to authenticate with the gitlab or github API by specifying a PRIVATE-TOKEN or Authorization header with the http request.

Now you can download the ansible source tarball and md5 directly from the gitlab or github package registry using the gitlab API.

example config:

{
  "http-url": "gitlab.ops.catdevbrain.lan/api/v4/projects/4/jobs/artifacts/main/raw/catdevbrain-ansible-latest.tar.gz?job=build_latest",
  "http-checksum-url": "gitlab.ops.catdevbrain.lan/api/v4/projects/4/jobs/artifacts/main/raw/catdevbrain-ansible-latest.tar.gz.md5?job=build_latest",
  "http-proto": "https",
  "http-header-name": "PRIVATE-TOKEN",
  "http-header-value": "<REDACTED>",
  "ansible-dir": "ansible",
  "ansible-inventory": ["inventories/catdevbrain"],
  "playbook": "site.yml",
  "sleep": "10",
  "sleep-jitter": "5"
}

This makes it possible to authenticate with the gitlab or github API by
specifying a `PRIVATE-TOKEN` or `Authorization` header with the http request.

Now you can download the ansible source tarball and md5 directly from the
gitlab package registry using the gitlab API.
@dmeulen dmeulen changed the title Add support for sentting a http header name and value. Add support for setting a http header name and value. Sep 11, 2024
@dmeulen dmeulen changed the title Add support for setting a http header name and value. Add auth header support. Sep 18, 2024
Copy link
Collaborator

@shk3 shk3 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I have some nits, and I will merge this PR once they are addressed.

@@ -87,7 +87,8 @@ func init() {
pflag.String("http-proto", "https", "Set to 'http' if necessary")
pflag.String("http-user", "", "HTTP username for pulling the remote file")
pflag.String("http-pass", "", "HTTP password for pulling the remote file")

pflag.String("http-header-name", "", "HTTP header name")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Let's fill it with context. "HTTP header name for pulling the remote file"

@@ -87,7 +87,8 @@ func init() {
pflag.String("http-proto", "https", "Set to 'http' if necessary")
pflag.String("http-user", "", "HTTP username for pulling the remote file")
pflag.String("http-pass", "", "HTTP password for pulling the remote file")

pflag.String("http-header-name", "", "HTTP header name")
pflag.String("http-header-value", "", "HTTP header value")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Let's fill it with context. "HTTP header value for pulling the remote file"

testEmptyChecksumUrl = ""
testChecksumUrlPath = "custom.txt.md5"
testEmptyChecksumUrl = ""
testChecksumUrlPath = "custom.txt.md5"

testHashlessFilename = "nohash.txt"
testHashlessText = []byte("Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we include the new fields in the test?

@dmeulen
Copy link
Contributor Author

dmeulen commented Oct 3, 2024

Will update whein I find some time, rather busy atm! Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants