-
Notifications
You must be signed in to change notification settings - Fork 18
/
accessspec_options.go
64 lines (47 loc) · 1.59 KB
/
accessspec_options.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
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
package cpi
import (
"github.com/open-component-model/ocm/v2/pkg/cobrautils/flagsets"
)
////////////////////////////////////////////////////////////////////////////////
// Access Type Options
type AccessSpecOptionTarget interface {
SetFormat(string)
SetDescription(string)
SetConfigHandler(flagsets.ConfigOptionTypeSetHandler)
}
type AccessSpecTypeOption interface {
ApplyToAccessSpecOptionTarget(AccessSpecOptionTarget)
}
////////////////////////////////////////////////////////////////////////////////
type formatOption struct {
value string
}
func WithFormatSpec(value string) AccessSpecTypeOption {
return formatOption{value}
}
func (o formatOption) ApplyToAccessSpecOptionTarget(t AccessSpecOptionTarget) {
t.SetFormat(o.value)
}
////////////////////////////////////////////////////////////////////////////////
type descriptionOption struct {
value string
}
func WithDescription(value string) AccessSpecTypeOption {
return descriptionOption{value}
}
func (o descriptionOption) ApplyToAccessSpecOptionTarget(t AccessSpecOptionTarget) {
t.SetDescription(o.value)
}
////////////////////////////////////////////////////////////////////////////////
type configOption struct {
value flagsets.ConfigOptionTypeSetHandler
}
func WithConfigHandler(value flagsets.ConfigOptionTypeSetHandler) AccessSpecTypeOption {
return configOption{value}
}
func (o configOption) ApplyToAccessSpecOptionTarget(t AccessSpecOptionTarget) {
t.SetConfigHandler(o.value)
}