-
Notifications
You must be signed in to change notification settings - Fork 92
Notation CLI baseline #83
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
Merged
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
efe151d
Initial prototype
shizhMSFT f494914
Distribution api proposal
SteveLasker 230940d
Formating fix
SteveLasker 945c02c
Formating fix
SteveLasker a42acd8
JWT based system (#16)
shizhMSFT 02723c7
Update examples
SteveLasker 7902d29
Fix extra curly bracket
SteveLasker a1b85a7
Fix extra curly bracket
SteveLasker f4765d1
Merge pull request #8 from shizhMSFT/main
SteveLasker cbd9bfa
Add examples of signing a multi-arch image
SteveLasker 4e392ca
Fix paging api link
SteveLasker 24207bb
Resolve spelling errors
SteveLasker 276abe4
Fix examples to include full descriptor
SteveLasker 6298cd2
typo feedback
SteveLasker 578ecad
Renamed as options to keep as reference. Updated digest references
SteveLasker a3d6785
Merge pull request #10 from SteveLasker/distribution-proposal
SteveLasker 73112f4
Doc and Demo updates
SteveLasker a5bac5d
Doc and Demo updates
SteveLasker 3a6d3a6
nv2 demo script updates
SteveLasker a7ae4eb
nv2 demo: cleanup steps
SteveLasker 24fc5c5
Prototype-2 initial mocks
SteveLasker 9f54b68
Prototype-2 initial mocks
SteveLasker bc042ea
Merge pull request #42 from SteveLasker/prototype-2
SteveLasker 7fbc45f
Use library implementation
shizhMSFT 4a0a77d
converge docker-generate
shizhMSFT 3d6c0a9
converge docker-nv2
shizhMSFT 545280e
refactor network transport
shizhMSFT cd28c19
add makefile
shizhMSFT 41012fb
update dependency
shizhMSFT 62e2eee
push signature support
shizhMSFT 20e35b6
pull signature support
shizhMSFT e759247
integrate sign and push
shizhMSFT 7d70eee
no output on sign-then-push by default
shizhMSFT 996eeb9
Merge pull request #43 from shizhMSFT/prototype-2
SteveLasker f7da7a7
better ux for signature info
shizhMSFT a1071bc
make install better
shizhMSFT b72e867
update notary library
shizhMSFT e928219
update dependencies
shizhMSFT 1444a31
Merge pull request #50 from shizhMSFT/prototype-2
SteveLasker ffe6cdc
Multiple signatures support (#52)
shizhMSFT 44d4614
pull signatures when pulling images (#54)
shizhMSFT 5af426e
Explicit add original references when signing (#57)
shizhMSFT d589dd8
create parent folders before create config file (#59)
shizhMSFT 9ad1272
Update demo script for prototype-2 (#53)
SteveLasker 9c9f68b
Ci 2 (#49)
marcofranssen 2f199a5
upgrade to prototype-3
shizhMSFT bee5c84
Merge prototype-3
shizhMSFT e304503
Notation CLI Alpha
shizhMSFT cdd6aaf
bump notation-go-lib
shizhMSFT 62b35ef
prepare for 0.5.1 release
shizhMSFT db7b4d8
refine notation sign
dependabot[bot] b7ad88f
Bump actions/cache from 2.1.4 to 2.1.6
dependabot[bot] 0d29519
extract `list` from `pull --peek`
shizhMSFT 6502bbd
rename digest to sigDigests for code readability
shizhMSFT 3baeee3
update doc for building
shizhMSFT 107767c
refine doc for building
shizhMSFT 07dada7
plain http in config
shizhMSFT 9c5c749
no default trust on generated cert
shizhMSFT 35ea923
clean up media type
shizhMSFT 913848d
refine docker-notation
shizhMSFT 601f235
cached pull
shizhMSFT 94b55d5
refactor notation code
shizhMSFT 7ac7bfb
fix reference print
shizhMSFT bd80447
refactor docker-notation code
shizhMSFT 2862bb4
compare registry host case insensitively
shizhMSFT 4c4a3c3
refine docker-notation pull output
shizhMSFT 8746d03
safer prune
shizhMSFT 379b37a
prepare for v0.5.2 release
shizhMSFT 46918e8
update notation-go-lib dependency
shizhMSFT 68b632e
update release for go releaser
shizhMSFT b3b65a5
update notation-go-lib dependency
shizhMSFT 73d6fe0
update authors
shizhMSFT b75d34f
make github workflow consistent
shizhMSFT 33d34e6
output stderr for docker-generate
shizhMSFT 875fadd
move implementations to the correct package
shizhMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
| end_of_line = lf | ||
| indent_style = space | ||
| indent_size = 2 | ||
| tab_width = 2 | ||
|
|
||
| [*.go] | ||
| indent_size = 4 | ||
| tab_width = 4 | ||
| indent_style = tab | ||
| # required for multiline strings in test cases | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [Makefile] | ||
| indent_size = 4 | ||
| tab_width = 4 | ||
| indent_style = tab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| blank_issues_enabled: true | ||
| contact_links: | ||
| - name: Ask a question | ||
| url: https://github.com/notaryproject/nv2/discussions | ||
| url: https://github.com/notaryproject/notation/discussions | ||
| about: Ask questions and discuss with other community members |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # To get started with Dependabot version updates, you'll need to specify which | ||
| # package ecosystems to update and where the package manifests are located. | ||
| # Please see the documentation for all configuration options: | ||
| # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
|
||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "gomod" # See documentation for possible values | ||
| directory: "/" # Location of package manifests | ||
| schedule: | ||
| interval: "weekly" | ||
|
|
||
| - package-ecosystem: "github-actions" | ||
| # Workflow files stored in the | ||
| # default location of `.github/workflows` | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: build | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| build: | ||
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | ||
| name: Continuous Integration | ||
| runs-on: ubuntu-20.04 | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.17] | ||
| fail-fast: true | ||
| steps: | ||
| - name: Set up Go ${{ matrix.go-version }} | ||
| uses: actions/setup-go@v2 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| - name: Check out code | ||
| uses: actions/checkout@v2 | ||
| - name: Cache Go modules | ||
| uses: actions/cache@v2 | ||
| id: go-mod-cache | ||
| with: | ||
| path: ~/go/pkg/mod | ||
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-go- | ||
| - name: Get dependencies | ||
| run: make download | ||
| - name: Build | ||
| run: make build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: release-github | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - v* | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Release Notation Binaries | ||
| runs-on: ubuntu-20.04 | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.17] | ||
| fail-fast: true | ||
| steps: | ||
| - name: Set up Go ${{ matrix.go-version }} | ||
| uses: actions/setup-go@v2 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
| - name: Run GoReleaser | ||
| uses: goreleaser/goreleaser-action@v2 | ||
| with: | ||
| distribution: goreleaser | ||
| version: latest | ||
| args: release --rm-dist | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_USER_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # VS Code | ||
| .vscode | ||
|
|
||
| # Custom | ||
| bin/ | ||
| vendor/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| builds: | ||
| - main: ./cmd/notation | ||
| id: notation | ||
| binary: notation | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| ignore: | ||
| - goos: windows | ||
| goarch: arm64 | ||
| ldflags: | ||
| - -s -w -X {{.ModulePath}}/internal/version.Version={{.Version}} -X {{.ModulePath}}/internal/version.BuildMetadata= | ||
shizhMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - main: ./cmd/docker-notation | ||
| id: docker-notation | ||
| binary: docker-notation | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| ignore: | ||
| - goos: windows | ||
| goarch: arm64 | ||
| ldflags: | ||
| - -s -w -X {{.ModulePath}}/internal/version.Version={{.Version}} -X {{.ModulePath}}/internal/version.BuildMetadata= | ||
| - main: ./cmd/docker-generate | ||
| id: docker-generate | ||
| binary: docker-generate | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| ignore: | ||
| - goos: windows | ||
| goarch: arm64 | ||
| ldflags: | ||
| - -s -w | ||
| archives: | ||
| - format: tar.gz | ||
| format_overrides: | ||
| - goos: windows | ||
| format: zip | ||
| files: | ||
| - LICENSE | ||
| release: | ||
| prerelease: auto | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| MODULE = github.com/notaryproject/notation | ||
| DOCKER_PLUGINS = docker-generate docker-notation | ||
| COMMANDS = notation $(DOCKER_PLUGINS) | ||
| GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) | ||
| BUILD_METADATA = | ||
| ifeq ($(GIT_TAG),) # unreleased build | ||
| GIT_COMMIT = $(shell git rev-parse HEAD) | ||
| GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "unreleased") | ||
| BUILD_METADATA = $(GIT_COMMIT).$(GIT_STATUS) | ||
| endif | ||
| LDFLAGS = -X $(MODULE)/internal/version.BuildMetadata=$(BUILD_METADATA) | ||
| GO_BUILD_FLAGS = --ldflags="$(LDFLAGS)" | ||
|
|
||
| .PHONY: help | ||
| help: | ||
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' | ||
|
|
||
| .PHONY: all | ||
| all: build | ||
|
|
||
| .PHONY: FORCE | ||
| FORCE: | ||
|
|
||
| bin/%: cmd/% FORCE | ||
| go build $(GO_BUILD_FLAGS) -o $@ ./$< | ||
|
|
||
| .PHONY: download | ||
| download: ## download dependencies via go mod | ||
| go mod download | ||
|
|
||
| .PHONY: build | ||
| build: $(addprefix bin/,$(COMMANDS)) ## builds binaries | ||
|
|
||
| .PHONY: clean | ||
| clean: | ||
| git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf | ||
|
|
||
| .PHONY: check-line-endings | ||
| check-line-endings: ## check line endings | ||
| ! find cmd pkg internal -name "*.go" -type f -exec file "{}" ";" | grep CRLF | ||
|
|
||
| .PHONY: fix-line-endings | ||
| fix-line-endings: ## fix line endings | ||
| find cmd pkg internal -type f -name "*.go" -exec sed -i -e "s/\r//g" {} + | ||
|
|
||
| .PHONY: vendor | ||
| vendor: ## vendores the go modules | ||
| GO111MODULE=on go mod vendor | ||
|
|
||
| .PHONY: install | ||
| install: install-notation install-docker-plugins ## install the notation cli and docker plugins | ||
|
|
||
| .PHONY: install-notation | ||
| install-notation: bin/notation ## installs the notation cli | ||
| cp $< ~/bin/ | ||
|
|
||
| .PHONY: install-docker-% | ||
| install-docker-%: bin/docker-% | ||
| cp $< ~/.docker/cli-plugins/ | ||
|
|
||
| .PHONY: install-docker-plugins | ||
| install-docker-plugins: $(addprefix install-,$(DOCKER_PLUGINS)) ## installs the docker plugins | ||
| cp $(addprefix bin/,$(DOCKER_PLUGINS)) ~/.docker/cli-plugins/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Building Notation | ||
|
|
||
| The notation repo contains the following: | ||
|
|
||
| - `notation` - A CLI for signing and verifying artifacts with Notation | ||
| - `docker-generate` - Extends docker with `docker generate` to create locally persisted manifest for signing, without having to push to a registry. | ||
| - `docker-notation` - Extends docker with `docker notation` to enable, sign and verify Notation signatures. | ||
|
|
||
| Building above binaries require [golang](https://golang.org/dl/) with version `>= 1.17`. | ||
|
|
||
| ## Windows with WSL | ||
|
|
||
| - Build the binaries, installing them to: | ||
| - `~/bin/notation` | ||
| - `~/.docker/cli-plugins/docker-generate` | ||
| - `~/.docker/cli-plugins/docker-notation` | ||
| ```sh | ||
| git clone https://github.com/notaryproject/notation.git | ||
| cd notation | ||
| make install | ||
| ``` | ||
| - Verify binaries are installed | ||
| ```sh | ||
| docker --help | ||
| # look for | ||
| Management Commands: | ||
| generate* Generate artifacts (CNCF Notary Project, 0.1.0) | ||
| notation* Manage signatures on Docker images (CNCF Notary Project, 0.5.3-alpha) | ||
|
|
||
| which notation | ||
| # output | ||
| /home/<user>/bin/notation | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/urfave/cli/v2" | ||
| ) | ||
|
|
||
| var generateCommand = &cli.Command{ | ||
| Name: "generate", | ||
| Subcommands: []*cli.Command{ | ||
| manifestCommand, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/urfave/cli/v2" | ||
| ) | ||
|
|
||
| func main() { | ||
| app := &cli.App{ | ||
| Name: "docker", | ||
| Commands: []*cli.Command{ | ||
| generateCommand, | ||
| metadataCommand, | ||
| }, | ||
| } | ||
| if err := app.Run(os.Args); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "io" | ||
| "os" | ||
| "os/exec" | ||
|
|
||
| "github.com/notaryproject/notation/pkg/docker" | ||
| "github.com/urfave/cli/v2" | ||
| ) | ||
|
|
||
| var manifestCommand = &cli.Command{ | ||
| Name: "manifest", | ||
| Usage: "generates the manifest of a docker image", | ||
| ArgsUsage: "[<reference>]", | ||
| Flags: []cli.Flag{ | ||
| &cli.StringFlag{ | ||
| Name: "output", | ||
| Aliases: []string{"o"}, | ||
| Usage: "write to a file instead of stdout", | ||
| }, | ||
| }, | ||
| Action: generateManifest, | ||
| } | ||
|
|
||
| func generateManifest(ctx *cli.Context) error { | ||
| var reader io.Reader | ||
| if reference := ctx.Args().First(); reference != "" { | ||
| cmd := exec.Command("docker", "save", reference) | ||
| cmd.Stderr = os.Stderr | ||
| stdout, err := cmd.StdoutPipe() | ||
shizhMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if err != nil { | ||
| return err | ||
| } | ||
| reader = stdout | ||
| if err := cmd.Start(); err != nil { | ||
| return err | ||
| } | ||
| } else { | ||
| reader = os.Stdin | ||
| } | ||
|
|
||
| var writer io.Writer | ||
| if output := ctx.String("output"); output != "" { | ||
| file, err := os.Create(output) | ||
shizhMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if err != nil { | ||
| return err | ||
| } | ||
| defer file.Close() | ||
| writer = file | ||
| } else { | ||
| writer = os.Stdout | ||
| } | ||
|
|
||
| manifest, err := docker.GenerateSchema2FromDockerSave(reader) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| _, payload, err := manifest.Payload() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| _, err = writer.Write(payload) | ||
| return err | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.