def _strip_or_pad_version(version, num_components):
    """Strips or pads a version string to the given number of components.

    If the version string contains fewer than the requested number of
    components, it will be padded with zeros.

    Args:
        version: The version string.
        num_components: The desired number of components.

    Returns:
        The version, stripped or padded to the requested number of components.
    """
    version_string = str(version)
    components = version_string.split(".")
    if num_components <= len(components):
        return ".".join(components[:num_components])
    return version_string + (".0" * (num_components - len(components)))