dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
122 stars 46 forks source link

Support duplicate readme file names #1345

Closed mthalman closed 3 months ago

mthalman commented 3 months ago

These changes support the work of dotnet/dotnet-docker#5327. That issue requires that we define distinct versions of the READMEs between Docker Hub and GitHub. Previously those were identical. But now we want the Docker Hub version to have the tags table excluded.

The plan for implementing this is to have a separate set of Docker Hub README files that will get placed in the .mar directory alongside the MAR READMEs. The filename pattern (README.<repo>.md) must remain the same for the Docker Hub READMEs because that's what MAR requires for syndicating to Docker Hub. Similarly, we also want to maintain the existing README files at the root of the repo (e.g. https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md).

This causes an issue in the existing implementation of Image Builder because it has manifest validation disallowing READMEs with the same filename, regardless of which directory they're in. This is because they eventually get placed in the same directory when pushed to https://github.com/microsoft/mcrdocs.

However, we only need to push the Docker Hub and MAR READMEs to https://github.com/microsoft/mcrdocs, not the repo root READMEs. So the validation should only apply to those that are being pushed.

These changes solve this problem by introducing a --root option to the publishMcrDocs command. This allows you to specify the root directory that contains the files to be published. The filename validation is updated to apply only in the context of that directory. This also requires the validation logic to be moved out of the general manifest loading behavior to be defined in PublishMcrDocsCommand only. This allows the generateReadmes command to work without being subject to that validation since it's just generating files locally outside the context of publishing.

dotnet-issue-labeler[bot] commented 3 months ago

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 3 months ago

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.