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

feat: support --format in manifest fetch command #1295

Merged
merged 46 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
67dad87
feat: support `--format` in `manifest fetch` command
qweeah Mar 18, 2024
fa0f2a1
add comment
qweeah Mar 18, 2024
d832fbe
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Mar 19, 2024
3669aff
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Mar 19, 2024
fc2bccc
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 1, 2024
e9c1226
refactor
qweeah Apr 1, 2024
9c73b0d
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 1, 2024
6614c92
use new printer
qweeah Apr 1, 2024
eb5f62d
bug fix
qweeah Apr 1, 2024
ce6bc89
fix struct fields with json tags
qweeah Apr 2, 2024
5dc8583
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 3, 2024
c13ee29
remove raw discarder
qweeah Apr 3, 2024
4b1e2f9
fix e2e
qweeah Apr 3, 2024
5689580
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 7, 2024
c7488d6
fix e2e
qweeah Apr 7, 2024
42ab0a3
refactor
qweeah Apr 7, 2024
d954405
add discard handler for raw output
qweeah Apr 7, 2024
00a5895
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 7, 2024
7460060
revert focus
qweeah Apr 7, 2024
de6acf1
rename to content handler
qweeah Apr 7, 2024
4709b62
fix e2e
qweeah Apr 7, 2024
3fcab69
add e2e
qweeah Apr 7, 2024
f8c2dbf
fix e2e
qweeah Apr 7, 2024
90a3141
use unmarshal and enhance e2e
qweeah Apr 8, 2024
ca0f082
code clean
qweeah Apr 8, 2024
a1addb4
resolve comments
qweeah Apr 8, 2024
998ad76
fix e2e
qweeah Apr 8, 2024
f93ba89
code clean
qweeah Apr 8, 2024
e66ed8e
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 8, 2024
a7656be
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 8, 2024
b54a2e6
code clean
qweeah Apr 8, 2024
e682458
code clean
qweeah Apr 8, 2024
faa8c63
code clean
qweeah Apr 8, 2024
9c3a426
Merge remote-tracking branch 'upstream/main' into format-manifest-fetch
qweeah Apr 9, 2024
4eb5b9f
add fetched model
qweeah Apr 10, 2024
3cbbf9b
add experimental mark
qweeah Apr 10, 2024
7b09792
fix e2e
qweeah Apr 10, 2024
cb98a26
fix e2e
qweeah Apr 10, 2024
6615478
resolve comments
qweeah Apr 10, 2024
a8c3de8
add json test
qweeah Apr 10, 2024
1dfd284
fix e2e
qweeah Apr 10, 2024
dfb8dce
resolve comments
qweeah Apr 10, 2024
6c5e2cf
resolve comments
qweeah Apr 10, 2024
bb69b39
add e2e coverage
qweeah Apr 10, 2024
57d2078
remove used code
qweeah Apr 10, 2024
4ec65f9
use create file instead of open file
qweeah Apr 10, 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
4 changes: 1 addition & 3 deletions cmd/oras/internal/display/metadata/json/manifest_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func NewManifestFetchHandler(out io.Writer) metadata.ManifestFetchHandler {
// OnFetched is called after the manifest fetch is completed.
func (h *manifestFetchHandler) OnFetched(path string, desc ocispec.Descriptor, content []byte) error {
var manifest map[string]any
if err := json.Unmarshal(content, &manifest); err != nil {
return err
}
_ = json.Unmarshal(content, &manifest)
return printJSON(h.out, model.NewFetched(path, desc, manifest))
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func NewManifestFetchHandler(out io.Writer, template string) metadata.ManifestFe
// OnFetched is called after the manifest fetch is completed.
func (h *manifestFetchHandler) OnFetched(path string, desc ocispec.Descriptor, content []byte) error {
var manifest map[string]any
if err := json.Unmarshal(content, &manifest); err != nil {
return err
}
// return parseAndWrite(h.out, model.ToMappable(reflect.ValueOf(manifest)), h.template)
_ = json.Unmarshal(content, &manifest)
return parseAndWrite(h.out, model.NewFetched(path, desc, manifest), h.template)
}
6 changes: 3 additions & 3 deletions cmd/oras/root/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':

cmd.Flags().StringSliceVarP(&opts.mediaTypes, "media-type", "", nil, "accepted media types")
cmd.Flags().StringVarP(&opts.outputPath, "output", "o", "", "file `path` to write the fetched manifest to, use - for stdout")
cmd.Flags().StringVar(&opts.Template, "format", "", `[Experimental] Format fetched manifest using a custom template:
'json': Print manifest in prettified JSON format
'$TEMPLATE': Print output using the given Go template.`)
cmd.Flags().StringVar(&opts.Template, "format", "", `[Experimental] Format operation metadata using a custom template:
'json': Print in prettified JSON format
'$TEMPLATE': Print using the given Go template.`)
option.ApplyFlags(&opts, cmd.Flags())
return oerrors.Command(cmd, &opts.Target)
}
Expand Down
Loading