-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refactor-console
- Loading branch information
Showing
44 changed files
with
1,700 additions
and
259 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
39 changes: 39 additions & 0 deletions
39
cmd/oras/internal/display/metadata/text/manifest_index_create.go
This file contains 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,39 @@ | ||
/* | ||
Copyright The ORAS 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 text | ||
|
||
import ( | ||
ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||
"oras.land/oras/cmd/oras/internal/display/metadata" | ||
"oras.land/oras/cmd/oras/internal/output" | ||
) | ||
|
||
// ManifestIndexCreateHandler handles text metadata output for index create events. | ||
type ManifestIndexCreateHandler struct { | ||
printer *output.Printer | ||
} | ||
|
||
// NewManifestIndexCreateHandler returns a new handler for index create events. | ||
func NewManifestIndexCreateHandler(printer *output.Printer) metadata.ManifestIndexCreateHandler { | ||
return &ManifestIndexCreateHandler{ | ||
printer: printer, | ||
} | ||
} | ||
|
||
// OnTagged implements metadata.TaggedHandler. | ||
func (h *ManifestIndexCreateHandler) OnTagged(_ ocispec.Descriptor, tag string) error { | ||
return h.printer.Println("Tagged", tag) | ||
} |
This file contains 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
This file contains 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,67 @@ | ||
/* | ||
Copyright The ORAS 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 option | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
oerrors "oras.land/oras/cmd/oras/internal/errors" | ||
) | ||
|
||
var ( | ||
errAnnotationFormat = errors.New("annotation value doesn't match the required format") | ||
errAnnotationDuplication = errors.New("duplicate annotation key") | ||
) | ||
|
||
// Annotation option struct. | ||
type Annotation struct { | ||
// ManifestAnnotations contains raw input of manifest annotation "key=value" pairs | ||
ManifestAnnotations []string | ||
|
||
// Annotations contains parsed manifest and config annotations | ||
Annotations map[string]map[string]string | ||
} | ||
|
||
// ApplyFlags applies flags to a command flag set. | ||
func (opts *Annotation) ApplyFlags(fs *pflag.FlagSet) { | ||
fs.StringArrayVarP(&opts.ManifestAnnotations, "annotation", "a", nil, "manifest annotations") | ||
} | ||
|
||
// Parse parses the input annotation flags. | ||
func (opts *Annotation) Parse(*cobra.Command) error { | ||
manifestAnnotations := make(map[string]string) | ||
for _, anno := range opts.ManifestAnnotations { | ||
key, val, success := strings.Cut(anno, "=") | ||
if !success { | ||
return &oerrors.Error{ | ||
Err: errAnnotationFormat, | ||
Recommendation: `Please use the correct format in the flag: --annotation "key=value"`, | ||
} | ||
} | ||
if _, ok := manifestAnnotations[key]; ok { | ||
return fmt.Errorf("%w: %v, ", errAnnotationDuplication, key) | ||
} | ||
manifestAnnotations[key] = val | ||
} | ||
opts.Annotations = map[string]map[string]string{ | ||
AnnotationManifest: manifestAnnotations, | ||
} | ||
return nil | ||
} |
This file contains 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
Oops, something went wrong.