Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
populate-owners: Also slurp OWNERS_ALIASES
Some slurped repositories use OWNERS_ALIASES [1], so we need to pull these in to resolve entries in their OWNERS. OWNERS_ALIASES can only exist in the repo root [2]. That means we may need to namespace the upstream aliases to avoid collisions when assembing the composite OWNERS_ALIASES here. Defining aliases in upstream repos will be useful for situations where a particular repo team (e.g. the installer team) should have control over other directories within this repositories. For example, $ cat cluster/test-deploy/aws/OWNERS approvers: - installer-approvers reviewers: - installer-reviewers is simpler and more maintainable with an auto-maintained OWNERS_ALIASES than the copy/paste we used in 49f60b7 (cluster/test-deploy/aws/OWNERS: Delegate to openshift/installer, 2018-08-27, openshift#1290). With script control over OWNERS_ALIASES, *this* repo can't define its own aliases. But that doesn't seem like a large limitation, because this repo is unlikely to need aliases that are not defined in *any* of the upstream repositories. And if we need to grow a location for local alias configuration, we can always add that in the future. I'm using 'git clone...' over SSH to access the files, because that provides access to private repositories. Using: https://raw.githubusercontent.com/{organization}/{repository}/HEAD/{path} only works if you have an auth token or the repository is public. Using clone for two files is a bit heavy. Ideally we could pull just the two files we're interested. Git's archive command supports that use-case, but GitHub doesn't seem to have enabled the server side of that transaction: $ git archive --format=tar --remote ssh://[email protected]/openshift/installer.git HEAD OWNERS OWNERS_ALIASES Invalid command: 'git-upload-archive '/openshift/installer.git'' You appear to be using ssh to clone a git:// URL. Make sure your core.gitProxy config option and the GIT_PROXY_COMMAND environment variable are NOT set. fatal: The remote end hung up unexpectedly $ git --version git version 1.8.3.1 Until they enable that, I'm fine consuming more of their bandwidth than is strictly necessary ;). Using reflect in assertEqual gives us a nice, compact implementation. But the output can be a bit hard to read. With an introduced error: $ go test . ... --- FAIL: TestOrgRepos (0.00s) main_test.go:15: unexpected result: [0xc42006e1e0 0xc42006e240] != [0xc42006e2a0] --- FAIL: TestGetOwners (2.30s) main_test.go:15: unexpected result: &{Directories:[] Organization:openshift Repository:installer Owners:0xc42006e420 Aliases:<nil> Commit:aaa47f6a54f0fa0449d36de01ccb9f56729b608a} != &{Directories:[] Organiza ... I'd mocked up an assertEqual based on comparing json.MarshalIndent strings which produced: --- FAIL: TestOrgRepos (0.00s) main_test.go:30: unexpected result: [ { "directories": [ "/tmp/populate-owners-389376240/a/b" ], "organization": "a", "repository": "b" }, { "directories": [ "/tmp/populate-owners-389376240/c/d" ], "organization": "c", "repository": "d" } ] != [ { "directories": [ "/tmp/populate-owners-389376240/a/b" ], "organization": "a", "repository": "b" } ] --- FAIL: TestGetOwners (2.38s) main_test.go:30: unexpected result: { "organization": "openshift", "repository": "installer", "owners": { "approvers": [ "aaronlevy", "abhinavdahiya", "crawford", "smarterclayton", "wking", "yifan-gu" ], "reviewers": [ "vikramsk" ] }, "commit": "aaa47f6a54f0fa0449d36de01ccb9f56729b608a" } != { "organization": "openshift", "repository": "installer", "owners": { "approvers": [ "aaronlevy", "abhinavdahiya", "crawford", "smarterclayton", "wking", "yifan-gu" ], "reviewers": [ "vikramsk" ] }, "commit": "2587b3ed493c18747f2b37e1ab6daebdd277631a" } and of course, there are a number of third-party libraries that do an even better job (e.g. [3]). But I don't think this functionality is worth an external dependency, and Steve doesn't think it's worth maintaining much local code for comparison [4], so we're going with the more compact reflect approach despite the less-useful output. And the tests should all be passing anyway, right? ;) The GIT_*_DATE tick business is based on [5]. I haven't bothered running a new commit after each test.setup change, because we don't need a different commit hash. In production, extractOwners will be run on a fresh clone, so we will always have a different commit hash if the content changes. The stub populate-owners.sh wraps the 'go run' at Steve's request [6]. We no longer need anything Bash-specific, so I'm using a POSIX shebang in the wrapper. The 'exec' allows us to replace the shell command with Go without executing a new process [7] (although Go itself will proceed to launch a few processes). The O_TRUNC is an attempt to avoid occasional corruption like: diff --git a/ci-operator/jobs/openshift/azure-misc/OWNERS b/ci-operator/jobs/openshift/azure-misc/OWNERS index 132c684..bf0dec5 100644 --- a/ci-operator/jobs/openshift/azure-misc/OWNERS +++ b/ci-operator/jobs/openshift/azure-misc/OWNERS @@ -3,10 +3,11 @@ # See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md approvers: +- pweil- - jim-minter - kargakis - kwoodson -- mjudeikis +is - pweil- reviewers: - jim-minter although the exact source of that corruption is not clear to me. [1]: https://github.com/openshift/cluster-api-provider-aws/blob/44e974de04f496f9552ecd37b73cad01b6d69f4d/OWNERS_ALIASES [2]: https://github.com/kubernetes/community/blame/0741bdfbb56dcd4829754560f79a2f3da32cb34f/contributors/guide/owners.md#L54 [3]: https://godoc.org/github.com/stretchr/testify/assert#Equal [4]: openshift#1285 (comment) [5]: https://github.com/git/git/blob/v2.18.0/t/test-lib-functions.sh#L128-L138 [6]: openshift#1285 (comment) [7]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exec
- Loading branch information