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

docs: spec updates for arbitrary blob signing #811

Merged
merged 88 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
a653585
Spec updates for arbitrary blob signing
rgnote Oct 28, 2023
a59bdfa
fix verify command examples
rgnote Oct 28, 2023
b194284
update signature-name rather than signature-path for blob sign command
rgnote Nov 1, 2023
c14aaa7
minor updates
rgnote Nov 2, 2023
ee0dca3
minor updates
rgnote Nov 7, 2023
be48c14
support signature-directory flag in notation blob sign command
rgnote Nov 15, 2023
83ed0e5
address Pritesh's comments
rgnote Nov 17, 2023
deff1fa
minor change
rgnote Nov 17, 2023
294a8d0
minor updates to help texts
rgnote Nov 24, 2023
a882cc9
fix: improve error messages of notation CLI (#810)
Two-Hearts Nov 3, 2023
14b6b44
bump: update dependencies (#815)
Two-Hearts Nov 3, 2023
2d5896f
build(deps): Bump ossf/scorecard-action from 2.3.0 to 2.3.1 (#814)
dependabot[bot] Nov 3, 2023
67680e5
build(deps): Bump github/codeql-action from 2.22.0 to 2.22.5 (#813)
dependabot[bot] Nov 3, 2023
cd982bd
bump: bump up dependencies including E2E tests (#818)
Two-Hearts Nov 4, 2023
a8566bc
fix: add "release-*" to workflows trigger events (#819)
Two-Hearts Nov 4, 2023
039d292
fix: fix the license check (#826)
Two-Hearts Nov 15, 2023
9229343
bump: bump up to go version 1.21 (#833)
Two-Hearts Nov 20, 2023
8791d26
doc: update plugin spec (#809)
FeynmanZhou Nov 20, 2023
33bf39b
build(deps): Bump github.com/spf13/cobra from 1.7.0 to 1.8.0 (#823)
dependabot[bot] Nov 21, 2023
9802c0d
build(deps): Bump github/codeql-action from 2.22.5 to 2.22.7 (#835)
dependabot[bot] Nov 22, 2023
993c1a7
Correct broken link to quick start guide (#831)
rcrozean Nov 22, 2023
1102d9c
chore: update tag to digest (#837)
yizha1 Nov 28, 2023
604b8c2
fix nits
rgnote Dec 5, 2023
10099bf
Update specs/commandline/verify.md
rgnote Dec 8, 2023
dc2d289
Update specs/commandline/inspect.md
rgnote Dec 8, 2023
5c113af
fix -sd flag
rgnote Dec 8, 2023
2b533cf
Update specs/commandline/blob.md
rgnote Dec 28, 2023
39ce373
feat: add notation plugin uninstall command (#842)
Two-Hearts Dec 5, 2023
dca3df7
chore: update references with the tag version (#836)
yizha1 Dec 7, 2023
78ea8a7
build(deps): Bump golang.org/x/term from 0.13.0 to 0.15.0 (#843)
dependabot[bot] Dec 13, 2023
699f7ed
build(deps): Bump actions/setup-go from 4.1.0 to 5.0.0 (#845)
dependabot[bot] Dec 13, 2023
f267a4c
build(deps): Bump github/codeql-action from 2.22.7 to 2.22.9 (#846)
dependabot[bot] Dec 13, 2023
403423e
build(deps): Bump golang.org/x/crypto from 0.15.0 to 0.17.0 (#850)
dependabot[bot] Dec 19, 2023
97624b6
build(deps): Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /test/…
dependabot[bot] Dec 19, 2023
9ef1989
build(deps): Bump github/codeql-action from 2.22.9 to 3.22.11 (#847)
dependabot[bot] Dec 19, 2023
58bf3a0
build(deps): Bump actions/upload-artifact from 3.1.3 to 4.0.0 (#848)
dependabot[bot] Dec 19, 2023
c9354be
feat: notation plugin install command (#827)
Two-Hearts Dec 21, 2023
e6732c3
feat: add notation config environment variable (#821)
JeyJeyGao Jan 3, 2024
116f5ec
fix: fix bug in `SetHTTPDebugLog` (#857)
Two-Hearts Jan 4, 2024
bea8cf2
fix: `notation plugin install` error messages and tests (#855)
Two-Hearts Jan 4, 2024
9011319
build(deps): Bump github/codeql-action from 3.22.11 to 3.22.12 (#854)
dependabot[bot] Jan 4, 2024
7db7fca
Updated CODEOWNERS and MAINTAINERS files (#862)
toddysm Jan 14, 2024
73affa6
build(deps): Bump golang.org/x/term from 0.15.0 to 0.16.0 (#860)
dependabot[bot] Jan 15, 2024
e30df6c
bump: bump up notation-go (#863)
Two-Hearts Jan 15, 2024
a6c8ed7
build(deps): Bump actions/cache from 3.3.2 to 3.3.3 (#866)
dependabot[bot] Jan 16, 2024
b078456
build(deps): Bump github/codeql-action from 3.22.12 to 3.23.0 (#865)
dependabot[bot] Jan 16, 2024
87cb8b9
build(deps): Bump actions/upload-artifact from 4.0.0 to 4.1.0 (#864)
dependabot[bot] Jan 16, 2024
ccd10aa
address comments on the old CX before rewriting the PR for the new CX
rgnote Jan 17, 2024
1155995
update blob command to address policy management
rgnote Jan 18, 2024
4099f17
fix typos
rgnote Jan 26, 2024
999f3c2
Fix sub-command order
rgnote Jan 26, 2024
a5bebbd
remove policyType field from trust policies
rgnote Feb 1, 2024
d41bdb4
address comments
rgnote Feb 8, 2024
8dd0457
Update specs/commandline/blob.md
rgnote Feb 8, 2024
bcdb44a
remove --signature's short-hand flag
rgnote Feb 8, 2024
3d70c29
Update specs/commandline/policy.md
rgnote Feb 22, 2024
0b09a80
Update specs/commandline/blob.md
rgnote Feb 22, 2024
688bb2c
Update specs/commandline/blob.md
rgnote Feb 22, 2024
a5f3afc
Update specs/commandline/blob.md
rgnote Feb 22, 2024
70c8f47
Update specs/commandline/blob.md
rgnote Feb 22, 2024
e85bfe0
Update specs/commandline/blob.md
rgnote Feb 22, 2024
59e2fb9
Update specs/commandline/blob.md
rgnote Feb 22, 2024
002ca48
Update specs/commandline/blob.md
rgnote Feb 22, 2024
c40c667
Update specs/commandline/policy.md
rgnote Feb 22, 2024
9b79374
use related paths
rgnote Feb 22, 2024
17d7e1e
fix: improve error message for plugin (#870)
JeyJeyGao Jan 22, 2024
8e53eb0
build(deps): Bump actions/upload-artifact from 4.1.0 to 4.2.0 (#872)
dependabot[bot] Jan 23, 2024
b04cb09
build(deps): Bump actions/cache from 3.3.3 to 4.0.0 (#873)
dependabot[bot] Jan 23, 2024
6d49323
build(deps): Bump github/codeql-action from 3.23.0 to 3.23.1 (#874)
dependabot[bot] Jan 23, 2024
a538660
bump: bump up notation-go and notation-core-go including e2e tests (#…
Two-Hearts Jan 25, 2024
4baf935
vote for version v1.1.0
Two-Hearts Jan 25, 2024
a442153
build(deps): Bump actions/upload-artifact from 4.2.0 to 4.3.0 (#878)
dependabot[bot] Jan 30, 2024
ddf2c5e
build(deps): Bump codecov/codecov-action from 3.1.4 to 3.1.5 (#879)
dependabot[bot] Jan 30, 2024
f238f4f
build(deps): Bump github/codeql-action from 3.23.1 to 3.23.2 (#877)
dependabot[bot] Jan 30, 2024
3a0562b
bump: bump up oras-go and image-spec (#881)
Two-Hearts Feb 2, 2024
bbb4087
build(deps): Bump github/codeql-action from 3.23.2 to 3.24.0 (#883)
dependabot[bot] Feb 6, 2024
f8e613d
build(deps): Bump codecov/codecov-action from 3.1.5 to 4.0.1 (#884)
dependabot[bot] Feb 6, 2024
ecbea19
build(deps): Bump golang.org/x/term from 0.16.0 to 0.17.0 (#886)
dependabot[bot] Feb 22, 2024
b1ab330
build(deps): Bump actions/upload-artifact from 4.3.0 to 4.3.1 (#887)
dependabot[bot] Feb 22, 2024
194cab7
build(deps): Bump codecov/codecov-action from 4.0.1 to 4.0.2 (#896)
dependabot[bot] Feb 29, 2024
eae0fe3
build(deps): Bump github/codeql-action from 3.24.0 to 3.24.5 (#895)
dependabot[bot] Feb 29, 2024
a22d8fd
build(deps): Bump github.com/opencontainers/image-spec from 1.1.0-rc6…
dependabot[bot] Feb 29, 2024
8e0ce16
remove overwrite option in sign command
rgnote Feb 29, 2024
1b9e88b
Update specs/commandline/blob.md
rgnote Mar 5, 2024
a2ebf5c
Update specs/commandline/blob.md
rgnote Mar 5, 2024
7815b82
build(deps): Bump codecov/codecov-action from 4.0.2 to 4.1.0 (#898)
dependabot[bot] Mar 6, 2024
58dd756
build(deps): Bump actions/cache from 4.0.0 to 4.0.1 (#900)
dependabot[bot] Mar 6, 2024
778245a
build(deps): Bump actions/add-to-project from 0.5.0 to 0.6.0 (#901)
dependabot[bot] Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@31b3f3ccdc584546fc445612dec3f38ff5edb41c # v0.5.0
- uses: actions/add-to-project@0609a2702eefb44781da00f8e04901d6e5cd2b92 # v0.6.0
with:
project-url: https://github.com/orgs/notaryproject/projects/10
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
fail-fast: true
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Cache Go modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
id: go-mod-cache
with:
path: ~/go/pkg/mod
Expand All @@ -59,4 +59,4 @@ jobs:
make e2e-covdata
fi
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
14 changes: 9 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ name: "CodeQL"

on:
push:
branches: main
branches:
- main
- release-*
pull_request:
branches: main
branches:
- main
- release-*
schedule:
- cron: '38 21 * * 1'

Expand All @@ -40,13 +44,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Go ${{ matrix.go-version }} environment
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Initialize CodeQL
uses: github/codeql-action/init@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
uses: github/codeql-action/init@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
with:
languages: go
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
uses: github/codeql-action/analyze@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
8 changes: 6 additions & 2 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ name: License Checker

on:
push:
branches: main
branches:
- main
- release-*
pull_request:
branches: main
branches:
- main
- release-*

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
fail-fast: true
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ on:
# Weekly on Saturdays.
- cron: '30 1 * * 6'
push:
branches: [ main ]
branches:
- main
- release-*
paths:
- '!docs/**'
- '!specs/**'
Expand All @@ -44,21 +46,21 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # tag=v2.3.0
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # tag=v2.3.1
with:
results_file: results.sarif
results_format: sarif
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
publish_results: true

- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # tag=v3.1.3
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # tag=v4.3.1
with:
name: SARIF file
path: results.sarif
retention-days: 5

- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
uses: github/codeql-action/upload-sarif@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Repo-Level Owners (in alphabetical order)
# Note: This is only for the notaryproject/notation repo
* @gokarnm @JeyJeyGao @justincormack @niazfk @priteshbandi @rgnote @shizhMSFT @stevelasker @Two-Hearts
* @gokarnm @JeyJeyGao @justincormack @niazfk @priteshbandi @rgnote @shizhMSFT @stevelasker @toddysm @Two-Hearts
5 changes: 3 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# Pattern: [First Name] [Last Name] <[Email Address]> ([GitHub Handle])
Justin Cormack <[email protected]> (@justincormack)
Niaz Khan <[email protected]> (@niazfk)
Pritesh Bandi <[email protected]> (@priteshbandi)
Shiwei Zhang <[email protected]> (@shizhMSFT)
Steve Lasker <[email protected]> (@stevelasker)
Toddy Mladenov <[email protected]> (@toddysm)

# Repo-Level Maintainers (in alphabetical order)
# Note: This is for the notaryproject/notation repo
Junjie Gao <[email protected]> (@JeyJeyGao)
Milind Gokarn <[email protected]> (@gokarnm)
Patrick Zheng <[email protected]> (@Two-Hearts)
Pritesh Bandi <[email protected]> (@priteshbandi)
Rakesh Gariganti <[email protected]> (@rgnote)
Shiwei Zhang <[email protected]> (@shizhMSFT)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ You can find the Notary Project [README](https://github.com/notaryproject/.githu

## Quick Start

- [Quick start: Sign and validate a container image](https://notaryproject.dev/docs/quickstart-guides/quickstart/)
- [Quick start: Sign and validate a container image](https://notaryproject.dev/docs/quickstart-guides/quickstart-sign-image-artifact/)
- [Try out Notation in this Killercoda interactive sandbox environment](https://killercoda.com/notaryproject/scenario/notation)
- Build, sign, and verify container images using Notation with [Azure Key Vault](https://docs.microsoft.com/azure/container-registry/container-registry-tutorial-sign-build-push?wt.mc_id=azurelearn_inproduct_oss_notaryproject) or [AWS Signer](https://docs.aws.amazon.com/signer/latest/developerguide/container-workflow.html)

## Community

Notary Project is a [CNCF Incubating project](https://www.cncf.io/projects/notary/). We :heart: your contribution.
Expand Down
2 changes: 1 addition & 1 deletion cmd/notation/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Example - [Experimental] Inspect signatures on an OCI artifact identified by a d
Long: longMessage,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("missing reference")
return errors.New("missing reference to the artifact: use `notation inspect --help` to see what parameters are required")
}
opts.reference = args[0]
return nil
Expand Down
86 changes: 86 additions & 0 deletions cmd/notation/internal/plugin/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright The Notary Project Authors.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package plugin

import (
"context"
"fmt"
"io"
"net/http"
"time"

"github.com/notaryproject/notation/internal/httputil"
)

// MaxPluginSourceBytes specifies the limit on how many bytes are allowed in the
// server's response to the download from URL request.
//
// The plugin source size must be strictly less than this value.
var MaxPluginSourceBytes int64 = 256 * 1024 * 1024 // 256 MiB

// PluginSourceType is an enum for plugin source
type PluginSourceType int

const (
// PluginSourceTypeFile means plugin source is file
PluginSourceTypeFile PluginSourceType = 1 + iota

// PluginSourceTypeURL means plugin source is URL
PluginSourceTypeURL
)

const (
// MediaTypeZip means plugin file is zip
MediaTypeZip = "application/zip"

// MediaTypeGzip means plugin file is gzip
MediaTypeGzip = "application/x-gzip"
)

// DownloadPluginFromURLTimeout is the timeout when downloading plugin from a
// URL
const DownloadPluginFromURLTimeout = 10 * time.Minute

// DownloadPluginFromURL downloads plugin source from url to a tmp file on file
// system
func DownloadPluginFromURL(ctx context.Context, pluginURL string, tmpFile io.Writer) error {
// Get the data
client := httputil.NewAuthClient(ctx, &http.Client{Timeout: DownloadPluginFromURLTimeout})
req, err := http.NewRequest(http.MethodGet, pluginURL, nil)
if err != nil {
return err
}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
// Check server response
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s %q: https response bad status: %s", resp.Request.Method, resp.Request.URL, resp.Status)
}
// Write the body to file
lr := &io.LimitedReader{
R: resp.Body,
N: MaxPluginSourceBytes,
}
_, err = io.Copy(tmpFile, lr)
if err != nil {
return err
}
if lr.N == 0 {
return fmt.Errorf("%s %q: https response reached the %d MiB size limit", resp.Request.Method, resp.Request.URL, MaxPluginSourceBytes/1024/1024)
}
return nil
}
23 changes: 21 additions & 2 deletions cmd/notation/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,32 @@ func listCommand(opts *listOpts) *cobra.Command {
inputType: inputTypeRegistry, // remote registry by default
}
}
longMessage := `List all the signatures associated with signed artifact

Example - List signatures of an OCI artifact:
notation list <registry>/<repository>@<digest>

Example - List signatures of an OCI artifact identified by a tag (Notation will resolve tag to digest)
notation list <registry>/<repository>:<tag>
`
experimentalExamples := `
Example - [Experimental] List signatures of an OCI artifact using the Referrers API. If it's not supported (returns 404), fallback to the Referrers tag schema
notation list --allow-referrers-api <registry>/<repository>@<digest>

Example - [Experimental] List signatures of an OCI artifact referenced in an OCI layout
notation list --oci-layout "<oci_layout_path>@<digest>"

Example - [Experimental] List signatures of an OCI artifact identified by a tag and referenced in an OCI layout
notation list --oci-layout "<oci_layout_path>:<tag>"
`
command := &cobra.Command{
Use: "list [flags] <reference>",
Aliases: []string{"ls"},
Short: "List signatures of the signed artifact",
Long: "List all the signatures associated with signed artifact",
Long: longMessage,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("no reference specified")
return errors.New("missing reference to the artifact: use `notation list --help` to see what parameters are required")
}
opts.reference = args[0]
return nil
Expand All @@ -74,6 +92,7 @@ func listCommand(opts *listOpts) *cobra.Command {
command.Flags().BoolVar(&opts.ociLayout, "oci-layout", false, "[Experimental] list signatures stored in OCI image layout")
experimental.HideFlags(command, "", []string{"allow-referrers-api", "oci-layout"})
command.Flags().IntVar(&opts.maxSignatures, "max-signatures", 100, "maximum number of signatures to evaluate or examine")
experimental.HideFlags(command, experimentalExamples, []string{"allow-referrers-api", "oci-layout"})
return command
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/notation/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"github.com/notaryproject/notation-go/log"
"github.com/notaryproject/notation/internal/auth"
"github.com/notaryproject/notation/internal/cmd"
credentials "github.com/oras-project/oras-credentials-go"
"github.com/spf13/cobra"
"golang.org/x/term"
"oras.land/oras-go/v2/registry/remote/credentials"
)

const urlDocHowToAuthenticate = "https://notaryproject.dev/docs/how-to/registry-authentication/"
Expand Down
2 changes: 1 addition & 1 deletion cmd/notation/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/notaryproject/notation/internal/auth"
"github.com/notaryproject/notation/internal/cmd"
credentials "github.com/oras-project/oras-credentials-go"
"github.com/spf13/cobra"
"oras.land/oras-go/v2/registry/remote/credentials"
)

type logoutOpts struct {
Expand Down
14 changes: 13 additions & 1 deletion cmd/notation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ package main
import (
"os"

"github.com/notaryproject/notation-go/dir"
"github.com/notaryproject/notation/cmd/notation/cert"
"github.com/notaryproject/notation/cmd/notation/plugin"
"github.com/notaryproject/notation/cmd/notation/policy"
"github.com/spf13/cobra"
)
Expand All @@ -31,6 +33,16 @@ func main() {
// to avoid leaking credentials
os.Unsetenv(defaultUsernameEnv)
os.Unsetenv(defaultPasswordEnv)

// update Notation config directory
if notationConfig := os.Getenv("NOTATION_CONFIG"); notationConfig != "" {
dir.UserConfigDir = notationConfig
}

// update Notation Libexec directory (for plugins)
if notationLibexec := os.Getenv("NOTATION_LIBEXEC"); notationLibexec != "" {
dir.UserLibexecDir = notationLibexec
}
},
}
cmd.AddCommand(
Expand All @@ -40,7 +52,7 @@ func main() {
cert.Cmd(),
policy.Cmd(),
keyCommand(),
pluginCommand(),
plugin.Cmd(),
loginCommand(nil),
logoutCommand(nil),
versionCommand(),
Expand Down
11 changes: 7 additions & 4 deletions cmd/notation/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func resolveReference(ctx context.Context, inputType inputType, reference string
case inputTypeRegistry:
ref, err := registry.ParseReference(reference)
if err != nil {
return ocispec.Descriptor{}, "", fmt.Errorf("failed to resolve user input reference: %w", err)
return ocispec.Descriptor{}, "", fmt.Errorf("%q: %w. Expecting <registry>/<repository>:<tag> or <registry>/<repository>@<digest>", reference, err)
}
if ref.Reference == "" {
return ocispec.Descriptor{}, "", fmt.Errorf("%q: invalid reference: no tag or digest. Expecting <registry>/<repo>:<tag> or <registry>/<repo>@<digest>", reference)
}
tagOrDigestRef = ref.Reference
resolvedRef = ref.Registry + "/" + ref.Repository
Expand Down Expand Up @@ -113,16 +116,16 @@ func parseOCILayoutReference(raw string) (string, string, error) {
// find `tag`
idx := strings.LastIndex(raw, ":")
if idx == -1 || (idx == 1 && len(raw) > 2 && unicode.IsLetter(rune(raw[0])) && raw[2] == '\\') {
return "", "", notationerrors.ErrorOCILayoutMissingReference{}
return "", "", notationerrors.ErrorOCILayoutMissingReference{Msg: fmt.Sprintf("%q: invalid reference: missing tag or digest. Expecting <file_path>:<tag> or <file_path>@<digest>", raw)}
} else {
path, ref = raw[:idx], raw[idx+1:]
}
}
if path == "" {
return "", "", fmt.Errorf("found empty file path in %q", raw)
return "", "", fmt.Errorf("%q: invalid reference: missing oci-layout file path. Expecting <file_path>:<tag> or <file_path>@<digest>", raw)
}
if ref == "" {
return "", "", fmt.Errorf("found empty reference in %q", raw)
return "", "", notationerrors.ErrorOCILayoutMissingReference{Msg: fmt.Sprintf("%q: invalid reference: missing tag or digest. Expecting <file_path>:<tag> or <file_path>@<digest>", raw)}
}
return path, ref, nil
}
Expand Down
Loading
Loading