Skip to content

1207 create a demo shell script that illustrates integration with CircleCI #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
public
.env.*
2 changes: 2 additions & 0 deletions docs/microservices-assessment-platform-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ include::./console-how-to.adoc[]
include::./schema.adoc[]

include::./queries.adoc[]

include::./set-service-github-url.adoc[]
16 changes: 16 additions & 0 deletions docs/set-service-github-url.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
== Set github url metadata property to service

To set github url metadata property to service you can run:
[source]
----
./msat-set-service-repo-url-metadata.sh application_name service_name organization_name
----

It will create service if it does not exist and set github repository as metadata property.
To run this script environment variables MSAT_ACCESS_KEY_ID and MSAT_SECRET_ACCESS_KEY must be set. +
Also, you can set API endpoint where requests will be sent:
[source]
----
./msat-set-service-repo-url-metadata.sh --api-endpoint endpoint application_name service_name organization_name
----
Default endpoint is https://platform.microservices.io/graphql
55 changes: 55 additions & 0 deletions msat-set-service-repo-url-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#! /bin/bash -e

api_endpoint="https://platform.microservices.io/graphql"

while [ -n "$1" ]
do
case $1 in
--api-endpoint)
api_endpoint=${2?}
shift
;;
*)
break
;;
esac
shift
done

application=${1?}
service=${2?}
organization=$3

curl -X POST "$api_endpoint" \
-u ${MSAT_ACCESS_KEY_ID?}:${MSAT_SECRET_ACCESS_KEY?} \
-d '
{
"query": "mutation findOrCreateServiceByName ($serviceName: ServiceName!) { findOrCreateServiceByName (serviceName: $serviceName) { organizationId applicationId serviceId } }",
"variables": {
"serviceName": {
"organization": "'"$organization"'",
"application": "'"$application"'",
"service": "'"$service"'"
}
}
}
'

github_repo=`git remote get-url origin`

curl -X POST "$api_endpoint" \
-u ${MSAT_ACCESS_KEY_ID?}:${MSAT_SECRET_ACCESS_KEY?} \
-d '
{
"query": "mutation updateServiceMetadata ($organization: String, $applicationName: String!, $serviceName: String!, $metadata: [MetadataInput!]!) {\n updateServiceMetadata (organization: $organization, applicationName: $applicationName, serviceName: $serviceName, metadata: $metadata)\n}",
"variables": {
"organization": "'"$organization"'",
"applicationName": "'"$application"'",
"serviceName":"'"$service"'",
"metadata": {
"name": "github-repo",
"value": "'"$github_repo"'"
}
}
}
'