get.porter.sh/porter@v1.3.0/pkg/config/datastore.go (about)

     1  package config
     2  
     3  const (
     4  	// BuildDriverDocker is no longer supported.
     5  	BuildDriverDocker = "docker"
     6  
     7  	// BuildDriverBuildkit is the configuration value for specifying BuildKit as
     8  	// the build driver.
     9  	BuildDriverBuildkit = "buildkit"
    10  
    11  	// RuntimeDriverDocker specifies that the bundle image should be executed on docker.
    12  	RuntimeDriverDocker = "docker"
    13  
    14  	// RuntimeDriverKubernetes specifies that the bundle image should be executed on kubernetes.
    15  	RuntimeDriverKubernetes = "kubernetes"
    16  )
    17  
    18  // Data is the data stored in PORTER_HOME/porter.toml|yaml|json.
    19  // Use the accessor functions to ensure default values are handled properly.
    20  type Data struct {
    21  	// Only define fields here that you need to access from code
    22  	// Values are dynamically applied to flags and don't need to be defined
    23  
    24  	// BuildDriver is the driver to use when building bundles.
    25  	// Available values are: buildkit.
    26  	// Do not use directly, use Config.GetBuildDriver.
    27  	BuildDriver string `mapstructure:"build-driver"`
    28  
    29  	// RuntimeDriver is the driver to use when executing bundles.
    30  	// Available values are: docker, kubernetes.
    31  	// It is both a global variable and a command flag because some of our commands, like porter installation apply,
    32  	// do not expose all the bundle execution flags. This allows us to later manually use the global config value
    33  	// to ensure that the global config value works even for those commands.
    34  	RuntimeDriver string `mapstructure:"runtime-driver"`
    35  
    36  	// ForceOverwrite specifies OCI artifacts can be overwritten when pushed.
    37  	// By default, Porter requires the --force flag to be specified to overwrite a bundle or image.
    38  	ForceOverwrite bool `mapstructure:"force-overwrite"`
    39  
    40  	// AllowDockerHostAccess grants bundles access to the underlying docker host
    41  	// upon which it is running so that it can do things like build and run containers.
    42  	// It's a security risk.
    43  	// It is both a global variable and a command flag because some of our commands, like porter installation apply,
    44  	// do not expose all the bundle execution flags. This allows us to later manually use the global config value
    45  	// to ensure that the global config value works even for those commands.
    46  	AllowDockerHostAccess bool `mapstructure:"allow-docker-host-access"`
    47  
    48  	// DefaultStoragePlugin is the storage plugin to use when no named storage is specified.
    49  	DefaultStoragePlugin string `mapstructure:"default-storage-plugin"`
    50  
    51  	// DefaultStorage to use when a named storage is not specified by a flag.
    52  	DefaultStorage string `mapstructure:"default-storage"`
    53  
    54  	// ExperimentalFlags is a list of enabled experimental.FeatureFlags.
    55  	// Use Config.IsFeatureEnabled instead of parsing directly.
    56  	ExperimentalFlags []string `mapstructure:"experimental"`
    57  
    58  	// StoragePlugins defined in the configuration file.
    59  	StoragePlugins []StoragePlugin `mapstructure:"storage"`
    60  
    61  	// DefaultSecretsPlugin is the plugin to use when no plugin is specified.
    62  	DefaultSecretsPlugin string `mapstructure:"default-secrets-plugin"`
    63  
    64  	// DefaultSecrets to use when one is not specified by a flag.
    65  	DefaultSecrets string `mapstructure:"default-secrets"`
    66  
    67  	// DefaultSigningPlugin is the plugin to use when no plugin is specified.
    68  	DefaultSigningPlugin string `mapstructure:"default-signing-plugin"`
    69  
    70  	// DefaultSigning to use when one is not specified by a flag.
    71  	DefaultSigning string `mapstructure:"default-signer"`
    72  
    73  	// Namespace is the default namespace for commands that do not override it with a flag.
    74  	Namespace string `mapstructure:"namespace"`
    75  
    76  	// SecretsPlugin defined in the configuration file.
    77  	SecretsPlugin []SecretsPlugin `mapstructure:"secrets"`
    78  
    79  	// SigningPlugin defined in the configuration file.
    80  	SigningPlugin []SigningPlugin `mapstructure:"signers"`
    81  
    82  	// Logs are settings related to Porter's log files.
    83  	Logs LogConfig `mapstructure:"logs"`
    84  
    85  	// Telemetry are settings related to Porter's tracing with open telemetry.
    86  	Telemetry TelemetryConfig `mapstructure:"telemetry"`
    87  
    88  	// SchemaCheck specifies how strict Porter should be when comparing the
    89  	// schemaVersion field on a resource with the supported schemaVersion.
    90  	// Supported values are: exact, minor, major, none.
    91  	SchemaCheck string `mapstructure:"schema-check"`
    92  
    93  	// Verbosity controls the level of messages output to the console.
    94  	// Use Logs.LogLevel if you want to change what is output to the logfile.
    95  	// Traces sent to an OpenTelemetry collector always include all levels of messages.
    96  	Verbosity string `mapstructure:"verbosity"`
    97  }
    98  
    99  // DefaultDataStore used when no config file is found.
   100  func DefaultDataStore() Data {
   101  	return Data{
   102  		BuildDriver:          BuildDriverBuildkit,
   103  		RuntimeDriver:        RuntimeDriverDocker,
   104  		DefaultStoragePlugin: "mongodb-docker",
   105  		DefaultSecretsPlugin: "host",
   106  		DefaultSigningPlugin: "",
   107  		Logs:                 LogConfig{Level: "info"},
   108  		Verbosity:            DefaultVerbosity,
   109  	}
   110  }
   111  
   112  // SigningPlugin is the plugin stanza for signing.
   113  type SigningPlugin struct {
   114  	PluginConfig `mapstructure:",squash"`
   115  }
   116  
   117  // SecretsPlugin is the plugin stanza for secrets.
   118  type SecretsPlugin struct {
   119  	PluginConfig `mapstructure:",squash"`
   120  }
   121  
   122  // StoragePlugin is the plugin stanza for storage.
   123  type StoragePlugin struct {
   124  	PluginConfig `mapstructure:",squash"`
   125  }
   126  
   127  // PluginConfig is a standardized config stanza that defines which plugin to
   128  // use and its custom configuration.
   129  type PluginConfig struct {
   130  	Name         string                 `mapstructure:"name"`
   131  	PluginSubKey string                 `mapstructure:"plugin"`
   132  	Config       map[string]interface{} `mapstructure:"config"`
   133  }
   134  
   135  func (p PluginConfig) GetName() string {
   136  	return p.Name
   137  }
   138  
   139  func (p PluginConfig) GetPluginSubKey() string {
   140  	return p.PluginSubKey
   141  }
   142  
   143  func (p PluginConfig) GetConfig() interface{} {
   144  	return p.Config
   145  }