Commit 1d860ade authored by Anuj Gupta's avatar Anuj Gupta
Browse files

Merge branch 'ibm_bootscrap_schema' into 'master'

Ibm bootstrap schema

See merge request !114
parents a504c836 c5ba4519
Pipeline #45856 passed with stages
in 22 minutes and 43 seconds
......@@ -11,6 +11,8 @@ variables:
IBM_BUILD_SUBDIR: provider/schema-ibm
IBM_INT_TEST_SUBDIR: testing/schema-test-core
IBM_TEST_CMD: verify
IBM_DEPLOYMENTS_SUBDIR: deployments/scripts/ibm
IBM_DEPLOYMENTS_SCRIPTS_SUBDIR: deployments/scripts
AZURE_SERVICE: schema
AZURE_BUILD_SUBDIR: provider/schema-azure
......@@ -65,6 +67,7 @@ include:
- local: "/devops/azure/gitlab-bootstrap.yml"
- local: "/devops/aws/bootstrap.yaml"
- local: "/devops/ibm/bootstrap.yaml"
osdu-gcp-test:
image: maven:3.6.3-jdk-8
......
import json
import requests
import http.client
import os;
class IBMToken(object):
def get_ibm_id_token(self):
url = 'https://' + os.getenv('IBM_KEYCLOAK_URL') + '/auth/realms/OSDU/protocol/openid-connect/token'
clientId = os.getenv('IBM_KEYCLOAK_CLIENT_ID')
clientSecret = os.getenv('IBM_KEYCLOAK_CLIENT_SECRET')
grantType = 'password'
userName = os.getenv('IBM_AUTH_USER_ACCESS')
password = os.getenv('IBM_AUTH_USER_ACCESS_PASSWORD')
scope = 'openid'
if url is None:
print('Please pass url to generate token')
exit(1)
if clientId is None:
print('Please pass client id to generate token')
exit(1)
if clientSecret is None:
print('Please pass client secret to generate token')
exit(1)
if grantType is None:
print('Please pass client secret to generate token')
exit(1)
if userName is None:
print('Please pass client secret to generate token')
exit(1)
if password is None:
print('Please pass client secret to generate token')
exit(1)
if scope is None:
print('Please pass client secret to generate token')
exit(1)
try:
response = requests.post(url, data={"grant_type": grantType,
"client_id": clientId,
"client_secret" : clientSecret,
"username": userName,
"password": password, "scope": scope})
result = response.json()
token = 'Bearer ' + result['access_token']
print(token)
except Exception as e:
print(e)
if __name__ == '__main__':
IBMToken().get_ibm_id_token()
export IBM_SCHEMA_URL=$IBM_SCHEMA_HOST/api/schema-service/v1/schema
BEARER_TOKEN=`python $IBM_DEPLOYMENTS_SUBDIR/Token.py`
export BEARER_TOKEN=$BEARER_TOKEN
echo $BEARER_TOKEN
python $IBM_DEPLOYMENTS_SCRIPTS_SUBDIR/DeploySharedSchemas.py -u $IBM_SCHEMA_URL
ibm_bootstrap:
stage: bootstrap
image: python:3.8
needs: ["ibm-deploy"]
extends:
- .ibm_variables
script:
- pip install -r $IBM_DEPLOYMENTS_SUBDIR/requirements.txt
- chmod +x $IBM_DEPLOYMENTS_SUBDIR/bootstrap.sh
- $IBM_DEPLOYMENTS_SUBDIR/bootstrap.sh
only:
variables:
- $IBM == 'true'
ibm-test:
needs: ["ibm_bootstrap"]
only:
variables:
- $IBM == 'true'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment