-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add script that generate app-config.local.yaml
- Loading branch information
Showing
2 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Backstage override configuration for QShift | ||
|
||
organization: | ||
name: ${BACKSTAGE_ORG} | ||
|
||
app: | ||
title: ${BACKSTAGE_TITLE} | ||
baseUrl: http://localhost:3000 | ||
|
||
backend: | ||
baseUrl: http://localhost:7007 | ||
listen: | ||
port: 7007 | ||
csp: | ||
connect-src: ["'self'", 'http:', 'https:'] | ||
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference | ||
# Default Helmet Content-Security-Policy values can be removed by setting the key to false | ||
cors: | ||
origin: http://localhost:3000 | ||
methods: [GET, HEAD, PATCH, POST, PUT, DELETE] | ||
credentials: true | ||
# This is for local development only, it is not recommended to use this in production | ||
# The production database configuration is stored in app-config.production.yaml | ||
database: | ||
client: better-sqlite3 | ||
connection: ':memory:' | ||
auth: | ||
# Used for enabling authentication, secret is shared by all backend plugins | ||
# See https://backstage.io/docs/auth/service-to-service-auth for | ||
# information on the format | ||
keys: | ||
- secret: HCS2MVvZueiKlfKxCMhNY6XuRiOU9Pe2 | ||
reading: | ||
allow: | ||
- host: 'raw.githubusercontent.com' | ||
|
||
auth: | ||
# see https://backstage.io/docs/auth/ to learn about auth providers | ||
providers: | ||
guest: {} | ||
|
||
# Reference documentation http://backstage.io/docs/features/techdocs/configuration | ||
# Note: After experimenting with basic setup, use CI/CD to generate docs | ||
# and an external cloud storage when deploying TechDocs for production use-case. | ||
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach | ||
techdocs: | ||
builder: 'local' # Alternatives - 'external' | ||
generator: | ||
runIn: 'docker' # Alternatives - 'local' | ||
publisher: | ||
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using [email protected] | ||
|
||
catalog: | ||
import: | ||
entityFilename: catalog-info.yaml | ||
rules: | ||
- allow: [ Component, System, API, Resource, Location ] | ||
locations: | ||
# Quarkus template, org, entity | ||
- type: file | ||
# The path needs to be relative to the root of the repository | ||
target: ../../locations/root.yaml | ||
rules: | ||
- allow: [ Component, System, API, Resource, Location, Group, User, Template ] | ||
- type: file | ||
# The path needs to be relative to the root of the repository | ||
target: ../../examples/components/all.yaml | ||
rules: | ||
- allow: [ Component, System, API, Resource, Location, Group, User, Template ] | ||
|
||
|
||
integrations: | ||
github: | ||
- host: github.com | ||
token: ${GITHUB_TOKEN} | ||
|
||
argocd: | ||
username: ${ARGOCD_USERNAME} | ||
password: ${ARGOCD_PASSWORD} | ||
baseUrl: https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev | ||
appLocatorMethods: | ||
- type: config | ||
instances: | ||
- name: argocdQShift | ||
url: https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev | ||
|
||
proxy: | ||
endpoints: | ||
'/argocd/api': | ||
target: https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev | ||
changeOrigin: true | ||
secure: false | ||
rejectUnauthorized: false | ||
headers: | ||
Cookie: | ||
$env: ${ARGOCD_COOKIE} | ||
kubernetes: | ||
serviceLocatorMethod: | ||
type: 'multiTenant' | ||
clusterLocatorMethods: | ||
- type: 'config' | ||
clusters: | ||
- url: https://api.qshift.snowdrop.dev:6443 | ||
name: ocp-qshift | ||
authProvider: 'serviceAccount' | ||
skipTLSVerify: true | ||
skipMetricsLookup: true | ||
serviceAccountToken: ${KUBERNETES_SERVICE_ACCOUNT_TOKEN} | ||
customResources: | ||
- group: 'tekton.dev' | ||
apiVersion: 'v1' | ||
plural: 'pipelineruns' | ||
- group: 'tekton.dev' | ||
apiVersion: 'v1' | ||
plural: 'taskruns' | ||
- apiVersion: 'v1' | ||
group: 'route.openshift.io' | ||
plural: 'routes' | ||
defaultGroupId: "da.mycompany" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Render app-config.local.yaml from template | ||
# | ||
|
||
# Fallback to the second argument if the first is empty | ||
setf() { | ||
if [ -z "${!1}" ]; then | ||
export $1="$2" | ||
fi | ||
} | ||
|
||
usage() { | ||
echo "Usage: $0 [options]" | ||
echo "Options:" | ||
echo " -t, --title <title> The title of the Backstage instance" | ||
echo " -o, --org <org> The organization name" | ||
echo " -u, --github-user <github-user> The GitHub user" | ||
echo " --github-token <github-token> The GitHub token" | ||
echo " --github-client-id <client-id> The GitHub client id" | ||
echo " --github-client-secret <secret> The GitHub client secret" | ||
exit 1 | ||
} | ||
|
||
# Set defaults | ||
setf "BACKSTAGE_TITLE" "My Backstage" | ||
setf "BACKSTAGE_ORG" "q-shift" | ||
setf "BACKSTAGE_GITHUB_USER" "q-shift" | ||
setf "BACKSTAGE_GITHUB_TOKEN" "" | ||
setf "BACKSTAGE_TEAM_NAME" "team" | ||
|
||
# | ||
# Optionally override the default values (above) with command line arguments: | ||
# -t: Title | ||
# -o: Organization | ||
# --github-user: GitHub User | ||
# --github-token: GitHub Token | ||
# --github-client-id: GitHub Client ID | ||
# --github-client-secret: GitHub Client Secret | ||
# | ||
while [[ $# -gt 0 ]]; do | ||
echo "Processing $1" | ||
case $1 in | ||
-t|--title) | ||
BACKSTAGE_TITLE=$2 | ||
shift 2 | ||
;; | ||
-o|--org) | ||
BACKSTAGE_ORG=$2 | ||
shift 2 | ||
;; | ||
-u|--github-user) | ||
BACKSTAGE_GITHUB_USER=$2 | ||
shift 2 | ||
;; | ||
--github-token) | ||
BACKSTAGE_GITHUB_TOKEN=$2 | ||
shift 2 | ||
;; | ||
--github-client-id) | ||
BACKSTAGE_GITHUB_CLIENT_ID=$2 | ||
shift 2 | ||
;; | ||
-github-client-secret) | ||
BACKSTAGE_GITHUB_CLIENT_SECRET=$2 | ||
shift 2 | ||
;; | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
-*|--*) | ||
echo "Unknown option $1" | ||
usage | ||
exit 1 | ||
;; | ||
*) | ||
POSITIONAL_ARGS+=("$1") # save positional arg | ||
shift # past argument | ||
;; | ||
esac | ||
done | ||
|
||
# Kubernetes | ||
setf KUBERNETES_CLUSTER_NAME "default" | ||
setf KUBERNETES_CONFIG_PATH "$HOME/.kube/config" | ||
setf KUBERNETES_API_URL `kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'` | ||
setf KUBERNETES_USER `kubectl config view --minify -o jsonpath='{.users[0].name}'` | ||
setf KUBERNETES_TOKEN `cat $KUBERNETES_CONFIG_PATH | grep -A 2 "name: $KUBERNETES_USER" | grep token | awk '{print $2}'` | ||
|
||
|
||
# Argo CD | ||
export ARGOCD_USERNAME=admin | ||
export ARGOCD_PASSWORD=`kubectl get secrets -n openshift-gitops argocd-cluster -o yaml | grep password | awk '{print $2}' | base64 -d` | ||
export ARGOCD_COOKIE=`kubectl get secrets -n openshift-gitops argocd-secret -o yaml | grep clientSecret | awk '{print $2}' | base64 -d` | ||
|
||
# Github | ||
|
||
if [ -z "$BACKSTAGE_GITHUB_TOKEN" ]; then | ||
if command -v gh &> /dev/null; then | ||
setf BACKSTAGE_GITHUB_TOKEN `gh auth status -t | grep Token: | awk -F": " '{print $2}'` | ||
else | ||
echo "BACKSTAGE_GITHUB_TOKEN is not defined and can't be read from 'gh' command. Aborting" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "BACKSTAGE_TITLE=$BACKSTAGE_TITLE" | ||
echo "BACKSTAGE_ORG=$BACKSTAGE_ORG" | ||
echo "BACKSTAGE_GITHUB_USER=$BACKSTAGE_GITHUB_USER" | ||
echo "BACKSTAGE_GITHUB_TOKEN=$BACKSTAGE_GITHUB_TOKEN" | ||
echo "BACKSTAGE_GITHUB_CLIENT_ID=$BACKSTAGE_GITHUB_CLIENT_ID" | ||
echo "BACKSTAGE_GITHUB_CLIENT_SECRET=$BACKSTAGE_GITHUB_CLIENT_SECRET" | ||
echo "KUBERNETES_API_URL=$KUBERNETES_API_URL" | ||
echo "KUBERNETES_USER=$KUBERNETES_USER" | ||
|
||
envsubst < app-config.local.yaml.tmpl > app-config.local.yaml | ||
|
||
|
||
export NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
|
||
# Run Backstage in Development Mode | ||
yarn dev |