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

APT-543 Download From Artifactory Support #82

Merged
merged 4 commits into from
Oct 11, 2023
Merged

APT-543 Download From Artifactory Support #82

merged 4 commits into from
Oct 11, 2023

Conversation

afujiwara-roblox
Copy link
Collaborator

@afujiwara-roblox afujiwara-roblox commented Oct 10, 2023

This PR adds Artifactory download support for Foreman

@afujiwara-roblox afujiwara-roblox marked this pull request as ready for review October 10, 2023 21:26
Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

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

Some minor questions, but this looks good overall!

// file.uri will look something like /<version>/<artifact-name>, so uri will be ["", <version>, <artifact-name]
uri.next();
let version = uri.next().unwrap();
let asset_name = uri.next().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do some validation here? For names, I don't think they have to be especially precise, but we could certainly validate that version is a valid semver version, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we probably do this elsewhere, now that I think about it. But I do wonder if we could detect if the target repo isn't structured the way we expect.

Copy link
Collaborator Author

@afujiwara-roblox afujiwara-roblox Oct 10, 2023

Choose a reason for hiding this comment

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

Good point. I think it's worth at least ensuring that the repo path is structured the way we expect. If the path isn't what we expect, we should probably skip the file instead of panicking though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Foreman already does this version validation here https://github.com/Roblox/foreman/blob/main/src/tool_cache.rs#L115

fn get_releases(&self, repo: &str, host: &Url) -> ForemanResult<Vec<Release>> {
let client = Client::new();

let url = format!("{}artifactory/api/storage/{}", host, repo);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does host always automatically have a trailing /? Or must it be provided somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

Speaking of, could we potentially use Url methods to do this in a slightly more structured way? https://docs.rs/url/latest/url/struct.Url.html#method.join

Or would it not provide any meaningful benefit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

host does automatically have the trailing /, but using something like url join is probably worth it.

tag_name: version.to_string(),
assets,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but I think this could be expressed a little more elegantly with a functional approach.

@afujiwara-roblox afujiwara-roblox merged commit d169fdb into main Oct 11, 2023
10 checks passed
@afujiwara-roblox afujiwara-roblox deleted the APT-543 branch October 11, 2023 22:39
@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants