Secrets: Add GetType for KeeperSpec and clean-up unused Envelope (#107511)

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
This commit is contained in:
Matheus Macabu
2025-07-02 14:33:23 +02:00
committed by GitHub
co-authored by Michael Mandrus
parent 7614089077
commit b340b3fb7b
3 changed files with 51 additions and 31 deletions
+23 -3
View File
@@ -65,6 +65,22 @@ type KeeperSpec struct {
HashiCorp *HashiCorpKeeperConfig `json:"hashivault,omitempty"`
}
func (s *KeeperSpec) GetType() KeeperType {
if s.AWS != nil {
return AWSKeeperType
}
if s.Azure != nil {
return AzureKeeperType
}
if s.GCP != nil {
return GCPKeeperType
}
if s.HashiCorp != nil {
return HashiCorpKeeperType
}
return ""
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type KeeperList struct {
metav1.TypeMeta `json:",inline"`
@@ -102,9 +118,6 @@ type HashiCorpCredentials struct {
Token CredentialValue `json:"token"`
}
// Envelope encrytion details.
type Envelope struct{}
// Holds the way credentials are obtained.
// +union
type CredentialValue struct {
@@ -122,6 +135,13 @@ type CredentialValue struct {
ValueFromConfig string `json:"valueFromConfig,omitempty"`
}
// System Keeper.
type SystemKeeperConfig struct{}
func (s *SystemKeeperConfig) Type() KeeperType {
return "system"
}
// Remote Keepers.
type AWSKeeperConfig struct {
AWSCredentials `json:",inline"`
@@ -96,22 +96,6 @@ func (in *CredentialValue) DeepCopy() *CredentialValue {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Envelope) DeepCopyInto(out *Envelope) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Envelope.
func (in *Envelope) DeepCopy() *Envelope {
if in == nil {
return nil
}
out := new(Envelope)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GCPCredentials) DeepCopyInto(out *GCPCredentials) {
*out = *in
@@ -382,3 +366,19 @@ func (in *SecureValueStatus) DeepCopy() *SecureValueStatus {
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SystemKeeperConfig) DeepCopyInto(out *SystemKeeperConfig) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemKeeperConfig.
func (in *SystemKeeperConfig) DeepCopy() *SystemKeeperConfig {
if in == nil {
return nil
}
out := new(SystemKeeperConfig)
in.DeepCopyInto(out)
return out
}
@@ -20,7 +20,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.AzureCredentials": schema_pkg_apis_secret_v0alpha1_AzureCredentials(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.AzureKeeperConfig": schema_pkg_apis_secret_v0alpha1_AzureKeeperConfig(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.CredentialValue": schema_pkg_apis_secret_v0alpha1_CredentialValue(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.Envelope": schema_pkg_apis_secret_v0alpha1_Envelope(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.GCPCredentials": schema_pkg_apis_secret_v0alpha1_GCPCredentials(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.GCPKeeperConfig": schema_pkg_apis_secret_v0alpha1_GCPKeeperConfig(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.HashiCorpCredentials": schema_pkg_apis_secret_v0alpha1_HashiCorpCredentials(ref),
@@ -32,6 +31,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.SecureValueList": schema_pkg_apis_secret_v0alpha1_SecureValueList(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.SecureValueSpec": schema_pkg_apis_secret_v0alpha1_SecureValueSpec(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.SecureValueStatus": schema_pkg_apis_secret_v0alpha1_SecureValueStatus(ref),
"github.com/grafana/grafana/pkg/apis/secret/v0alpha1.SystemKeeperConfig": schema_pkg_apis_secret_v0alpha1_SystemKeeperConfig(ref),
}
}
@@ -234,17 +234,6 @@ func schema_pkg_apis_secret_v0alpha1_CredentialValue(ref common.ReferenceCallbac
}
}
func schema_pkg_apis_secret_v0alpha1_Envelope(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Envelope encrytion details.",
Type: []string{"object"},
},
},
}
}
func schema_pkg_apis_secret_v0alpha1_GCPCredentials(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -729,3 +718,14 @@ func schema_pkg_apis_secret_v0alpha1_SecureValueStatus(ref common.ReferenceCallb
},
}
}
func schema_pkg_apis_secret_v0alpha1_SystemKeeperConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "System Keeper.",
Type: []string{"object"},
},
},
}
}