-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.go
More file actions
85 lines (69 loc) · 3.21 KB
/
Copy pathconfig.go
File metadata and controls
85 lines (69 loc) · 3.21 KB
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
// Copyright (C) 2026 ingress-anubis contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0
// Package config contains the configuration.
package config
import "github.com/caarlos0/env/v11"
// Config contains the configuration
type Config struct {
// Namespace that the ingress controller is running in and should
// create resources in.
Namespace string `env:"NAMESPACE" envDefault:"ingress-anubis"`
// AnubisVersion is the version of Anubis to use. If not set, then the
// latest version known to the controller at build time will be used.
//renovate: datasource=github-tags depName=anubis packageName=techarohq/anubis
AnubisVersion string `env:"ANUBIS_VERSION" envDefault:"v1.27.0"`
// AnubisImage is the docker image to use, note that the version (tag)
// comes from [Config.AnubisVersion].
AnubisImage string `env:"ANUBIS_IMAGE" envDefault:"ghcr.io/techarohq/anubis"`
// IngressClassName is the ingress class name that Anubis itself
// should use.
IngressClassName string `env:"INGRESS_CLASS_NAME" envDefault:"anubis"`
// WrappedIngressClassName is the name of the ingressClass to use for
// the ingress managed by anubis. While this is configurable, only
// nginx has been tested (though, in theory, any should work).
WrappedIngressClassName string `env:"WRAPPED_INGRESS_CLASS_NAME" envDefault:"nginx"`
// LeaderElection enables or disables leader election. This should
// usually always be on.
LeaderElection bool `env:"LEADER_ELECTION" envDefault:"true"`
// Annotations is a map of annotations to set on the managed Anubis
// pod. Example:
//
// ANNOTATIONS="prometheus.io/scrape:true,hello.world/a-thing:1"
Annotations map[string]string `env:"ANNOTATIONS"`
// EnvironmentVariables is a map of environment variables to set on
// the manages Anubis pod. See [Annotations] for an example of the
// expected format.
EnvironmentVariables map[string]string `env:"ENVIRONMENT_VARIABLES"`
// EnvFromCM is a global version of IngressConfig.EnvFromCM
EnvFromCM string `env:"ENV_FROM_CM"`
// EnvFromSec is a global version of IngressConfig.EnvFromSec
EnvFromSec string `env:"ENV_FROM_SEC"`
// Volumes is JSON representation of the associated Kubernetes
// field applied to the created anubis instances.
Volumes string `env:"VOLUMES"`
// VolumeMounts is JSON representation of the associated Kubernetes
// field applied to the created anubis instances.
VolumeMounts string `env:"VOLUME_MOUNTS"`
}
// Load returns a configuration object from the environment.
func Load() (*Config, error) {
var cfg Config
if err := env.Parse(&cfg); err != nil {
return nil, err
}
return &cfg, nil
}