@@ -44,45 +44,6 @@ local k = import 'ksonnet-util/kausal.libsonnet';
44
44
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
45
45
container.mixin.readinessProbe.withInitialDelaySeconds(15 ) +
46
46
container.mixin.readinessProbe.withTimeoutSeconds(1 ),
47
-
48
- // parseCPU is used for conversion of Kubernetes CPU units to the corresponding float value of CPU cores.
49
- // Moreover, the function assumes the input is in a correct Kubernetes format, i.e., an integer, a float,
50
- // a string representation of an integer or a float, or a string containing a number ending with 'm'
51
- // representing a number of millicores.
52
- // Examples:
53
- // parseCPU(10) = parseCPU("10") = 10
54
- // parseCPU(4.5) = parse("4.5") = 4.5
55
- // parseCPU("3000m") = 3000 / 1000
56
- // parseCPU("3580m") = 3580 / 1000
57
- // parseCPU("3980.7m") = 3980.7 / 1000
58
- // parseCPU(0.5) = parse("0.5") = parse("500m") = 0.5
59
- parseCPU(v)::
60
- if std.isString (v) && std.endsWith (v, 'm' ) then std.parseJson(std.rstripChars(v, 'm' )) / 1000
61
- else if std.isString (v) then std.parseJson(v)
62
- else if std.isNumber (v) then v
63
- else 0 ,
64
-
65
- // siToBytes is used to convert Kubernetes byte units to bytes.
66
- // Only works for limited set of SI prefixes: Ki, Mi, Gi, Ti.
67
- siToBytes(str):: (
68
- // Utility converting the input to a (potentially decimal) number of bytes
69
- local siToBytesDecimal(str) = (
70
- if std.endsWith (str, 'Ki' ) then (
71
- std.parseJson(std.rstripChars(str, 'Ki' )) * std.pow (2 , 10 )
72
- ) else if std.endsWith (str, 'Mi' ) then (
73
- std.parseJson(std.rstripChars(str, 'Mi' )) * std.pow (2 , 20 )
74
- ) else if std.endsWith (str, 'Gi' ) then (
75
- std.parseJson(std.rstripChars(str, 'Gi' )) * std.pow (2 , 30 )
76
- ) else if std.endsWith (str, 'Ti' ) then (
77
- std.parseJson(std.rstripChars(str, 'Ti' )) * std.pow (2 , 40 )
78
- ) else (
79
- std.parseJson(str)
80
- )
81
- );
82
-
83
- // Round down to nearest integer
84
- std.floor (siToBytesDecimal(str))
85
- ),
86
47
},
87
48
88
49
// functions for k8s objects
0 commit comments