in cost-optimization/gke-shift-left-cost/api/builder_statefulset.go [42:66]
func buildStatefulSetV1(statefulset *appsV1.StatefulSet, conf CostimatorConfig) (StatefulSet, error) {
conf = populateConfigNotProvided(conf)
containers := buildContainers(statefulset.Spec.Template.Spec.Containers, conf)
var replicas int32 = 1
if statefulset.Spec.Replicas != (*int32)(nil) {
replicas = *statefulset.Spec.Replicas
}
volumeClaims := []*VolumeClaim{}
for _, vct := range statefulset.Spec.VolumeClaimTemplates {
groupVersionKind := GroupVersionKind{Kind: VolumeClaimKind}
pvc, err := buildVolumeClaim(&vct, groupVersionKind, conf)
if err != nil {
return StatefulSet{}, err
}
volumeClaims = append(volumeClaims, &pvc)
}
return StatefulSet{
APIVersionKindName: buildAPIVersionKindName(statefulset.APIVersion, statefulset.Kind, statefulset.GetNamespace(), statefulset.GetName()),
Replicas: replicas,
Containers: containers,
VolumeClaims: volumeClaims,
}, nil
}