Ejemplo n.º 1
0
def test_tags_semver_point(monkeypatch):
    """Test getting tags from a starting semver"""
    monkeypatch.setattr(
        "cilib.models.repos.kubernetes.InternalKubernetesRepoModel.tags",
        ["v1.16.1", "v1.17.1", "v1.17.2", "v1.18.1"],
    )
    DOWNSTREAM = InternalKubernetesRepoModel()
    tags = DOWNSTREAM.tags_from_semver_point("v1.17.0")
    assert tags == ["v1.17.1", "v1.17.2", "v1.18.1"]
Ejemplo n.º 2
0
def snaps(dry_run):
    """Syncs the snap branches, keeps snap builds in sync, and makes sure the latest snaps are published into snap store"""
    dryrun(dry_run)
    snaps_to_process = [
        SnapKubeApiServerRepoModel(),
        SnapKubeControllerManagerRepoModel(),
        SnapKubeProxyRepoModel(),
        SnapKubeSchedulerRepoModel(),
        SnapKubectlRepoModel(),
        SnapKubeadmRepoModel(),
        SnapKubeletRepoModel(),
        SnapKubernetesTestRepoModel(),
    ]

    kubernetes_repo = InternalKubernetesRepoModel()

    # Sync all snap branches
    for _snap in snaps_to_process:
        snap_service_obj = SnapService(_snap, kubernetes_repo)
        snap_service_obj.sync_from_upstream()
        snap_service_obj.sync_all_track_snaps()
        snap_service_obj.sync_stable_track_snaps()

    # Handle cdk-addons sync separetely
    cdk_addons = SnapCdkAddonsRepoModel()
    cdk_addons_service_obj = SnapService(cdk_addons, kubernetes_repo)
    cdk_addons_service_obj.sync_stable_track_snaps()
Ejemplo n.º 3
0
def sync_internal_tags(dry_run):
    """Syncs upstream to downstream internal k8s tags"""
    dryrun(dry_run)
    # List of tuples containing upstream, downstream models and a starting semver
    repos_map = [
        (
            UpstreamKubernetesRepoModel(),
            InternalKubernetesRepoModel(),
            enums.K8S_STARTING_SEMVER,
        ),
        (
            CriToolsUpstreamRepoModel(),
            InternalCriToolsRepoModel(),
            enums.K8S_CRI_TOOLS_SEMVER,
        ),
        (
            CNIPluginsUpstreamRepoModel(),
            InternalCNIPluginsRepoModel(),
            enums.K8S_CNI_SEMVER,
        ),
    ]

    for repo in repos_map:
        upstream, downstream, starting_semver = repo
        tags_to_sync = upstream.tags_subset_semver_point(
            downstream, starting_semver)
        if not tags_to_sync:
            click.echo(f"All synced up: {upstream} == {downstream}")
            continue
        upstream.clone()
        upstream.remote_add("downstream", downstream.repo, cwd=upstream.name)
        for tag in tags_to_sync:
            click.echo(
                f"Syncing repo {upstream} => {downstream}, tag => {tag}")
            upstream.push("downstream", tag, cwd=upstream.name)
Ejemplo n.º 4
0
def debs(sign_key, dry_run, force):
    """Syncs debs"""
    dryrun(dry_run)

    client = lp.Client()
    client.login()
    ppas = client.ppas("k8s-maintainers")

    debs_to_process = [
        DebKubeadmRepoModel(),
        DebKubectlRepoModel(),
        DebKubeletRepoModel(),
    ]
    kubernetes_repo = InternalKubernetesRepoModel()

    # Sync all deb branches
    for _deb in debs_to_process:
        deb_service_obj = DebService(_deb, kubernetes_repo, ppas, sign_key)
        deb_service_obj.sync_from_upstream()
        deb_service_obj.sync_debs(force)

    cri_tools = DebCriToolsRepoModel()
    cri_tools_service_obj = DebCriToolsService(cri_tools,
                                               InternalCriToolsRepoModel(),
                                               ppas, sign_key)
    cri_tools_service_obj.sync_from_upstream()
    cri_tools_service_obj.sync_debs(force)

    kubernetes_cni = DebKubernetesCniRepoModel()
    kubernetes_cni_service_obj = DebCNIService(kubernetes_cni,
                                               InternalCNIPluginsRepoModel(),
                                               ppas, sign_key)
    kubernetes_cni_service_obj.sync_from_upstream()
    kubernetes_cni_service_obj.sync_debs(force)
Ejemplo n.º 5
0
def test_tags_subset_semver_point(monkeypatch):
    """Test getting subset of tags from a starting semver"""
    monkeypatch.setattr(
        "cilib.models.repos.kubernetes.UpstreamKubernetesRepoModel.tags",
        ["v1.17.5", "v1.17.6", "v1.17.7"],
    )
    monkeypatch.setattr(
        "cilib.models.repos.kubernetes.InternalKubernetesRepoModel.tags",
        ["v1.17.0", "v1.17.1", "v1.17.2"],
    )
    ustream = UpstreamKubernetesRepoModel()
    dstream = InternalKubernetesRepoModel()
    tags = ustream.tags_subset_semver_point(dstream, "v1.17.0")
    assert "v1.16.0" not in tags
    assert "v1.17.5" in tags
Ejemplo n.º 6
0
def snap_from_branch(branch, dry_run):
    """Syncs the snap branches, keeps snap builds in sync, and makes sure the latest snaps are published into snap store"""
    dryrun(dry_run)
    snaps_to_process = [
        SnapKubeApiServerRepoModel(),
        SnapKubeControllerManagerRepoModel(),
        SnapKubeProxyRepoModel(),
        SnapKubeSchedulerRepoModel(),
        SnapKubectlRepoModel(),
        SnapKubeadmRepoModel(),
        SnapKubeletRepoModel(),
        SnapKubernetesTestRepoModel(),
    ]

    kubernetes_repo = InternalKubernetesRepoModel()

    # Sync all snap branches
    for _snap in snaps_to_process:
        snap_service_obj = SnapService(_snap, kubernetes_repo)
        snap_service_obj.build_snap_from_branch(branch)