Skip to content

Commit 221bd43

Browse files
feat: add globalsopssecret api (#172)
* feat: add globalsopssecret api Signed-off-by: Oliver Bähler <[email protected]> * feat: add globalsopssecret api Signed-off-by: Oliver Bähler <[email protected]> * feat: add globalsopssecret api Signed-off-by: Oliver Bähler <[email protected]> --------- Signed-off-by: Oliver Bähler <[email protected]>
1 parent 939092e commit 221bd43

24 files changed

+2048
-583
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ linters:
2424
- unparam
2525
- varnamelen
2626
- wrapcheck
27+
- goconst
2728
settings:
2829
cyclop:
2930
max-complexity: 27

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ e2e-init: sops openbao
238238
$(SOPS) -e secret-quorum.yaml > secret-quorum.enc.yaml';
239239

240240

241-
242241
e2e-destroy: kind
243242
$(KIND) delete cluster --name $(CLUSTER_NAME)
244243

PROJECT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,11 @@ resources:
2323
kind: SopsSecret
2424
path: github.com/peak-scale/sops-operator/api/v1alpha1
2525
version: v1alpha1
26+
- api:
27+
crdVersion: v1
28+
domain: projectcapsule.dev
29+
group: addons
30+
kind: GlobalSopsSecret
31+
path: github.com/peak-scale/sops-operator/api/v1alpha1
32+
version: v1alpha1
2633
version: "3"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Copyright 2024-2025 Peak Scale
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package v1alpha1
7+
8+
import (
9+
"github.com/peak-scale/sops-operator/internal/api"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
)
12+
13+
// SopsSecretSpec defines the desired state of SopsSecret.
14+
type GlobalSopsSecretSpec struct {
15+
// Define Secrets to replicate, when secret is decrypted
16+
Secrets []*GlobalSopsSecretItem `json:"secrets"`
17+
}
18+
19+
// GlobalSopsSecretItem defines the desired state of GlobalSopsSecret.
20+
type GlobalSopsSecretItem struct {
21+
// Namespace must be declared since this is a cluster scoped resource
22+
Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"`
23+
24+
SopsSecretItem `json:",inline"`
25+
}
26+
27+
func (s *GlobalSopsSecret) GetSopsMetadata() *api.Metadata {
28+
return s.Sops
29+
}
30+
31+
// +kubebuilder:object:root=true
32+
// +kubebuilder:subresource:status
33+
// +kubebuilder:resource:scope=Cluster
34+
// +kubebuilder:printcolumn:name="Secrets",type="integer",JSONPath=".status.size",description="The amount of secrets being managed"
35+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.condition.type",description="The actual state of the GlobalSopsSecret"
36+
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.condition.message",description="Condition Message"
37+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
38+
39+
// GlobalSopsSecret is the Schema for the globalsopssecrets API.
40+
type GlobalSopsSecret struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec GlobalSopsSecretSpec `json:"spec,omitempty"`
45+
Status SopsSecretStatus `json:"status,omitempty"`
46+
Sops *api.Metadata `json:"sops"`
47+
}
48+
49+
// +kubebuilder:object:root=true
50+
51+
// GlobalSopsSecretList contains a list of GlobalSopsSecret.
52+
type GlobalSopsSecretList struct {
53+
metav1.TypeMeta `json:",inline"`
54+
metav1.ListMeta `json:"metadata,omitempty"`
55+
Items []GlobalSopsSecret `json:"items"`
56+
}
57+
58+
func init() {
59+
SchemeBuilder.Register(&GlobalSopsSecret{}, &GlobalSopsSecretList{})
60+
}

api/v1alpha1/sopssecret_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ type SopsSecretItem struct {
6666
Immutable *bool `json:"immutable,omitempty" protobuf:"varint,5,opt,name=immutable"`
6767
}
6868

69+
func (s *SopsSecret) GetSopsMetadata() *api.Metadata {
70+
return s.Sops
71+
}
72+
6973
// +kubebuilder:object:root=true
7074
// +kubebuilder:subresource:status
7175
// +kubebuilder:printcolumn:name="Secrets",type="integer",JSONPath=".status.size",description="The amount of secrets being managed"
72-
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.condition.type",description="The actual state of the Tenant"
76+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.condition.type",description="The actual state of the SopsSecret"
7377
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.condition.message",description="Condition Message"
7478
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
7579

@@ -80,7 +84,7 @@ type SopsSecret struct {
8084

8185
Spec SopsSecretSpec `json:"spec,omitempty"`
8286
Status SopsSecretStatus `json:"status,omitempty"`
83-
Sops *api.Metadata `json:"sops,omitempty"`
87+
Sops *api.Metadata `json:"sops"`
8488
}
8589

8690
// +kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)