func (c *SecretMapping) Find(secretName string, dataKey string) *Mapping {
	for i, m := range c.Spec.Secrets {
		if m.Name == secretName {
			return c.Spec.Secrets[i].Find(dataKey)
		}
	}
	return nil
}
Find finds a secret rule for the given secret name
package v1alpha1
import (
	"io/ioutil"
	"github.com/jenkins-x/jx-api/v4/pkg/util"
	"github.com/pkg/errors"
	"gopkg.in/validator.v2"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"sigs.k8s.io/yaml"
)
const (
	SecretMappingFileName = "secret-mappings.yaml"
)
type SecretMapping struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ObjectMeta `json:"metadata"`
	Spec SecretMappingSpec `json:"spec"`
}
type SecretMappingSpec struct {
	Secrets []SecretRule `json:"secrets,omitempty"`
	Defaults `json:"defaults,omitempty" validate:"nonzero"`
}
type Defaults struct {
	BackendType BackendType `json:"backendType,omitempty" validate:"nonzero"`
	GcpSecretsManager GcpSecretsManager `json:"gcpSecretsManager,omitempty"`
}
type SecretMappingList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SecretMapping `json:"items"`
}
type SecretRule struct {
	Name string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	BackendType BackendType `json:"backendType"`
	Mappings []Mapping `json:"mappings,omitempty"`
	Mandatory bool `json:"mandatory,omitempty"`
	GcpSecretsManager GcpSecretsManager `json:"gcpSecretsManager,omitempty"`
}
type BackendType string
const (
	BackendTypeVault BackendType = "vault"
	BackendTypeGSM BackendType = "gcpSecretsManager"
	BackendTypeNone BackendType = ""
)
type GcpSecretsManager struct {
	Version string `json:"version,omitempty"`
	ProjectId string `json:"projectId,omitempty"`
	UniquePrefix string `json:"uniquePrefix,omitempty"`
}
type Mapping struct {
	Name string `json:"name,omitempty"`
	Key string `json:"key,omitempty"`
	Property string `json:"property,omitempty"`
}
func (c *SecretMapping) FindRule(namespace string, secretName string) SecretRule {
	for _, m := range c.Spec.Secrets {
		if m.Name == secretName && (m.Namespace == "" || m.Namespace == namespace) {
			return m
		}
	}
	return SecretRule{
		BackendType: c.Spec.Defaults.BackendType,
	}
}