Skip to content

Commit

Permalink
Fix ui to accept OS_INSECURE from rc file (#177)
Browse files Browse the repository at this point in the history
Co-authored-by: Suhas <[email protected]>
  • Loading branch information
sharma-tapas and spai-p9 authored Feb 12, 2025
1 parent bbc70f9 commit f200de1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
53 changes: 38 additions & 15 deletions .github/workflows/packer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ on:
- main
release:
types:
- created
- published
workflow_dispatch:
inputs:
branch:
description: 'Branch to use'
required: true
default: 'main'

env:
PACKER_VERSION: "latest"
QCOW2_IMG: quay.io/platform9/vjailbreak
UI_IMG: quay.io/platform9/vjailbreak-ui
V2V_IMG: quay.io/platform9/vjailbreak-v2v-helper
CONTROLLER_IMG: quay.io/platform9/vjailbreak-controller
QCOW2_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak
UI_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-ui
V2V_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-v2v-helper
CONTROLLER_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-controller

jobs:
build-containers:
Expand All @@ -35,8 +41,8 @@ jobs:
patch-wording: 'patch,fixes' # Providing patch-wording will override commits
# defaulting to a patch bump.
rc-wording: 'RELEASE,alpha'
skip-commit: 'true'
skip-tag: 'true'
skip-commit: 'true'
skip-push: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -45,35 +51,47 @@ jobs:
run: |
# Get the branch name, remove 'refs/heads/' from github.ref
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
# If the branch is 'main', don't append the branch name to the tag
if [ "$BRANCH_NAME" == "main" ]; then
TAG=${{ steps.bump_version.outputs.newTag }}
elif [[ "${{ github.event_name }}" == "release" ]]; then
TAG=${{ steps.bump_version.outputs.newTag }}
GIT_SHA=$(echo "$(git rev-parse --short HEAD)")
GIT_BRANCH=$(echo "$(git rev-parse --abbrev-ref HEAD)")
# if its a release event bump the version and use that as tag
if [[ "${{ github.event_name }}" == "release" ]]; then
# In case of release event the tag will be the next version
# build version will be the same as tag
TAG=${{ github.event.release.tag_name }}
BUILD_VERSION=${TAG}
else
TAG=${{ steps.bump_version.outputs.newTag }}-$BRANCH_NAME
BUILD_VERSION=${{ github.run_number }}
# build release version as version-branch-sha
VERSION=${BUILD_VERSION}-${GIT_BRANCH}-${GIT_SHA}
# Since this is a merge or pull-request
# use the TAG as the version
TAG=${VERSION}
fi
echo "TAG=$TAG" >> $GITHUB_ENV
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "QCOW2_IMG=${{ env.QCOW2_IMG }}:$TAG" >> $GITHUB_ENV
echo "UI_IMG=${{ env.UI_IMG }}:$TAG" >> $GITHUB_ENV
echo "V2V_IMG=${{ env.V2V_IMG }}:$TAG" >> $GITHUB_ENV
echo "CONTROLLER_IMG=${{ env.CONTROLLER_IMG }}:$TAG" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: quay.io
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.QUAY_ROBOT_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_PASSWORD }}

- name: Build and push UI image
run: make ui

- name: Build and push helper image
- name: Build and push v2v-helper image
run: make v2v-helper

- name: Build and push controller image
Expand Down Expand Up @@ -118,6 +136,11 @@ jobs:
echo "release_found=true" >> $GITHUB_ENV
fi
- name: Check if manual trigger from main branch
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
run: echo "release_found=true" >> $GITHUB_ENV
id: check_manual_trigger

- name: Enable KVM group perms
if: env.release_found == 'true'
run: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.1.1"
"version": "0.1.2"
}
12 changes: 12 additions & 0 deletions ui/src/api/openstack-creds/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { v4 as uuidv4 } from "uuid"



// Helper function to parse OS_INSECURE from string to boolean
const getBooleanValue = (value: string | undefined): boolean | undefined => {
if (value === undefined) return undefined;
return value.toLowerCase() === "true";
};



export const createOpenstackCredsJson = (params) => {
const {
name,
Expand All @@ -10,6 +20,7 @@ export const createOpenstackCredsJson = (params) => {
OS_PASSWORD,
OS_REGION_NAME,
OS_TENANT_NAME,
OS_INSECURE,
} = params || {}
return {
apiVersion: "vjailbreak.k8s.pf9.io/v1alpha1",
Expand All @@ -25,6 +36,7 @@ export const createOpenstackCredsJson = (params) => {
OS_PASSWORD,
OS_REGION_NAME,
OS_TENANT_NAME,
OS_INSECURE: getBooleanValue(OS_INSECURE),
},
}
}

0 comments on commit f200de1

Please sign in to comment.