func setGCPConfig()

in controllers/flinkcluster/flinkcluster_converter.go [1292:1327]


func setGCPConfig(gcpConfig *v1beta1.GCPConfig, podSpec *corev1.PodSpec) bool {
	if gcpConfig == nil {
		return false
	}

	var saConfig = gcpConfig.ServiceAccount
	var saVolume = corev1.Volume{
		Name: gcpServiceAccountVolume,
		VolumeSource: corev1.VolumeSource{
			Secret: &corev1.SecretVolumeSource{
				SecretName: gcpConfig.ServiceAccount.SecretName,
			},
		},
	}
	var saMount = corev1.VolumeMount{
		Name:      gcpServiceAccountVolume,
		MountPath: gcpConfig.ServiceAccount.MountPath,
		ReadOnly:  true,
	}
	if !strings.HasSuffix(saMount.MountPath, "/") {
		saMount.MountPath = saMount.MountPath + "/"
	}

	var saEnv = corev1.EnvVar{
		Name:  gacEnvVar,
		Value: saMount.MountPath + saConfig.KeyFile,
	}

	volumes := []corev1.Volume{saVolume}
	volumeMounts := []corev1.VolumeMount{saMount}
	envVars := []corev1.EnvVar{saEnv}
	podSpec.Containers = convertContainers(podSpec.Containers, volumeMounts, envVars)
	podSpec.InitContainers = convertContainers(podSpec.InitContainers, volumeMounts, envVars)
	podSpec.Volumes = appendVolumes(podSpec.Volumes, volumes...)
	return true
}