MCPcopy
hub / github.com/FairwindsOps/goldilocks / vpaMinReplicasForResource

Function vpaMinReplicasForResource

pkg/vpa/vpa.go:447–472  ·  view source on GitHub ↗

vpaMinReplicas sets the VPA minimum replicas required for eviction

(obj runtime.Object)

Source from the content-addressed store, hash-verified

445
446// vpaMinReplicas sets the VPA minimum replicas required for eviction
447func vpaMinReplicasForResource(obj runtime.Object) (*int32, bool) {
448 explicit := false
449
450 minReplicasString := ""
451 accessor, _ := meta.Accessor(obj)
452 if val, ok := accessor.GetAnnotations()[utils.VpaMinReplicasAnnotation]; ok {
453 minReplicasString = val
454 } else if val, ok := accessor.GetLabels()[utils.VpaMinReplicasAnnotation]; ok {
455 minReplicasString = val
456 }
457
458 if minReplicasString == "" {
459 return nil, explicit
460 }
461
462 explicit = true
463 minReplicas, err := strconv.ParseInt(minReplicasString, 10, 32)
464 if err != nil {
465 klog.Error(err.Error())
466 return nil, explicit
467 }
468
469 minReplicasInt32 := int32(minReplicas)
470
471 return &minReplicasInt32, explicit
472}

Callers 7

Test_getVPAObjectFunction · 0.85
Test_createVPAFunction · 0.85
Test_deleteVPAFunction · 0.85
Test_updateVPAFunction · 0.85
Test_listVPAFunction · 0.85

Calls

no outgoing calls

Tested by 6

Test_getVPAObjectFunction · 0.68
Test_createVPAFunction · 0.68
Test_deleteVPAFunction · 0.68
Test_updateVPAFunction · 0.68
Test_listVPAFunction · 0.68