Skip to content

Commit 4a9ff1e

Browse files
authored
Linter, Test fixes, and Container Updates (#620)
* Fix lint errors * Fix test errors by removing six * Fix lint errors * Update containers with new helm/kubectl versions (#621) * Update helm, kubectl and container dependencies * Fix docker install * Revert changes to test docker container
1 parent ef3dfa3 commit 4a9ff1e

File tree

6 files changed

+25
-30
lines changed

6 files changed

+25
-30
lines changed

marketplace/deployer_envsubst_base/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM marketplace.gcr.io/google/ubuntu2004
1+
FROM marketplace.gcr.io/google/ubuntu2204
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
bash \
@@ -17,15 +17,15 @@ RUN pip3 install \
1717
pyyaml \
1818
six
1919

20-
RUN for full_version in 1.26.5 1.26.5 1.27.2; \
20+
RUN for full_version in 1.27.3 1.28.3; \
2121
do \
2222
version=${full_version%.*} \
2323
&& mkdir -p /opt/kubectl/$version \
2424
&& wget -q -O /opt/kubectl/$version/kubectl \
2525
https://storage.googleapis.com/kubernetes-release/release/v$full_version/bin/linux/amd64/kubectl \
2626
&& chmod 755 /opt/kubectl/$version/kubectl; \
2727
done;
28-
RUN ln -s /opt/kubectl/1.26 /opt/kubectl/default
28+
RUN ln -s /opt/kubectl/1.27 /opt/kubectl/default
2929

3030
COPY marketplace/deployer_envsubst_base/* /bin/
3131
COPY marketplace/deployer_util/* /bin/

marketplace/deployer_helm_base/Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM marketplace.gcr.io/google/ubuntu2004
1+
FROM marketplace.gcr.io/google/ubuntu2204
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
bash \
@@ -14,22 +14,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1414
RUN pip3 install \
1515
wheel \
1616
pyOpenSSL \
17-
pyyaml \
18-
six
17+
pyyaml
1918

20-
RUN for full_version in 1.26.5 1.26.5 1.27.2; \
19+
RUN for full_version in 1.27.3 1.28.3; \
2120
do \
2221
version=${full_version%.*} \
2322
&& mkdir -p /opt/kubectl/$version \
2423
&& wget -q -O /opt/kubectl/$version/kubectl \
2524
https://storage.googleapis.com/kubernetes-release/release/v$full_version/bin/linux/amd64/kubectl \
2625
&& chmod 755 /opt/kubectl/$version/kubectl; \
2726
done;
28-
RUN ln -s /opt/kubectl/1.26 /opt/kubectl/default
27+
RUN ln -s /opt/kubectl/1.27 /opt/kubectl/default
2928

3029
RUN mkdir -p /bin/helm-downloaded \
3130
&& wget -q -O /bin/helm-downloaded/helm.tar.gz \
32-
https://get.helm.sh/helm-v3.12.2-linux-amd64.tar.gz \
31+
https://get.helm.sh/helm-v3.13.2-linux-amd64.tar.gz \
3332
&& tar -zxvf /bin/helm-downloaded/helm.tar.gz -C /bin/helm-downloaded \
3433
&& mv /bin/helm-downloaded/linux-amd64/helm /bin/ \
3534
&& rm -rf /bin/helm-downloaded

marketplace/deployer_util/bash_util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import shlex
1717
import subprocess
1818

19-
import six
20-
2119

2220
class CommandException(Exception):
2321

@@ -39,7 +37,11 @@ def __init__(self, cmd, print_call=False, print_result=False):
3937

4038
parsedCmd = shlex.split(cmd)
4139
self._process = subprocess.Popen(
42-
parsedCmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40+
parsedCmd,
41+
stdin=None,
42+
stdout=subprocess.PIPE,
43+
stderr=subprocess.PIPE,
44+
encoding='utf-8')
4345
self._exitcode = None
4446
self._output = None
4547
self._print_call = print_call
@@ -48,8 +50,6 @@ def __init__(self, cmd, print_call=False, print_result=False):
4850

4951
def _run(self):
5052
self._output, error_message = self._process.communicate()
51-
self._output = six.ensure_str(self._output, 'utf-8')
52-
error_message = six.ensure_str(error_message, 'utf-8')
5353
self._exitcode = self._process.returncode
5454
if self._print_result:
5555
result = (f"result: {self._exitcode}\n"

marketplace/deployer_util/make_dns1123_name.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import re
1919
from argparse import ArgumentParser
2020

21-
import six
22-
2321
_PROG_HELP = """
2422
Turns a name into a proper DNS-1123 subdomain, with limitations.
2523
"""
@@ -54,7 +52,7 @@ def limit_name(name, length=127):
5452
result = result[:length - 5]
5553
# Hash and get the first 4 characters of the hash.
5654
m = hashlib.sha256()
57-
m.update(six.ensure_binary(name, 'utf-8'))
55+
m.update(name.encode('utf-8'))
5856
h4sh = m.hexdigest()[:4]
5957
result = '{}-{}'.format(result, h4sh)
6058
return result

marketplace/deployer_util/process_helm_hooks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
_HELM_HOOK_KEY = 'helm.sh/hook'
2727
_HOOK_SUCCESS = ['test-success', 'test']
28-
_HOOK_FAILURE = ['test-failure', 'test']
28+
_HOOK_FAILURE = ['test-failure']
29+
2930

3031
def main():
3132
parser = ArgumentParser()
@@ -44,13 +45,13 @@ def main():
4445
helm_hook = deep_get(resource, "metadata", "annotations", _HELM_HOOK_KEY)
4546
if helm_hook is None:
4647
filtered_resources.append(resource)
47-
elif _HOOK_SUCCESS.index(helm_hook):
48+
elif helm_hook in _HOOK_SUCCESS:
4849
if args.deploy_tests:
4950
annotations = deep_get(resource, "metadata", "annotations")
5051
del annotations[_HELM_HOOK_KEY]
5152
annotations[GOOGLE_CLOUD_TEST] = "test"
5253
filtered_resources.append(resource)
53-
elif _HOOK_FAILURE.index(helm_hook):
54+
elif helm_hook in _HOOK_FAILURE:
5455
if args.deploy_tests:
5556
raise Exception("Helm hook {} is not supported".format(helm_hook))
5657
else:

marketplace/dev/Dockerfile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM marketplace.gcr.io/google/ubuntu2004
1+
FROM marketplace.gcr.io/google/ubuntu2204
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
apt-transport-https \
@@ -13,7 +13,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
gnupg \
1414
python3 \
1515
python3-pip \
16-
python-is-python3 \
1716
&& rm -rf /var/lib/apt/lists/*
1817

1918
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
@@ -24,27 +23,25 @@ RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.c
2423
RUN pip3 install \
2524
wheel \
2625
pyOpenSSL \
27-
pyyaml \
28-
six
26+
pyyaml
2927

30-
RUN for full_version in 1.26.5 1.26.5 1.27.2; \
28+
RUN for full_version in 1.27.3 1.28.3; \
3129
do \
3230
version=${full_version%.*} \
3331
&& mkdir -p /opt/kubectl/$version \
3432
&& wget -q -O /opt/kubectl/$version/kubectl \
3533
https://storage.googleapis.com/kubernetes-release/release/v$full_version/bin/linux/amd64/kubectl \
3634
&& chmod 755 /opt/kubectl/$version/kubectl; \
3735
done;
38-
RUN ln -s /opt/kubectl/1.26 /opt/kubectl/default
36+
RUN ln -s /opt/kubectl/1.27 /opt/kubectl/default
3937

40-
RUN echo "deb [signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu focal edge" | tee /etc/apt/sources.list.d/docker.list \
38+
RUN echo "deb [signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" | tee /etc/apt/sources.list.d/docker.list \
4139
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key --keyring /usr/share/keyrings/docker.gpg add - \
4240
&& apt-get -y update \
43-
&& apt-get -y install docker-ce=5:19.03.13~3-0~ubuntu-focal
44-
41+
&& apt-get -y install docker-ce
4542
RUN mkdir -p /bin/helm-downloaded \
4643
&& wget -q -O /bin/helm-downloaded/helm.tar.gz \
47-
https://get.helm.sh/helm-v3.12.2-linux-amd64.tar.gz \
44+
https://get.helm.sh/helm-v3.13.2-linux-amd64.tar.gz \
4845
&& tar -zxvf /bin/helm-downloaded/helm.tar.gz -C /bin/helm-downloaded \
4946
&& mv /bin/helm-downloaded/linux-amd64/helm /bin/ \
5047
&& rm -rf /bin/helm-downloaded

0 commit comments

Comments
 (0)