INNER CODE UNIT · Python

message

weaveworks/kubediff · kubedifflib/_diff.py:46

            message = self.message % self.args
        if self.path is None:
            return message
        return '%s: %s' % (self.path, message)


def cpus_equal(a, b):
    """Compares cpu specs for equality. cpu specs can be ints, floats or strings '{:d}m',
    where 'm' denotes 'milli-', ie. 1/1000th of an integer value.
    Eg. "50m" is equal to 0.05."""
    def parse(x):
        return int(x[:-1]) / 1000. if x.endswith('m') else float(x)

    return parse(a) == parse(b)

# Kubernetes outputs "creationTimestamp: null" in a blank object
# e.g. from kubectl create deploy foo --image=foo --output=yaml --dry-run
# so allow that to compare equal to any real value that comes back.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…