Skip to content

Commit

Permalink
feat(setup_devconsole):Toggle feature flag by fetching from devconsol…
Browse files Browse the repository at this point in the history
…e CRD (openshift#18)

* add devconsle routes based on feature flags

* fetch CRDs from oc cluster

* add requested changes

* add script to install operator

* remove webpack devconsole config
  • Loading branch information
karthikjeeyar authored and christianvogt committed May 7, 2019
1 parent 03e9f3a commit 05ff2a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
16 changes: 16 additions & 0 deletions frontend/devconsole.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

DEVCONSOLE_OPERATORS_INSTALLED=$(oc get pods --all-namespaces --output=json | jq '[.items | .[].metadata.name | contains("devops")] | any')
DEVCONSOLE_CRDS_INSTALLED=$(oc get crds --output=json | jq '[.items | .[].metadata.name | contains("gitsources.devopsconsole.openshift.io")] | any')

if $DEVCONSOLE_OPERATORS_INSTALLED && $DEVCONSOLE_CRDS_INSTALLED
then
echo -e "\n\033[0;32m \xE2\x9C\x94 Devconsole Operator and crds are already installed \033[0m\n"
else

echo -e "Installing OLM... \n"
oc create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml
echo -e "\n Installing DevConsole Operator... \n"
oc create -f http://operator-hub-shbose-preview1-stage.b542.starter-us-east-2a.openshiftapps.com/install/devopsconsole.v0.1.0.yaml

fi
10 changes: 8 additions & 2 deletions frontend/public/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,15 @@ const detectUser = dispatch => coFetchJSON('api/kubernetes/apis/user.openshift.i
},
);

const devopsConsolePath = `${k8sBasePath}/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/gitsources.devopsconsole.openshift.io`;
const detectDevConsole = dispatch => {
const devconsoleEnabled = !!(process.env.DEVCONSOLE_ENABLED && process.env.NODE_ENV === 'development');
setFlag(dispatch, FLAGS.SHOW_DEV_CONSOLE, devconsoleEnabled);
coFetchJSON(devopsConsolePath)
.then(
res => setFlag(dispatch, FLAGS.SHOW_DEV_CONSOLE, true),
err => _.get(err, 'response.status') === 404
? setFlag(dispatch, FLAGS.SHOW_DEV_CONSOLE, false)
: handleError(err, FLAGS.SHOW_DEV_CONSOLE, dispatch, detectDevConsole)
)
};

export const featureActions = [
Expand Down
17 changes: 0 additions & 17 deletions frontend/webpack.devconsole.config.ts

This file was deleted.

0 comments on commit 05ff2a6

Please sign in to comment.