-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathdatastore.go
145 lines (113 loc) · 5.61 KB
/
datastore.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package config
const (
// BuildDriverDocker is no longer supported.
BuildDriverDocker = "docker"
// BuildDriverBuildkit is the configuration value for specifying BuildKit as
// the build driver.
BuildDriverBuildkit = "buildkit"
// RuntimeDriverDocker specifies that the bundle image should be executed on docker.
RuntimeDriverDocker = "docker"
// RuntimeDriverKubernetes specifies that the bundle image should be executed on kubernetes.
RuntimeDriverKubernetes = "kubernetes"
)
// Data is the data stored in PORTER_HOME/porter.toml|yaml|json.
// Use the accessor functions to ensure default values are handled properly.
type Data struct {
// Only define fields here that you need to access from code
// Values are dynamically applied to flags and don't need to be defined
// BuildDriver is the driver to use when building bundles.
// Available values are: buildkit.
// Do not use directly, use Config.GetBuildDriver.
BuildDriver string `mapstructure:"build-driver"`
// RuntimeDriver is the driver to use when executing bundles.
// Available values are: docker, kubernetes.
// It is both a global variable and a command flag because some of our commands, like porter installation apply,
// do not expose all the bundle execution flags. This allows us to later manually use the global config value
// to ensure that the global config value works even for those commands.
RuntimeDriver string `mapstructure:"runtime-driver"`
// ForceOverwrite specifies OCI artifacts can be overwritten when pushed.
// By default, Porter requires the --force flag to be specified to overwrite a bundle or image.
ForceOverwrite bool `mapstructure:"force-overwrite"`
// AllowDockerHostAccess grants bundles access to the underlying docker host
// upon which it is running so that it can do things like build and run containers.
// It's a security risk.
// It is both a global variable and a command flag because some of our commands, like porter installation apply,
// do not expose all the bundle execution flags. This allows us to later manually use the global config value
// to ensure that the global config value works even for those commands.
AllowDockerHostAccess bool `mapstructure:"allow-docker-host-access"`
// DefaultStoragePlugin is the storage plugin to use when no named storage is specified.
DefaultStoragePlugin string `mapstructure:"default-storage-plugin"`
// DefaultStorage to use when a named storage is not specified by a flag.
DefaultStorage string `mapstructure:"default-storage"`
// ExperimentalFlags is a list of enabled experimental.FeatureFlags.
// Use Config.IsFeatureEnabled instead of parsing directly.
ExperimentalFlags []string `mapstructure:"experimental"`
// StoragePlugins defined in the configuration file.
StoragePlugins []StoragePlugin `mapstructure:"storage"`
// DefaultSecretsPlugin is the plugin to use when no plugin is specified.
DefaultSecretsPlugin string `mapstructure:"default-secrets-plugin"`
// DefaultSecrets to use when one is not specified by a flag.
DefaultSecrets string `mapstructure:"default-secrets"`
// DefaultSigningPlugin is the plugin to use when no plugin is specified.
DefaultSigningPlugin string `mapstructure:"default-signing-plugin"`
// DefaultSigning to use when one is not specified by a flag.
DefaultSigning string `mapstructure:"default-signer"`
// Namespace is the default namespace for commands that do not override it with a flag.
Namespace string `mapstructure:"namespace"`
// SecretsPlugin defined in the configuration file.
SecretsPlugin []SecretsPlugin `mapstructure:"secrets"`
// SigningPlugin defined in the configuration file.
SigningPlugin []SigningPlugin `mapstructure:"signers"`
// Logs are settings related to Porter's log files.
Logs LogConfig `mapstructure:"logs"`
// Telemetry are settings related to Porter's tracing with open telemetry.
Telemetry TelemetryConfig `mapstructure:"telemetry"`
// SchemaCheck specifies how strict Porter should be when comparing the
// schemaVersion field on a resource with the supported schemaVersion.
// Supported values are: exact, minor, major, none.
SchemaCheck string `mapstructure:"schema-check"`
// Verbosity controls the level of messages output to the console.
// Use Logs.LogLevel if you want to change what is output to the logfile.
// Traces sent to an OpenTelemetry collector always include all levels of messages.
Verbosity string `mapstructure:"verbosity"`
}
// DefaultDataStore used when no config file is found.
func DefaultDataStore() Data {
return Data{
BuildDriver: BuildDriverBuildkit,
RuntimeDriver: RuntimeDriverDocker,
DefaultStoragePlugin: "mongodb-docker",
DefaultSecretsPlugin: "host",
DefaultSigningPlugin: "",
Logs: LogConfig{Level: "info"},
Verbosity: DefaultVerbosity,
}
}
// SigningPlugin is the plugin stanza for signing.
type SigningPlugin struct {
PluginConfig `mapstructure:",squash"`
}
// SecretsPlugin is the plugin stanza for secrets.
type SecretsPlugin struct {
PluginConfig `mapstructure:",squash"`
}
// StoragePlugin is the plugin stanza for storage.
type StoragePlugin struct {
PluginConfig `mapstructure:",squash"`
}
// PluginConfig is a standardized config stanza that defines which plugin to
// use and its custom configuration.
type PluginConfig struct {
Name string `mapstructure:"name"`
PluginSubKey string `mapstructure:"plugin"`
Config map[string]interface{} `mapstructure:"config"`
}
func (p PluginConfig) GetName() string {
return p.Name
}
func (p PluginConfig) GetPluginSubKey() string {
return p.PluginSubKey
}
func (p PluginConfig) GetConfig() interface{} {
return p.Config
}