From e8ed606ac823ae7d7bfe1611a0865a5a60eaaca1 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 28 Jun 2021 15:41:34 -0700 Subject: [PATCH] docker: remove description updates when publishing a release We used to update the Docker Hub description for https://hub.docker.com/r/sourcegraph/src-batch-change-volume-workspace on release, but doing so reliably has proven to be difficult, as Docker Hub doesn't provide a reliable API to do this. When it fails, the entire release shows up as red, which is obviously not ideal! Since this description rarely changes, and the pushes themselves are reliable, this removes the description update and makes it a manual process. --- .../batch-change-volume-workspace/README.md | 6 +++ docker/batch-change-volume-workspace/push.py | 53 +------------------ 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/docker/batch-change-volume-workspace/README.md b/docker/batch-change-volume-workspace/README.md index 92b949dcfa..fc352a7ec2 100644 --- a/docker/batch-change-volume-workspace/README.md +++ b/docker/batch-change-volume-workspace/README.md @@ -5,3 +5,9 @@ Sourcegraph `src` executes batch changes using either a bind or volume workspace This image is based on Alpine, and adds the tools we need: curl, git, and unzip. For more information, please refer to the [`src-cli` repository](https://github.com/sourcegraph/src-cli/tree/main/docker/batch-change-volume-workspace). + + diff --git a/docker/batch-change-volume-workspace/push.py b/docker/batch-change-volume-workspace/push.py index 719c01e1aa..bca152802e 100755 --- a/docker/batch-change-volume-workspace/push.py +++ b/docker/batch-change-volume-workspace/push.py @@ -33,13 +33,11 @@ import argparse import itertools -import json import os import subprocess -from ssl import SSLContext -from typing import BinaryIO, Optional, Sequence, TextIO -from urllib.request import urlopen, Request +from typing import BinaryIO, Optional, Sequence +from urllib.request import urlopen def calculate_tags(ref: str) -> Sequence[str]: @@ -97,47 +95,6 @@ def docker_cli_login(username: str, password: str): ) -class DockerHub: - context: SSLContext - token: str - - @staticmethod - def login(username: str, password: str) -> DockerHub: - context = SSLContext() - context.load_default_certs() - - with urlopen( - Request( - "https://hub.docker.com/v2/users/login", - method="POST", - data=json.dumps({"username": username, "password": password}).encode( - "utf-8" - ), - headers={"Content-Type": "application/json; charset=utf-8"}, - ), - context=context, - ) as resp: - hub = DockerHub() - hub.context = context - hub.token = json.load(resp)["token"] - - return hub - - def update_description(self, image: str, file: TextIO) -> None: - urlopen( - Request( - f"https://hub.docker.com/v2/repositories/{image}/", - method="PATCH", - data=json.dumps({"full_description": file.read()}).encode("utf-8"), - headers={ - "Content-Type": "application/json; charset=utf-8", - "Authorization": f"JWT {self.token}", - }, - ), - context=self.context, - ) - - def run(args: Sequence[str], /, **kwargs) -> subprocess.CompletedProcess: print(f"+ {' '.join(args)}") return subprocess.run(args, check=True, **kwargs) @@ -180,12 +137,6 @@ def main(): print("building and pushing image") docker_cli_build(open(args.dockerfile, "rb"), args.platform, args.image, tags) - print("acquiring token to update description") - hub = DockerHub.login(os.environ["DOCKER_USERNAME"], os.environ["DOCKER_PASSWORD"]) - - print("updating description") - hub.update_description(args.image, open(args.readme, "r")) - print("success!")