forked from RocketChat/k8s-secrets-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.go
81 lines (66 loc) · 1.8 KB
/
env.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
package main
import (
"os"
)
var (
// secret resources filters
secretName string
namespace string
labelKey string
labelValue string
// s3
bucketName string
s3folder string
s3region string
// aws creds
accessKeyID string
secretAccessKey string
// age
ageRecipientPublicKey string
)
func init() {
// secret resources filters
secretName = os.Getenv("SECRET_NAME")
namespace = os.Getenv("NAMESPACE")
if namespace == "" {
panic("please provide the environment variable NAMESPACE")
}
labelKey = os.Getenv("LABEL_KEY")
labelValue = os.Getenv("LABEL_VALUE")
if secretName == "" {
if labelKey == "" || labelValue == "" {
panic("please provide either the environmental variable SECRET_NAME or both environmental variables LABEL_KEY and LABEL_VALUE")
}
} else {
if labelKey != "" || labelValue != "" {
panic("please provide either the environmental variable SECRET_NAME or both environmental variables LABEL_KEY and LABEL_VALUE")
}
}
// s3
bucketName = os.Getenv("BUCKET_NAME")
if bucketName == "" {
panic("please provide the environment variable BUCKET_NAME")
}
s3folder = os.Getenv("S3_FOLDER")
if s3folder == "" {
panic("please provide the environment variable S3_FOLDER")
}
s3region = os.Getenv("S3_REGION")
if s3region == "" {
panic("please provide the environment variable S3_REGION")
}
// aws creds
accessKeyID = os.Getenv("AWS_ACCESS_KEY_ID")
if accessKeyID == "" {
panic("please provide the environment variable AWS_ACCESS_KEY_ID")
}
secretAccessKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
if secretAccessKey == "" {
panic("please provide the environment variable AWS_SECRET_ACCESS_KEY")
}
// age
ageRecipientPublicKey = os.Getenv("AGE_PUBLIC_KEY")
if ageRecipientPublicKey == "" {
panic("please provide the environment variable AGE_PUBLIC_KEY")
}
}