github.com/openshift/installer@v1.4.17/pkg/asset/manifests/gcp/clustercsidriver.go (about)

     1  package gcp
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  	"sigs.k8s.io/yaml"
     6  
     7  	operatorv1 "github.com/openshift/api/operator/v1"
     8  )
     9  
    10  // ClusterCSIDriverConfig is the GCP config for the cluster CSI Driver.
    11  type ClusterCSIDriverConfig struct {
    12  	Name      string
    13  	KeyRing   string
    14  	ProjectID string
    15  	Location  string
    16  }
    17  
    18  // YAML generates the cluster CSI driver config for the GCP platform.
    19  func (params ClusterCSIDriverConfig) YAML() ([]byte, error) {
    20  	obj := &operatorv1.ClusterCSIDriver{
    21  		TypeMeta: metav1.TypeMeta{
    22  			APIVersion: operatorv1.GroupVersion.String(),
    23  			Kind:       "ClusterCSIDriver",
    24  		},
    25  		ObjectMeta: metav1.ObjectMeta{
    26  			Name: string(operatorv1.GCPPDCSIDriver),
    27  		},
    28  		Spec: operatorv1.ClusterCSIDriverSpec{
    29  			DriverConfig: operatorv1.CSIDriverConfigSpec{
    30  				DriverType: operatorv1.GCPDriverType,
    31  				GCP: &operatorv1.GCPCSIDriverConfigSpec{
    32  					KMSKey: &operatorv1.GCPKMSKeyReference{
    33  						Name:      params.Name,
    34  						KeyRing:   params.KeyRing,
    35  						ProjectID: params.ProjectID,
    36  						Location:  params.Location,
    37  					},
    38  				},
    39  			},
    40  			OperatorSpec: operatorv1.OperatorSpec{
    41  				ManagementState: operatorv1.Managed,
    42  			},
    43  		},
    44  	}
    45  
    46  	configData, err := yaml.Marshal(obj)
    47  	if err != nil {
    48  		return nil, err
    49  	}
    50  	return configData, nil
    51  }