Skip to content

Commit b0a0863

Browse files
committed
Issue microservices-platform/microservices-assesment-platform#1207 GraphQL: create a demo shell script that illustrates integration with CircleCI (for example): fix
-Renamed "build-service.adoc" to "set-service-github-url.adoc" -Added api-endpoint as an optional variable -Renamed environment variable MSAT_USER_LOGIN to MSAT_ACCESS_KEY_ID -Renamed environment variable MSAT_USER_PASSWORD to MSAT_SECRET_ACCESS_KEY
1 parent 32cdba5 commit b0a0863

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

docs/build-service.adoc

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/microservices-assessment-platform-api.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ include::./schema.adoc[]
2020

2121
include::./queries.adoc[]
2222

23-
include::./build-service.adoc[]
23+
include::./set-service-github-url.adoc[]

docs/set-service-github-url.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
== Set github url metadata property to service
2+
3+
To set github url metadata property to service you can run:
4+
[source]
5+
----
6+
./msat-set-service-repo-url-metadata.sh application_name service_name organization_name
7+
----
8+
9+
It will create service if it does not exist and set github repository as metadata property.
10+
To run this script environment variables MSAT_ACCESS_KEY_ID and MSAT_SECRET_ACCESS_KEY must be set. +
11+
Also, you can set API endpoint where requests will be sent:
12+
[source]
13+
----
14+
./msat-set-service-repo-url-metadata.sh --api-endpoint endpoint application_name service_name organization_name
15+
----
16+
Default endpoint is https://platform.microservices.io/graphql

msat-set-service-repo-url-metadata.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
#! /bin/bash -e
22

3+
while [ -n "$1" ]
4+
do
5+
case $1 in
6+
--api-endpoint)
7+
api_endpoint=${2?}
8+
shift
9+
;;
10+
*)
11+
break
12+
;;
13+
esac
14+
shift
15+
done
16+
17+
if [ -z $api_endpoint ]
18+
then
19+
api_endpoint="https://platform.microservices.io/graphql"
20+
fi
21+
322
application=${1?}
423
service=${2?}
524
organization=$3
625

7-
curl -X POST "$MSAT_API_ENDPOINT" \
8-
-u $MSAT_USER_LOGIN:$MSAT_USER_PASSWORD \
26+
curl -X POST "$api_endpoint" \
27+
-u ${MSAT_ACCESS_KEY_ID?}:${MSAT_SECRET_ACCESS_KEY?} \
928
-d '
1029
{
1130
"query": "mutation findOrCreateServiceByName ($serviceName: ServiceName!) { findOrCreateServiceByName (serviceName: $serviceName) { organizationId applicationId serviceId } }",
@@ -19,10 +38,10 @@ curl -X POST "$MSAT_API_ENDPOINT" \
1938
}
2039
'
2140

22-
github_repo=`git remote -v | grep -o "origin\s.*\s(fetch)" | awk '{ print $2 }'`
41+
github_repo=`git remote get-url origin`
2342

24-
curl -X POST "$MSAT_API_ENDPOINT" \
25-
-u $MSAT_USER_LOGIN:$MSAT_USER_PASSWORD \
43+
curl -X POST "$api_endpoint" \
44+
-u ${MSAT_ACCESS_KEY_ID?}:${MSAT_SECRET_ACCESS_KEY?} \
2645
-d '
2746
{
2847
"query": "mutation updateServiceMetadata ($organization: String, $applicationName: String!, $serviceName: String!, $metadata: [MetadataInput!]!) {\n updateServiceMetadata (organization: $organization, applicationName: $applicationName, serviceName: $serviceName, metadata: $metadata)\n}",

0 commit comments

Comments
 (0)