Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move from python 2 to 3 #656

Merged
merged 12 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defaults: &defaults
jobs:
is_upstream:
docker:
- image: cimg/python:3.10
- image: cimg/python:3.12
steps:
- run: |
set -veuo pipefail
Expand All @@ -34,8 +34,8 @@ jobs:
<<: *defaults
steps:
- checkout
- run: sudo apt-get update; sudo apt-get install shunit2
- run: sudo pip install pytest # todo cache these
- run: sudo apt-get update; sudo apt-get install shunit2 python3-pip
- run: sudo pip3 install pytest # todo cache these
- run: sudo make deps # todo cache these
- run: make test

Expand Down
100 changes: 100 additions & 0 deletions .stignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.git
# Byte-compiled / optimized / DLL files
__pycache__
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build
develop-eggs
dist
downloads
eggs
.eggs
lib
lib64
parts
sdist
var
wheels
pip-wheel-metadata
share/python-wheels
*.egg-info
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build

# PyBuilder
target

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env
venv
ENV
env.bak
venv.bak

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mypy
.mypy_cache
.dmypy.json
dmypy.json

# Pyre type checker
.pyre
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2
FROM python:3.12

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2
FROM python:3.12

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
endif

deps:
pip install -r requirements.txt
pip3 install -r requirements.txt

build:
docker build --pull -t install-scripts -f deploy/Dockerfile.prod .
Expand Down Expand Up @@ -113,12 +113,12 @@ shell_composer_linux:
install-scripts-dev \
/bin/bash
test:
python2 -m pytest -v tests
python3 -m pytest -v tests
./test.sh

run:
/dcg --raw > install_scripts/templates/swarm/docker-compose-generate-safe.sh
python2 main.py
python3 main.py

.PHONY: scan
scan: build
Expand Down
2 changes: 1 addition & 1 deletion deploy/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WORKDIR /docker-compose-generate
COPY ./util/docker-compose-generate /docker-compose-generate
RUN make build

FROM python:2
FROM python:3.12

COPY --from=builder /docker-compose-generate/dcg /dcg
RUN apt-get update \
Expand Down
7 changes: 4 additions & 3 deletions install_scripts/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function

import constant
from flask import Flask, Response, abort, redirect, render_template, request, \
jsonify
import semver
Expand All @@ -13,9 +12,11 @@
from shellescape import quote
import tempfile

from . import db, helpers, param, images
from . import db, helpers, param, images, constant

app = Flask(__name__)
project_root = os.path.dirname(__file__)
template_path = os.path.join(project_root, 'templates')
app = Flask(__name__, template_folder=template_path)

_images = images.get_default_images()

Expand Down
3 changes: 2 additions & 1 deletion install_scripts/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def get():
port=param.lookup('MYSQL_PORT'),
database=database,
user=param.lookup('MYSQL_USER'),
password=password)
password=password,
auth_plugin='mysql_native_password')
return db


Expand Down
6 changes: 4 additions & 2 deletions install_scripts/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ def does_customer_exist(customer_id):

# Produce base64 encoding with linebreaks.
def base64_encode(data):
if len(data) == 0:
return ''
encoded = base64.b64encode(data)
return '\n'.join(
encoded[pos:pos + 76] for pos in xrange(0, len(encoded), 76))
encoded[pos:pos + 76] for pos in range(0, len(encoded), 76))


def get_docker_deb_pkg_version(docker_version, lsb_dist, dist_version):
Expand Down Expand Up @@ -567,4 +569,4 @@ def snapshots_use_overlay(replicated_version):
def make_shell_safe(s):
if type(s) == str or type(s) == unicode:
return s.replace('$', '_').replace('`', '\'')
return s
return s
15 changes: 0 additions & 15 deletions okteto-pipeline.yml

This file was deleted.

2 changes: 1 addition & 1 deletion okteto.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY ./util/docker-compose-generate /docker-compose-generate
RUN make build


FROM python:2
FROM python:3.12

COPY --from=builder /docker-compose-generate/dcg /dcg
RUN apt-get update && \
Expand Down
28 changes: 19 additions & 9 deletions okteto.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
name: install-scripts
command: bash
workdir: /go/src/github.com/replicatedhq/install-scripts
sync:
- .:/go/src/github.com/replicatedhq/install-scripts
resources:
limits:
cpu: "2"
memory: 4Gi
icon: https://github.com/okteto/polling/raw/master/icon.png
deploy:
- envsubst < kustomize/overlays/okteto/deployment.tmpl.yaml > kustomize/overlays/okteto/deployment.yaml

- okteto build
-f ./okteto.Dockerfile
-t okteto.dev/install-scripts:${OKTETO_GIT_COMMIT}
--build-arg DD_API_KEY=${DD_API_KEY}
.

- cd kustomize/overlays/okteto && kustomize edit set image replicated/install-scripts=okteto.dev/install-scripts:${OKTETO_GIT_COMMIT}

- kubectl apply -k kustomize/overlays/okteto
dev:
install-scripts:
command: bash
workdir: /go/src/github.com/replicatedhq/install-scripts
sync:
- .:/go/src/github.com/replicatedhq/install-scripts
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
boto3==1.7.25
Flask==0.12.3
boto3==1.35.78
Flask==3.1.0
mysql-connector==2.1.7
pytest==3.0.6
pytest-mock==1.5.0
PyYAML==5.4
pytest==8.3.4
pytest-mock==3.14.0
PyYAML==6.0.2
git+https://github.com/emosbaugh/python-semver@f26d956e2ea13a8159e5629d5b7bf225f8ae5a61#egg=semver
shellescape==3.8.1
uWSGI==2.0.22
uWSGI==2.0.28