Commit graph

3419 commits

Author SHA1 Message Date
Stanislav Ochotnický
40be4b366c Ignore run-id when providing also job for rerun
This makes the behaviour consistent with gh run view.
2024-04-17 13:49:16 +02:00
William Martin
fd4f2c9c1f
Merge pull request #8620 from heaths/merge-json
Merge JSON responses from `gh api`
2024-04-17 11:45:13 +02:00
Heath Stewart
2758b80013
Remove unnecessary --help comment 2024-04-15 21:38:16 -07:00
Babak K. Shandiz
1992fdeb1a
Use filepath.Join to support different platforms
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-14 00:09:53 +01:00
Babak K. Shandiz
f05a5ccb6b
Merge branch 'trunk' into 8508-add-skip-ssh-key-option
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-13 21:17:16 +01:00
Babak K. Shandiz
a269032fd3
Refactor into table tests
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-13 21:13:12 +01:00
Babak K. Shandiz
2c6343ad56
Explain --skip-ssh-key usage in long doc
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-13 15:47:44 +01:00
Andy Feller
a42450e9a3
Merge pull request #8949 from steiza/steiza/multi-attestation
Add support to `attestation` command for more predicate types.
2024-04-12 11:12:59 -04:00
Meredith Lancaster
02158e896b
Fix attestation cmd offline unit test failure (#8933)
* pass policy to Verify method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove policy argument from SigstoreVerifier constructor

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add SigstoreVerifier interface and introduce mock SigstoreVerifier struct for unit testing

Signed-off-by: Meredith Lancaster <malancas@github.com>

* gofmt

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename LiveSigstoreVerifier constructor

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pr feedback, add todos for tests that need to be reimplemented

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unused import

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more missing TODO statements

Signed-off-by: Meredith Lancaster <malancas@github.com>

* update skipped test

Signed-off-by: Meredith Lancaster <malancas@github.com>

---------

Signed-off-by: Meredith Lancaster <malancas@github.com>
2024-04-11 18:09:10 -06:00
Zach Steindler
f0a1e2707c Change subcommands default to be more user friendly
Signed-off-by: Zach Steindler <steiza@github.com>
2024-04-10 10:11:33 -04:00
Zach Steindler
2b293c4840 Add unit test, update naming, ensure DSSE envelope is in-toto
Signed-off-by: Zach Steindler <steiza@github.com>
2024-04-10 09:49:34 -04:00
Zach Steindler
c96fb7c553 Updates from linter feedback
Signed-off-by: Zach Steindler <steiza@github.com>
2024-04-09 17:34:45 -04:00
Zach Steindler
643f4031b2 Add support to attestation command for more predicate types.
Before, we required all attestations have predicateType
https://slsa.dev/provenance/v1. This allows you to use other predicate
types, and adds the ability to filter responses from the API for a
particular predicate type.

Signed-off-by: Zach Steindler <steiza@github.com>
2024-04-09 17:26:32 -04:00
Andy Feller
88a7e529ab
Merge pull request #8762 from Ebonsignori/8761/allow-multiple-items-in-nested-array
allow multiple items in nested array
2024-04-09 14:23:19 -04:00
Andy Feller
6a55528882
Merge pull request #8899 from babakks/8679-include-num-selected-repos
Include `numSelectedRepos` in JSON output of `gh secret list`
2024-04-09 13:18:50 -04:00
William Martin
61584b83cb Close zip file in run view tests 2024-04-08 16:50:43 +02:00
William Martin
bbeccd69ad Ensure run log cache creates cache dir if it doesn't exist 2024-04-08 15:51:29 +02:00
Babak K. Shandiz
8839ee7ddf
Test --skip-ssh-key is captured correctly
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-06 13:11:02 +01:00
Babak K. Shandiz
0a77c56c44
Add test to verify skipped SSH key prompts
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-06 12:47:09 +01:00
Babak K. Shandiz
cf9699bbbb
Add --skip-ssh-key to options
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-06 12:46:05 +01:00
Babak K. Shandiz
3a3450fec5
Add SkipSSHKey field to LoginOptions
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-06 12:45:26 +01:00
Andy Feller
b722dd4151 Add tests for non-happy field paths
This commit as a suite of test around different combination of `gh api` field scenarios that result in errors.

In the course of creating this test, there were 2 scenarios that did not raise an error as expected involving overriding an existing map value.
2024-04-05 17:21:28 -04:00
William Martin
9738d68bba Fix api cache test 2024-04-05 16:47:29 +02:00
William Martin
b6239238c8
Merge pull request #8931 from cli/wm/run-log-cache-stronger-abstraction
Create stronger run log cache abstraction
2024-04-05 16:00:28 +02:00
William Martin
c2aee1e402 Ensure cache dir is always available in RunLogCache 2024-04-05 15:39:33 +02:00
William Martin
103586a94c Remove RunLogCache interface 2024-04-05 15:33:49 +02:00
William Martin
a3ffc1ca33 Use real Run Log Cache in run view tests 2024-04-05 15:18:18 +02:00
William Martin
e644dc50d6 Capture error on Run Log Cache Exists 2024-04-05 15:16:12 +02:00
Andy Feller
b0a3975948
Merge pull request #8882 from zdrve/zdrve/job-name-prefix
Anchor the log filename to the start
2024-04-05 09:11:50 -04:00
William Martin
a89d50fc63 Rework Run Log Cache so that cache dir is injected 2024-04-05 14:59:24 +02:00
Andy Feller
1540a37fee
Merge branch 'trunk' into fix-cannot-lock-pr-url 2024-04-05 08:13:44 -04:00
Babak K. Shandiz
d034a69164
Add comment to explain showSelectedReposInfo assignment
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-04 20:09:28 +01:00
Babak K. Shandiz
4aa7e75cd1
Rename const to avoid CodeQL error
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-04 20:06:45 +01:00
Babak K. Shandiz
d8ff343d5c
Add tests to verify numSelectedRepos is populated when necessary
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-04 19:49:34 +01:00
Babak K. Shandiz
e42b8b7e6b
Populate numSelectedRepos only if needed
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-04 19:48:44 +01:00
Heath Stewart
4ea7bcacb3
Run defers in queue 2024-04-04 01:26:10 -07:00
Heath Stewart
a76af8588c
Resolve PR comments 2024-04-04 01:26:09 -07:00
Heath Stewart
e83e049306
Wrap JSON arrays, objects in array with --slurp
Effectively copies `jq --slurp` since `--jq` already uses the same grammar.
2024-04-04 01:26:05 -07:00
Heath Stewart
f41876d64c
Resolve PR comments 2024-04-04 01:21:04 -07:00
Heath Stewart
0dfe6ec4b4
Clarify --merge-pages docs
Only works when piping or redirecting stdout.
2024-04-04 01:21:03 -07:00
Heath Stewart
48f0cd6f11
Replace --paginate-all with --merge-pages 2024-04-04 01:21:02 -07:00
Heath Stewart
310e5524ba
Resolve test issues 2024-04-04 01:21:01 -07:00
Heath Stewart
e7f5dded06
Add more JSON merge tests 2024-04-04 01:21:00 -07:00
Heath Stewart
a65103667e
Move jsonmerge package to internal 2024-04-04 01:20:57 -07:00
Heath Stewart
8e27e9a8cd
Merge JSON responses from gh api
Partly resolves cli/cli#1268 and replaces cli/cli#5652. Requires cli/go-gh#148 to be merged and optionally released.
2024-04-04 01:06:43 -07:00
Evan Bonsignori
fce871f3f4
Apply suggestions from code review
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-04-02 17:39:20 -07:00
William Martin
96a75139f8
Merge pull request #8888 from satoqz/trunk
Fix segfault in error handling of `gh repo rename`
2024-04-02 16:28:09 +02:00
Babak K. Shandiz
d687bc7908
Add test cases to verify exported JSON has non-zero numSelectedRepos
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-01 22:08:18 +01:00
Babak K. Shandiz
148f9527c1
Populate numSelectedRepos in non-interactive mode, if explicitly selected
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-01 22:07:53 +01:00
Meredith Lancaster
90b7bf97c5
gh-attestation cmd integration (#8698)
* add attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* update args passed to the attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use gh-attestation branch for passing iostreams from the root

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add package security team entry to codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start moving over verify cmd and general verification code

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up common and verify specific policy code

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move artifact package over

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start pulling in the github api client wrapper

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix imports

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add logger and test packages

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add additional packages to support verify command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix mock api client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up mock api client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include missing fields

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use correct owner

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more mock api client options

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add download cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add inspect cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass factory object to inspect cmd, add inspect sub cmd to attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add verify-tuf-root cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass iostream struct from command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename logger pkg to logger

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix path in codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* formatter

Signed-off-by: Meredith Lancaster <malancas@github.com>

* go mod tidy

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix printf linter issue

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix printf linter issue

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check user's GH host for compatibility

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass oci client to commands directly

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* mark tuf-root-verify cmd hidden

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move client initialization back to subcommands

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more verbose options and logging

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add missing logger

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add testing around OCI and API client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add integration test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix file path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* build executable before integration test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* split integration tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove integration test steps

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix flag value

Signed-off-by: Meredith Lancaster <malancas@github.com>

* run integration tests on ubuntu for now

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pull over doc updates

Signed-off-by: Meredith Lancaster <malancas@github.com>

* delete unused test data

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove Go patch version

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch assert to require

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move integration tests to prexisting test workflow

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use platform matrix for integration tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* simplify build step

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use StringEnumFlag handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* typo

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use the iostreams.Test helper func

Signed-off-by: Meredith Lancaster <malancas@github.com>

* create interface for oci client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for oci client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename files

Signed-off-by: Meredith Lancaster <malancas@github.com>

* format file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix shellcheck issues

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use testing TempDir method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup unused tempdir handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use table driven tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check correct cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* support repo option in download sub cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch over to using RunE

Signed-off-by: Meredith Lancaster <malancas@github.com>

* unexport top level subcommand funcs

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add comment around keychain option

Signed-off-by: Meredith Lancaster <malancas@github.com>

* update comments

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix inconsistent naming

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for CLI commands

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check for noattestationsfound err

Signed-off-by: Meredith Lancaster <malancas@github.com>

* try out metadata abstraction instead

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch to using MetadataStore abstraction

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include test case with failing metadata store

Signed-off-by: Meredith Lancaster <malancas@github.com>

* look for err specific to file write

Signed-off-by: Meredith Lancaster <malancas@github.com>

* unexport fields

Signed-off-by: Meredith Lancaster <malancas@github.com>

* return err when an unsupported hash alg is provided

Signed-off-by: Meredith Lancaster <malancas@github.com>

* PrintTableToStdOut returns err when rendering fails

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start adding sigstore verifier unit tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more sigstore verifier specific tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use cli table printer

Signed-off-by: Meredith Lancaster <malancas@github.com>

* return JSON results in slice instead of table

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move mock client to test file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded table printer method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add initial tests for tufrootverify cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* formatting

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* close file in error handling branch

Signed-off-by: Meredith Lancaster <malancas@github.com>

* normalize artifact path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded embedded file system

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include image name reference err

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use GH_DEBUG value for io handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove quiet and verbose flags

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more tufrootveriify tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* GitHubTUFOptions no longer needs to return error

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded slice

Signed-off-by: Meredith Lancaster <malancas@github.com>

* normalize all relative paths

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up nil client checks

Signed-off-by: Meredith Lancaster <malancas@github.com>

* set api server based on host

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add comment about http client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use format flag to handle json output in verify cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use format flag to handle json output

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use normalized path for cli test arg

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for json output

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup error wrapping

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use test fixtures correctly by normalizing path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* dont clean

Signed-off-by: Meredith Lancaster <malancas@github.com>

* escape backwards slash for windows files with replace

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use strings.Split func

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use strings.Replace for all command tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use CLI cache dir to store tuf metadata

Signed-off-by: Meredith Lancaster <malancas@github.com>

* Tweaked docstrings for gh attestation download

* Tweaked docstrings for gh attestation verify

* Fix for bug in gh attestation where the wrong hostname was being passed to the API client.

* lets hide tuf-root-verify eh?

* Forgot verify's short str.

* add remote verification test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* Revert "add remote verification test"

This reverts commit c0ceb99ca8.

* update json result handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add json tags to struct returned by command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix how json results are handled

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add test to ensure JSON output is valid

Signed-off-by: Meredith Lancaster <malancas@github.com>

---------

Signed-off-by: Meredith Lancaster <malancas@github.com>
Co-authored-by: Phill MV <phillmv@github.com>
2024-04-01 11:13:47 -06:00