Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
faermanj committed Sep 28, 2023
1 parent 3dd39aa commit dcfe9d1
Show file tree
Hide file tree
Showing 23 changed files with 441 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
33 changes: 33 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# docker build --no-cache --progress=plain -t caravanacloud/up -f Containerfile .
# docker run -it --rm caravanacloud/up echo uala

FROM registry.fedoraproject.org/fedora:38

RUN sudo dnf -y install python3 python3-pip
#RUN python3 --version

ARG YOUR_ENV
ARG POETRY_VERSION=1.6.1
ENV YOUR_ENV=${YOUR_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=${POETRY_VERSION}
RUN pip3 install "poetry==$POETRY_VERSION"

RUN mkdir -p /opt/up
WORKDIR /opt/up

COPY . .

WORKDIR /opt/up/up_cli
RUN ls
RUN poetry config virtualenvs.create false
# --without dev
RUN poetry install

ENTRYPOINT ["poetry", "--quiet", "run", "python3", "-m", "up_cli.main"]

4 changes: 1 addition & 3 deletions archive/up_cli/src/up_cli/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import logging as log
import up_lib
from datetime import datetime


Expand Down Expand Up @@ -31,8 +30,7 @@ def main():
"executable": executable
}
try:
up_lib.up(line= line,
context= context)
log.info("Starting UP cli")
except Exception as ex:
exit_cli(333)

Expand Down
134 changes: 134 additions & 0 deletions archive/up_images/up_rh/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# docker build --no-cache --progress=plain -t caravanacloud/up_rh -f Containerfile .
FROM registry.fedoraproject.org/fedora:38

# Java
ARG JAVA_SDK="21-graalce"
RUN curl -s "https://get.sdkman.io" | bash
RUN bash -c "sdk install java $JAVA_SDK \
&& sdk default java $JAVA_SDK \
&& sdk install quarkus \
&& sdk install maven \
"


# OpenShift Installer
RUN bash -c "mkdir -p '/tmp/openshift-installer' \
&& wget -nv -O '/tmp/openshift-installer/openshift-install-linux.tar.gz' 'https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest/openshift-install-linux.tar.gz' \
&& tar zxvf '/tmp/openshift-installer/openshift-install-linux.tar.gz' -C '/tmp/openshift-installer' \
&& sudo mv '/tmp/openshift-installer/openshift-install' '/usr/local/bin/' \
&& rm '/tmp/openshift-installer/openshift-install-linux.tar.gz'\
"

# Credentials Operator CLI
RUN bash -c "mkdir -p '/tmp/ccoctl' \
&& wget -nv -O '/tmp/ccoctl/ccoctl-linux.tar.gz' 'https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest/ccoctl-linux.tar.gz' \
&& tar zxvf '/tmp/ccoctl/ccoctl-linux.tar.gz' -C '/tmp/ccoctl' \
&& sudo mv '/tmp/ccoctl/ccoctl' '/usr/local/bin/' \
&& rm '/tmp/ccoctl/ccoctl-linux.tar.gz'\
"

# OpenShift CLI
RUN bash -c "mkdir -p '/tmp/oc' \
&& wget -nv -O '/tmp/oc/openshift-client-linux.tar.gz' 'https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest/openshift-client-linux.tar.gz' \
&& tar zxvf '/tmp/oc/openshift-client-linux.tar.gz' -C '/tmp/oc' \
&& sudo mv '/tmp/oc/oc' '/usr/local/bin/' \
&& sudo mv '/tmp/oc/kubectl' '/usr/local/bin/' \
&& rm '/tmp/oc/openshift-client-linux.tar.gz' \
"

# Red Hat OpenShift on AWS CLI
RUN bash -c "mkdir -p '/tmp/rosa' \
&& wget -nv -O '/tmp/rosa/rosa-linux.tar.gz' 'https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/rosa/latest/rosa-linux.tar.gz' \
&& tar zxvf '/tmp/rosa/rosa-linux.tar.gz' -C '/tmp/rosa' \
&& sudo mv '/tmp/rosa/rosa' '/usr/local/bin/' \
&& rm '/tmp/rosa/rosa-linux.tar.gz' \
"

# odo
ARG ODO_URL="https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/v3.10.0/odo-linux-amd64"
RUN bash -c "curl -L ${ODO_URL} -o odo \
&& curl -L ${ODO_URL}.sha256 -o odo.sha256 \
&& echo "$(<odo.sha256) odo" | shasum -a 256 --check \
&& sudo install -o root -g root -m 0755 odo /usr/local/bin/odo \
"

# OpenShift Local (crc) - no virt flags
# ARG CRC_URL="https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz"
# RUN bash -c "mkdir -p '/tmp/crc' \
# && wget -nv -O '/tmp/crc/crc-linux-amd64.tar.xz' '${CRC_URL}' \
# && tar xvf '/tmp/crc/crc-linux-amd64.tar.xz' -C '/tmp/crc' \
# && find '/tmp/crc' \
# && sudo mv /tmp/crc/crc-linux-*/crc '/usr/local/bin/' \
# && rm '/tmp/crc/crc-linux-amd64.tar.xz' \
# "


# krew
# RUN OS="$(uname | tr '[:upper:]' '[:lower:]')" && \
# ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && \
# curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz" && \
# tar zxvf krew.tar.gz && \
# KREW=./krew-"${OS}_${ARCH}" && \
# "$KREW" install krew && \
# cp $HOME/.krew/bin/kubectl-krew /usr/local/bin/
#

# Operator SDK
RUN bash -c "brew install operator-sdk"

# Helm, Terraform, Terragrunt
RUN bash -c "brew install helm terraform terragrunt"

# KAN https://github.com/redhat-developer/kam

# Tackle
# RUN bash -c 'git clone "https://github.com/kubernetes/test-infra" "/tmp/test-infra" \
# && cd /tmp/test-infra/prow/cmd/tackle \
# && go build -o tackle \
# && sudo mv tackle /usr/sbin/tackle \
# '

# ArgoCD and Tekton
RUN bash -c "brew install argocd"
RUN bash -c "sudo apt install -y tektoncd-cli \
&& tkn version"

# Kustomize
RUN bash -c "curl -s 'https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh' | bash"

# AWS CLIs
RUN bash -c "curl 'https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o 'awscliv2.zip' && unzip awscliv2.zip \
&& sudo ./aws/install \
&& aws --version \
"

RUN bash -c "npm install -g aws-cdk"

ARG SAM_URL="https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"
RUN bash -c "curl -Ls '${SAM_URL}' -o '/tmp/aws-sam-cli-linux-x86_64.zip' \
&& unzip '/tmp/aws-sam-cli-linux-x86_64.zip' -d '/tmp/sam-installation' \
&& sudo '/tmp/sam-installation/install' \
&& sam --version"

RUN bash -c "pip install cloudformation-cli cloudformation-cli-java-plugin cloudformation-cli-go-plugin cloudformation-cli-python-plugin cloudformation-cli-typescript-plugin"

# Azure CLI
RUN bash -c "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"

# Aliyun CLI
RUN bash -c "brew install aliyun-cli"

# Google CLI
RUN bash -c "curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-437.0.1-linux-x86_64.tar.gz \
&& tar -xf google-cloud-cli-437.0.1-linux-x86_64.tar.gz \
&& rm google-cloud-cli-437.0.1-linux-x86_64.tar.gz \
&& ./google-cloud-sdk/install.sh --quiet \
&& sudo ln -s /workspace/red-pod/google-cloud-sdk/bin/gcloud /usr/local/bin/gcloud \
"

# Oracle Cloud CLI
RUN bash -c "brew install oci-cli"

# Done :)
RUN bash -c "echo 'done.'"

Empty file added up_ansible/README.md
Empty file.
14 changes: 14 additions & 0 deletions up_ansible/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "up-ansible"
version = "0.1.0"
description = ""
authors = ["Julio Faerman <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file added up_ansible/tests/__init__.py
Empty file.
Empty file.
Empty file added up_cli/README.md
Empty file.
21 changes: 21 additions & 0 deletions up_cli/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions up_cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "up"
version = "0.1.0"
description = ""
authors = ["Julio Faerman <[email protected]>"]
readme = "README.md"
packages = [
{ include = "up_cli", from="./src/"}
]

[tool.poetry.dependencies]
python = "^3.11"
pluggy = "^1.3.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
up = 'up_cli.main:main'
Empty file added up_cli/src/up_cli/__init__.py
Empty file.
49 changes: 49 additions & 0 deletions up_cli/src/up_cli/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
import logging as log
from datetime import datetime


def print_help():
log.debug("Please please help me")

def exit_cli(code=-1):
if code:
log.error("Exiting up cli with code %s", code)
sys.exit(code)

def init():
sys.set_int_max_str_digits(999999)
level = log.DEBUG
log.basicConfig(stream=sys.stderr, level=level)

def main():
init()
now = datetime.now()
log.info(f"Starting UP cli at {now.isoformat()}")
args = sys.argv
len_args = len(args)
if len_args < 1:
print_help()
exit_cli("NO_COMMAND_SPECIFIED")
executable = args[0]
line = args[1:]
log.debug(f"executable: {executable}")
log.debug(f"line: {line}")
context = {
"executable": executable
}
try:
log.info("UP entrypoint reached")
start_container()
log.debug("UP done")
except Exception as ex:
exit_cli(333)

def start_container():
log.info("Starting container")
image = "caravanacloud/up_rh"


if __name__ == '__main__':
main()

Empty file added up_cli/tests/__init__.py
Empty file.
Loading

0 comments on commit dcfe9d1

Please sign in to comment.