Secrets: Move decrypt types to contracts and export public at root pkg (#108376)
* Secrets: Move decrypt types to contracts and export public at root pkg * Provisioning: Replace decrypt pkg imports * Merge wire changes
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
secretv1beta1 "github.com/grafana/grafana/apps/secret/pkg/apis/secret/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/secret/contracts"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/secret/service"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/secret/testutils"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/secret/xkube"
|
||||
"github.com/mitchellh/copystructure"
|
||||
@@ -111,24 +110,24 @@ func (m *model) list(namespace string) (*secretv1beta1.SecureValueList, error) {
|
||||
return &secretv1beta1.SecureValueList{Items: out}, nil
|
||||
}
|
||||
|
||||
func (m *model) decrypt(decrypter, namespace, name string) (map[string]service.DecryptResult, error) {
|
||||
func (m *model) decrypt(decrypter, namespace, name string) (map[string]contracts.DecryptResult, error) {
|
||||
for _, v := range m.secureValues {
|
||||
if v.Namespace == namespace &&
|
||||
v.Name == name &&
|
||||
v.active {
|
||||
if slices.ContainsFunc(v.Spec.Decrypters, func(d string) bool { return d == decrypter }) {
|
||||
return map[string]service.DecryptResult{
|
||||
name: service.NewDecryptResultValue(deepCopy(v).Spec.Value),
|
||||
return map[string]contracts.DecryptResult{
|
||||
name: contracts.NewDecryptResultValue(deepCopy(v).Spec.Value),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return map[string]service.DecryptResult{
|
||||
name: service.NewDecryptResultErr(contracts.ErrDecryptNotAuthorized),
|
||||
return map[string]contracts.DecryptResult{
|
||||
name: contracts.NewDecryptResultErr(contracts.ErrDecryptNotAuthorized),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return map[string]service.DecryptResult{
|
||||
name: service.NewDecryptResultErr(contracts.ErrDecryptNotFound),
|
||||
return map[string]contracts.DecryptResult{
|
||||
name: contracts.NewDecryptResultErr(contracts.ErrDecryptNotFound),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user