-
Notifications
You must be signed in to change notification settings - Fork 18
/
modopts.go
97 lines (74 loc) · 2.95 KB
/
modopts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package ocm
import (
"github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/hashattr"
"github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/signingattr"
"github.com/open-component-model/ocm/pkg/contexts/ocm/internal"
"github.com/open-component-model/ocm/pkg/signing/hasher/sha256"
)
type (
ModificationOption = internal.ModificationOption
ModificationOptions = internal.ModificationOptions
BlobModificationOption = internal.BlobModificationOption
BlobModificationOptions = internal.BlobModificationOptions
BlobUploadOption = internal.BlobUploadOption
BlobUploadOptions = internal.BlobUploadOptions
AddVersionOption = internal.AddVersionOption
AddVersionOptions = internal.AddVersionOptions
)
////////////////////////////////////////////////////////////////////////////////
func NewAddVersionOptions(list ...AddVersionOption) *AddVersionOptions {
return internal.NewAddVersionOptions(list...)
}
// Overwrite enabled the overwrite mode for adding a component version.
func Overwrite(flag ...bool) AddVersionOption {
return internal.Overwrite(flag...)
}
////////////////////////////////////////////////////////////////////////////////
func NewBlobModificationOptions(list ...BlobModificationOption) *BlobModificationOptions {
return internal.NewBlobModificationOptions(list...)
}
////////////////////////////////////////////////////////////////////////////////
func NewBlobUploadOptions(list ...BlobUploadOption) *BlobUploadOptions {
return internal.NewBlobUploadOptions(list...)
}
func UseBlobHandlers(h BlobHandlerProvider) internal.BlobOptionImpl {
return internal.UseBlobHandlers(h)
}
////////////////////////////////////////////////////////////////////////////////
func NewModificationOptions(list ...ModificationOption) *ModificationOptions {
return internal.NewModificationOptions(list...)
}
func ModifyResource(flag ...bool) internal.ModOptionImpl {
return internal.ModifyResource(flag...)
}
func AcceptExistentDigests(flag ...bool) internal.ModOptionImpl {
return internal.AcceptExistentDigests(flag...)
}
func WithDefaultHashAlgorithm(algo ...string) internal.ModOptionImpl {
return internal.WithDefaultHashAlgorithm(algo...)
}
func WithHasherProvider(prov HasherProvider) internal.ModOptionImpl {
return internal.WithHasherProvider(prov)
}
func SkipVerify(flag ...bool) internal.ModOptionImpl {
return internal.SkipVerify(flag...)
}
// SkipDigest disables digest creation if enabled.
//
// Deprecated: for legacy code, only.
func SkipDigest(flag ...bool) internal.ModOptionImpl {
return internal.SkipDigest(flag...)
}
///////////////////////////////////////////////////////
func CompleteModificationOptions(ctx ContextProvider, m *ModificationOptions) {
attr := hashattr.Get(ctx.OCMContext())
if m.DefaultHashAlgorithm == "" {
m.DefaultHashAlgorithm = attr.DefaultHasher
}
if m.DefaultHashAlgorithm == "" {
m.DefaultHashAlgorithm = sha256.Algorithm
}
if m.HasherProvider == nil {
m.HasherProvider = signingattr.Get(ctx.OCMContext())
}
}