Skip to content

Commit e15a2f5

Browse files
authored
docker: remove description updates when publishing a release (#561)
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.
1 parent 999b856 commit e15a2f5

File tree

2 files changed

+8
-51
lines changed

2 files changed

+8
-51
lines changed

docker/batch-change-volume-workspace/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ Sourcegraph `src` executes batch changes using either a bind or volume workspace
55
This image is based on Alpine, and adds the tools we need: curl, git, and unzip.
66

77
For more information, please refer to the [`src-cli` repository](https://github.com/sourcegraph/src-cli/tree/main/docker/batch-change-volume-workspace).
8+
9+
<!--
10+
If you update this description, you _must_ also update the description at
11+
https://hub.docker.com/r/sourcegraph/src-batch-change-volume-workspace — this
12+
does not happen automatically!
13+
-->

docker/batch-change-volume-workspace/push.py

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@
3333

3434
import argparse
3535
import itertools
36-
import json
3736
import os
3837
import subprocess
3938

40-
from ssl import SSLContext
41-
from typing import BinaryIO, Optional, Sequence, TextIO
42-
from urllib.request import urlopen, Request
39+
from typing import BinaryIO, Optional, Sequence
40+
from urllib.request import urlopen
4341

4442

4543
def calculate_tags(ref: str) -> Sequence[str]:
@@ -97,47 +95,6 @@ def docker_cli_login(username: str, password: str):
9795
)
9896

9997

100-
class DockerHub:
101-
context: SSLContext
102-
token: str
103-
104-
@staticmethod
105-
def login(username: str, password: str) -> DockerHub:
106-
context = SSLContext()
107-
context.load_default_certs()
108-
109-
with urlopen(
110-
Request(
111-
"https://hub.docker.com/v2/users/login",
112-
method="POST",
113-
data=json.dumps({"username": username, "password": password}).encode(
114-
"utf-8"
115-
),
116-
headers={"Content-Type": "application/json; charset=utf-8"},
117-
),
118-
context=context,
119-
) as resp:
120-
hub = DockerHub()
121-
hub.context = context
122-
hub.token = json.load(resp)["token"]
123-
124-
return hub
125-
126-
def update_description(self, image: str, file: TextIO) -> None:
127-
urlopen(
128-
Request(
129-
f"https://hub.docker.com/v2/repositories/{image}/",
130-
method="PATCH",
131-
data=json.dumps({"full_description": file.read()}).encode("utf-8"),
132-
headers={
133-
"Content-Type": "application/json; charset=utf-8",
134-
"Authorization": f"JWT {self.token}",
135-
},
136-
),
137-
context=self.context,
138-
)
139-
140-
14198
def run(args: Sequence[str], /, **kwargs) -> subprocess.CompletedProcess:
14299
print(f"+ {' '.join(args)}")
143100
return subprocess.run(args, check=True, **kwargs)
@@ -180,12 +137,6 @@ def main():
180137
print("building and pushing image")
181138
docker_cli_build(open(args.dockerfile, "rb"), args.platform, args.image, tags)
182139

183-
print("acquiring token to update description")
184-
hub = DockerHub.login(os.environ["DOCKER_USERNAME"], os.environ["DOCKER_PASSWORD"])
185-
186-
print("updating description")
187-
hub.update_description(args.image, open(args.readme, "r"))
188-
189140
print("success!")
190141

191142

0 commit comments

Comments
 (0)