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)
def ppas(dry_run): """Sync ppas""" dryrun(dry_run) client = lp.Client() client.login() ppa_service_obj = PPAService(client.owner("k8s-maintainers")) ppa_service_obj.sync()
def build_summaries(snap_list, snap_versions, owner): """Return snap build summaries""" _client = lp.Client(stage="production") _client.login() snap_list_p = Path(snap_list) snap_versions_p = Path(snap_versions) snap_iter = yaml.safe_load(snap_list_p.read_text()) snap_versions_iter = yaml.safe_load(snap_versions_p.read_text()) snaps_to_process = [ f"{name}-{ver}" for name, ver in list(itertools.product(*[snap_iter, snap_versions_iter])) ] owner_link = _client.owner(owner) summaries = [] for item in snaps_to_process: builds = _client.snaps.getByName(name=item, owner=owner_link).builds[:4] for build in builds: arch = build.distro_arch_series.architecture_tag click.echo(f"Summarizing {item} - {arch}") summaries.append( { "name": f"{item}-{arch}", "created": build.datecreated.strftime("%Y-%m-%d %H:%M:%S"), "started": build.date_started.strftime("%Y-%m-%d %H:%M:%S") if build.date_started else "n/a", "finished": build.datebuilt.strftime("%Y-%m-%d %H:%M:%S") if build.datebuilt else "n/a", "buildstate": build.buildstate, "build_log_url": build.build_log_url, "store_upload_status": build.store_upload_status, "store_upload_errors": build.store_upload_error_messages, "upload_log_url": build.upload_log_url, "channels": build.snap.store_channels, } ) # Generate published snaps from snapstore click.echo("Retrieving snapstore revisions and publishing information") # Add cdk-addons here since we need to check that snap as well from snapstore snap_iter.append("cdk-addons") published_snaps = [(snap, snapapi.all_published(snap)) for snap in snap_iter] tmpl = html.template("snap_summary.html") rendered = tmpl.render({"rows": summaries, "published_snaps": published_snaps}) summary_html_p = Path("snap_summary.html") summary_html_p.write_text(rendered) cmd_ok("aws s3 cp snap_summary.html s3://jenkaas/snap_summary.html", shell=True)
def _create_recipe(self, version, branch, arch): """ Creates an new snap recipe in Launchpad tag: launchpad git tag to pull snapcraft instructions from (ie, git.launchpad.net/snap-kubectl) # Note: this account would need access granted to the snaps it want's to publish from the snapstore dashboard snap_recipe_email: snapstore email for being able to publish snap recipe from launchpad to snap store snap_recipe_password: snapstore password for account being able to publish snap recipe from launchpad to snap store Usage: snap.py create-snap-recipe --snap kubectl --version 1.13 --tag v1.13.2 \ --track 1.13/edge/hotfix-LP123456 \ --repo git+ssh://[email protected]/snap-kubectl \ --owner k8s-jenkaas-admins \ --snap-recipe-email [email protected] \ --snap-recipe-password aabbccddee """ params = { "name": self.snap_model.name, "owner": "k8s-jenkaas-admins", "version": version, "branch": branch, "repo": self.snap_model.repo, "track": self.snap_model.tracks, "arch": arch, } self.log(f"> Creating recipe for {params}") snap_recipe_email = os.environ.get("K8STEAMCI_USR") snap_recipe_password = os.environ.get("K8STEAMCI_PSW") _client = lp.Client(stage="production") _client.login() snap_recipe = _client.create_or_update_snap_recipe(**params) caveat_id = snap_recipe.beginAuthorization() cip = idm.CanonicalIdentityProvider(email=snap_recipe_email, password=snap_recipe_password) discharge_macaroon = cip.get_discharge(caveat_id).json() discharge_macaroon = Macaroon.deserialize( discharge_macaroon["discharge_macaroon"]) snap_recipe.completeAuthorization( discharge_macaroon=discharge_macaroon.serialize()) snap_recipe.requestBuilds(archive=_client.archive(), pocket="Updates")
def _create_snap_recipe( snap, version, track, owner, tag, repo, dry_run, snap_recipe_email, snap_recipe_password, ): """ Creates an new snap recipe in Launchpad snap: Name of snap to create the recipe for (ie, kubectl) version: snap version channel apply this too (ie, Current patch is 1.13.3 but we want that to go in 1.13 snap channel) track: snap store version/risk/branch to publish to (ie, 1.13/edge/hotfix-LP123456) owner: launchpad owner of the snap recipe (ie, k8s-jenkaas-admins) tag: launchpad git tag to pull snapcraft instructions from (ie, git.launchpad.net/snap-kubectl) repo: launchpad git repo (git+ssh://[email protected]/snap-kubectl) # Note: this account would need access granted to the snaps it want's to publish from the snapstore dashboard snap_recipe_email: snapstore email for being able to publish snap recipe from launchpad to snap store snap_recipe_password: snapstore password for account being able to publish snap recipe from launchpad to snap store Usage: snap.py create-snap-recipe --snap kubectl --version 1.13 --tag v1.13.2 \ --track 1.13/edge/hotfix-LP123456 \ --repo git+ssh://[email protected]/snap-kubectl \ --owner k8s-jenkaas-admins \ --snap-recipe-email [email protected] \ --snap-recipe-password aabbccddee """ _client = lp.Client(stage="production") _client.login() if not isinstance(track, list): track = [track] params = { "name": snap, "owner": owner, "version": version, "branch": tag, "repo": repo, "track": track, } click.echo(f" > creating recipe for {params}") if dry_run: click.echo("dry-run only, exiting.") sys.exit(0) snap_recipe = _client.create_or_update_snap_recipe(**params) caveat_id = snap_recipe.beginAuthorization() cip = idm.CanonicalIdentityProvider( email=snap_recipe_email, password=snap_recipe_password ) discharge_macaroon = cip.get_discharge(caveat_id).json() discharge_macaroon = Macaroon.deserialize(discharge_macaroon["discharge_macaroon"]) snap_recipe.completeAuthorization(discharge_macaroon=discharge_macaroon.serialize()) snap_recipe.requestBuilds(archive=_client.archive(), pocket="Updates")