-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
options.go
87 lines (70 loc) · 2.59 KB
/
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (C) 2022 The Flux authors
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
package keyservice
import (
extage "filippo.io/age"
"github.com/getsops/sops/v3/age"
"github.com/getsops/sops/v3/azkv"
"github.com/getsops/sops/v3/gcpkms"
"github.com/getsops/sops/v3/hcvault"
"github.com/getsops/sops/v3/keyservice"
"github.com/getsops/sops/v3/kms"
"github.com/getsops/sops/v3/pgp"
)
// ServerOption is some configuration that modifies the Server.
type ServerOption interface {
// ApplyToServer applies this configuration to the given Server.
ApplyToServer(s *Server)
}
// WithGnuPGHome configures the GnuPG home directory on the Server.
type WithGnuPGHome string
// ApplyToServer applies this configuration to the given Server.
func (o WithGnuPGHome) ApplyToServer(s *Server) {
s.gnuPGHome = pgp.GnuPGHome(o)
}
// WithVaultToken configures the Hashicorp Vault token on the Server.
type WithVaultToken string
// ApplyToServer applies this configuration to the given Server.
func (o WithVaultToken) ApplyToServer(s *Server) {
s.vaultToken = hcvault.Token(o)
}
// WithAgeIdentities configures the parsed age identities on the Server.
type WithAgeIdentities []extage.Identity
// ApplyToServer applies this configuration to the given Server.
func (o WithAgeIdentities) ApplyToServer(s *Server) {
s.ageIdentities = age.ParsedIdentities(o)
}
// WithAWSKeys configures the AWS credentials on the Server
type WithAWSKeys struct {
CredsProvider *kms.CredentialsProvider
}
// ApplyToServer applies this configuration to the given Server.
func (o WithAWSKeys) ApplyToServer(s *Server) {
s.awsCredsProvider = o.CredsProvider
}
// WithGCPCredsJSON configures the GCP service account credentials JSON on the
// Server.
type WithGCPCredsJSON []byte
// ApplyToServer applies this configuration to the given Server.
func (o WithGCPCredsJSON) ApplyToServer(s *Server) {
s.gcpCredsJSON = gcpkms.CredentialJSON(o)
}
// WithAzureToken configures the Azure credential token on the Server.
type WithAzureToken struct {
Token *azkv.TokenCredential
}
// ApplyToServer applies this configuration to the given Server.
func (o WithAzureToken) ApplyToServer(s *Server) {
s.azureToken = o.Token
}
// WithDefaultServer configures the fallback default server on the Server.
type WithDefaultServer struct {
Server keyservice.KeyServiceServer
}
// ApplyToServer applies this configuration to the given Server.
func (o WithDefaultServer) ApplyToServer(s *Server) {
s.defaultServer = o.Server
}