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

Attempt to fix broker quay image build/push #258

Merged
merged 1 commit into from
Jan 23, 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
1 change: 1 addition & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
publish:
name: Build and Deploy to PyPi
runs-on: ubuntu-latest
if: github.repository == 'SatelliteQE/broker'
strategy:
matrix:
# build/push in lowest support python version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update_broker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
broker_container:
name: Update Broker container image on Quay.
runs-on: ubuntu-latest
if: github.repository == 'SatelliteQE/broker'

steps:
- name: Checkout
Expand All @@ -29,6 +30,6 @@ jobs:
- name: Build and push image to Quay
uses: docker/build-push-action@v5
with:
file: ./Dockerfile
context: .
push: true
tags: ${{ secrets.QUAY_SERVER }}/${{ secrets.QUAY_NAMESPACE }}/broker:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ ENV/
# project
*settings.yaml
inventory.yaml
*.bak
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ RUN dnf -y install make cmake gcc-c++ zlib-devel \
openssl-devel git python3-pip python3-devel \
&& dnf clean all
WORKDIR /root/broker
ENV BROKER_DIRECTORY=/root/broker/
COPY . /root/broker/
RUN pip install .
RUN cp broker_settings.yaml.example broker_settings.yaml

RUN pip install .

ENTRYPOINT ["broker"]
CMD ["--help"]
34 changes: 21 additions & 13 deletions broker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
settings: The settings object.
init_settings: Function to initialize the settings file.
validate_settings: Function to validate the settings file.
interactive_mode: Whether or not Broker is running in interactive mode.
INTERACTIVE_MODE: Whether or not Broker is running in interactive mode.
BROKER_DIRECTORY: The directory where Broker looks for its files.
settings_path: The path to the settings file.
inventory_path: The path to the inventory file.
Expand All @@ -25,21 +25,29 @@ def init_settings(settings_path, interactive=False):
raw_url = (
"https://raw.githubusercontent.com/SatelliteQE/broker/master/broker_settings.yaml.example"
)
if (
not interactive
or click.prompt(
f"Download example file from GitHub?\n{raw_url}",
type=click.Choice(["y", "n"]),
)
== "y"
):
proceed = not False
if interactive:
try:
proceed = (
click.prompt(
f"Download example file from GitHub?\n{raw_url}",
type=click.Choice(["y", "n"]),
default="y",
)
== "y"
)
except click.core.Abort:
# We're likely in a different non-interactive environment (container?)
global INTERACTIVE_MODE
proceed, INTERACTIVE_MODE = True, False
if proceed:
# download example file from github
import requests

click.echo(f"Downloading example file from: {raw_url}")
raw_file = requests.get(raw_url, timeout=60)
settings_path.write_text(raw_file.text)
if interative_mode:
if INTERACTIVE_MODE:
try:
click.edit(filename=str(settings_path.absolute()))
except click.exceptions.ClickException:
Expand All @@ -51,13 +59,13 @@ def init_settings(settings_path, interactive=False):
raise ConfigurationError(f"Broker settings file not found at {settings_path.absolute()}.")


interative_mode = False
INTERACTIVE_MODE = False
# GitHub action context
if "GITHUB_WORKFLOW" not in os.environ:
# determine if we're being ran from a CLI
for frame in inspect.stack()[::-1]:
if "/bin/broker" in frame.filename:
interative_mode = True
INTERACTIVE_MODE = True
break


Expand All @@ -76,7 +84,7 @@ def init_settings(settings_path, interactive=False):

if not settings_path.exists():
click.secho(f"Broker settings file not found at {settings_path.absolute()}.", fg="red")
init_settings(settings_path, interactive=interative_mode)
init_settings(settings_path, interactive=INTERACTIVE_MODE)

validators = [
Validator("HOST_USERNAME", default="root"),
Expand Down