-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hash component command * hash components in various flavours * improve online help for intermediate commands * make format work under IDE * fix accept header creation for oci blob access header with empty mediatype not accepted by Artifactory.
- Loading branch information
1 parent
628f105
commit 957d42a
Showing
30 changed files
with
880 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,4 @@ | ||
|
||
- [X] Transfer should support force option for override | ||
- [ ] Clarify how to list digests in (oci) ctf and artifact set under common oci API abstraction | ||
- [ ] Align OCI and OCM Repository Name with type structure and reference syntax | ||
- [ ] Aligned Denotation for OCM and OCI elements | ||
- [X] Generalize Sort Field Detection and check | ||
- first ugly implementation done | ||
- [ ] Artifact download with side artifacts (based on dedicated option) | ||
- [ ] Rework option complete handling with sessions | ||
- [ ] Rework Processing Chain/Iterable to work go-like with channels | ||
- [ ] Generic History based sort function to be used to transform object sequence for tree output | ||
- [ ] Recursion + Tree mode for OCI Indices | ||
- [ ] Better separation between typehandler/chain and chain/output | ||
- [X] Rework digest handling based on Resource Type and Access Method Spec | ||
- first cut and reorg done | ||
- [X] Complete handling of all possible input variations for the various CLI commands. | ||
- [X] Add signature handling | ||
- [ ] Identify required scenarios for OCM transport handling and improve transport handler accordingly | ||
- [ ] Add type factories for generic spec | ||
- [ ] Provide size and digest info for OCM blob access | ||
- [ ] CD validation for sources enforces git | ||
- [ ] decide on and introduce logging framework | ||
- [ ] add optional reference name to resource input | ||
- [ ] remove registry from default output and show only with wide output option (get artifact) | ||
- [ ] error handling for applying config (especially usage of ErrNoContext) | ||
- [X] migrate resource add input spec to typed spec | ||
- [X] Add Close method to access method to support external resource management |
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
82 changes: 82 additions & 0 deletions
82
cmds/ocm/commands/ocmcmds/common/options/hashoption/option.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,82 @@ | ||
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package hashoption | ||
|
||
import ( | ||
"github.com/spf13/pflag" | ||
|
||
"github.com/open-component-model/ocm/cmds/ocm/pkg/options" | ||
"github.com/open-component-model/ocm/cmds/ocm/pkg/utils" | ||
"github.com/open-component-model/ocm/pkg/contexts/clictx" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/signingattr" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/normalizations/jsonv1" | ||
ocmsign "github.com/open-component-model/ocm/pkg/contexts/ocm/signing" | ||
"github.com/open-component-model/ocm/pkg/errors" | ||
"github.com/open-component-model/ocm/pkg/signing" | ||
"github.com/open-component-model/ocm/pkg/signing/hasher/sha256" | ||
) | ||
|
||
func From(o options.OptionSetProvider) *Option { | ||
var opt *Option | ||
o.AsOptionSet().Get(&opt) | ||
return opt | ||
} | ||
|
||
var _ options.Options = (*Option)(nil) | ||
|
||
func New() *Option { | ||
return &Option{} | ||
} | ||
|
||
type Option struct { | ||
Hasher signing.Hasher | ||
NormAlgorithm string | ||
hashAlgorithm string | ||
} | ||
|
||
func (o *Option) AddFlags(fs *pflag.FlagSet) { | ||
fs.StringVarP(&o.NormAlgorithm, "normalization", "N", jsonv1.Algorithm, "normalization algorithm") | ||
fs.StringVarP(&o.hashAlgorithm, "hash", "H", sha256.Algorithm, "hash algorithm") | ||
} | ||
|
||
func (o *Option) Complete(ctx clictx.Context) error { | ||
if o.NormAlgorithm == "" { | ||
o.NormAlgorithm = jsonv1.Algorithm | ||
} | ||
if o.hashAlgorithm == "" { | ||
o.hashAlgorithm = sha256.Algorithm | ||
} | ||
x := compdesc.Normalizations.Get(o.NormAlgorithm) | ||
if x == nil { | ||
return errors.ErrUnknown(compdesc.KIND_NORM_ALGORITHM, o.NormAlgorithm) | ||
} | ||
o.Hasher = signingattr.Get(ctx).GetHasher(o.hashAlgorithm) | ||
if o.Hasher == nil { | ||
return errors.ErrUnknown(compdesc.KIND_HASH_ALGORITHM, o.hashAlgorithm) | ||
} | ||
return nil | ||
} | ||
|
||
func (o *Option) Usage() string { | ||
s := ` | ||
The following normalization modes are supported with option <code>--normalization</code>: | ||
` + utils.FormatList(jsonv1.Algorithm, compdesc.Normalizations.Names()...) | ||
|
||
s += ` | ||
The following hash modes are supported with option <code>--hash</code>: | ||
` + utils.FormatList(sha256.Algorithm, signing.DefaultRegistry().HasherNames()...) | ||
|
||
signing.DefaultRegistry().HasherNames() | ||
return s | ||
} | ||
|
||
var _ ocmsign.Option = (*Option)(nil) | ||
|
||
func (o *Option) ApplySigningOption(opts *ocmsign.Options) { | ||
opts.NormalizationAlgo = o.NormAlgorithm | ||
opts.Hasher = o.Hasher | ||
} |
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
Oops, something went wrong.