Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from lca1/dev
Browse files Browse the repository at this point in the history
MedCo v0.2.1
  • Loading branch information
mickmis authored Aug 15, 2019
2 parents 381eeca + 71564bd commit 064a470
Show file tree
Hide file tree
Showing 84 changed files with 5,708 additions and 680 deletions.
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@ EXCLUDE_LINT = "_test.go"

# generate/update go server based on swagger specifications
swagger-gen:
swagger validate ./swagger/swagger.yml
swagger validate ./swagger/medco-connector-server.yml
swagger generate server \
--server-package=restapi/server \
--model-package=restapi/models \
--principal=models.User \
--target=./swagger/ \
--spec=./swagger/swagger.yml \
--target=./ \
--spec=./swagger/medco-connector-server.yml \
--name=medco-connector
swagger validate ./swagger/medco-cli-client.yml
swagger generate client \
--client-package=restapi/client \
--existing-models=github.com/lca1/medco-connector/restapi/models \
--skip-models \
--principal=models.User \
--target=./ \
--spec=./swagger/medco-cli-client.yml \
--name=medco-cli \
--default-scheme=https

test_lint:
@echo Checking linting of files
@{ \
go install golang.org/x/lint/golint; \
GO111MODULE=off go get -u golang.org/x/lint/golint; \
el=$(EXCLUDE_LINT); \
lintfiles=$$( golint ./... | egrep -v "$$el" ); \
if [ -n "$$lintfiles" ]; then \
Expand Down
105 changes: 105 additions & 0 deletions cmd/medco-cli-client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package main

import (
medcoclient "github.com/lca1/medco-connector/medco/client"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"os"
"strings"
)

func main() {

cliApp := cli.NewApp()
cliApp.Name = "medco-cli-client"
cliApp.Usage = "Command-line query tool for MedCo."
cliApp.Version = "0.2.1" // todo: dynamically get version from build process

// from env / config: whatever is in the config of GB : debug,
// cli: whatever is user input

// --- global app flags
cliApp.Flags = []cli.Flag{
cli.StringFlag{
Name: "user, u",
Usage: "OIDC user login",
},
cli.StringFlag{
Name: "password, p",
Usage: "OIDC password login",
},
cli.StringFlag{
Name: "token, t",
Usage: "OIDC token",
},
cli.BoolFlag{
Name: "disableTLSCheck",
Usage: "Disable check of TLS certificates",
},
}

// --- search command flags
//searchCommandFlags := []cli.Flag{
// cli.StringFlag{
// Name: "path",
// Usage: "File containing the query definition",
//
// },
//}

//--- query command flags
queryCommandFlags := []cli.Flag{
cli.StringFlag{
Name: "resultFile, r",
Usage: "Output file for the result CSV. Printed to stdout if omitted.",
Value: "",
},
cli.BoolFlag{
Name: "bypassPicsure",
Usage: "Bypass PIC-SURE and query directly the MedCo connectors",
},
}

// --- app commands
cliApp.Commands = []cli.Command{
//{
// Name: "search",
// Aliases: []string{"s"},
// Usage: "Browse the MedCo tree ontology",
// Action: encryptIntFromApp,
// Flags: searchCommandFlags,
// ArgsUsage: "",
//
//},
{
Name: "query",
Aliases: []string{"q"},
Usage: "Query the MedCo network",
Flags: queryCommandFlags,
ArgsUsage: "[patient_list|count_per_site|count_per_site_obfuscated|count_per_site_shuffled|" +
"count_per_site_shuffled_obfuscated|count_global|count_global_obfuscated] [query string]",
Action: func(c *cli.Context) error {
return medcoclient.ExecuteClientQuery(
c.GlobalString("token"),
c.GlobalString("user"),
c.GlobalString("password"),
c.Args().First(),
strings.Join(c.Args().Tail(), " "),
c.String("resultFile"),
c.GlobalBool("disableTLSCheck"),
c.Bool("bypassPicsure"),
)
},
},

}

//cliApp.Before = func(c *cli.Context) error {
// log.SetDebugVisible(c.GlobalInt("debug"))
// return nil
//}
err := cliApp.Run(os.Args)
if err != nil {
logrus.Error(err)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM golang:1.11 as build
FROM golang:1.12 as build

COPY ./ /src

# compile and install medco-connector
# compile and install medco-connector-server
WORKDIR /src
RUN CGO_ENABLED=0 go build -v ./... && \
CGO_ENABLED=0 go install -v ./...
RUN CGO_ENABLED=0 go install -v ./cmd/medco-connector-server/...

# -------------------------------------------
FROM golang:1.11-alpine as release
FROM golang:1.12-alpine as release

COPY deployment/docker-entrypoint.sh /usr/local/bin/
RUN apk update && apk add bash && rm -rf /var/cache/apk/* && \
Expand All @@ -18,21 +17,25 @@ COPY --from=build /go/bin/medco-connector-server /go/bin/

# swagger server configuration
ENV HOST=0.0.0.0 \
PORT=1999
PORT=1999 \
SERVER_HTTP_WRITE_TIMEOUT_SECONDS=600

# run-time environment
ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \
I2B2_LOGIN_DOMAIN=i2b2medco \
I2B2_LOGIN_PROJECT=MedCo \
I2B2_LOGIN_USER=e2etest \
I2B2_LOGIN_PASSWORD=e2etest \
I2B2_WAIT_TIME_SECONDS=300 \
LOG_LEVEL=5 \
UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \
UNLYNX_GROUP_FILE_IDX=0 \
UNLYNX_TIMEOUT_SECONDS=300 \
JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs \
OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master \
OIDC_CLIENT_ID=medco \
OIDC_JWT_USER_ID_CLAIM=preferred_username
OIDC_JWT_USER_ID_CLAIM=preferred_username \
MEDCO_OBFUSCATION_MIN=5

EXPOSE 1999
ENTRYPOINT ["docker-entrypoint.sh"]
ENTRYPOINT docker-entrypoint.sh medco-connector-server --write-timeout=${SERVER_HTTP_WRITE_TIMEOUT_SECONDS}s
30 changes: 30 additions & 0 deletions deployment/client.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM golang:1.12.5 as build

COPY ./ /src

# compile and install medco-cli-client
WORKDIR /src
RUN CGO_ENABLED=0 go install -v ./cmd/medco-cli-client/...

# -------------------------------------------
FROM golang:1.12.5-alpine as release

COPY deployment/docker-entrypoint.sh /usr/local/bin/
RUN apk update && apk add bash && rm -rf /var/cache/apk/* && \
chmod a+x /usr/local/bin/docker-entrypoint.sh

COPY --from=build /go/bin/medco-cli-client /go/bin/

# run-time environment
ENV LOG_LEVEL=5 \
UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \
UNLYNX_GROUP_FILE_IDX=0 \
OIDC_CLIENT_ID=medco \
CLIENT_QUERY_TIMEOUT_SECONDS=660 \
PICSURE2_API_HOST=picsure:8080/pic-sure-api-2/PICSURE \
PICSURE2_API_BASE_PATH="" \
PICSURE2_API_SCHEME=https \
PICSURE2_RESOURCES=MEDCO_testnetwork_0_a,MEDCO_testnetwork_1_b,MEDCO_testnetwork_2_c \
OIDC_REQ_TOKEN_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/token

ENTRYPOINT ["docker-entrypoint.sh", "medco-cli-client"]
26 changes: 26 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,43 @@ services:
ports:
- "1999"
environment:
- SERVER_HTTP_WRITE_TIMEOUT_SECONDS=600
- I2B2_HIVE_URL=http://i2b2:8080/i2b2/services
- I2B2_LOGIN_DOMAIN=i2b2medco
- I2B2_LOGIN_PROJECT=MedCo
- I2B2_LOGIN_USER=e2etest
- I2B2_LOGIN_PASSWORD=e2etest
- I2B2_WAIT_TIME_SECONDS=300
- LOG_LEVEL=5
- UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml
- UNLYNX_GROUP_FILE_IDX=0
- UNLYNX_TIMEOUT_SECONDS=300
- JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs
- OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master
- OIDC_CLIENT_ID=medco
- OIDC_JWT_USER_ID_CLAIM=preferred_username
- MEDCO_OBFUSCATION_MIN=5
volumes:
- ./configuration-profile:/medco-configuration

medco-cli-client:
image: medco/medco-cli-client:dev
build:
context: ../
dockerfile: deployment/client.Dockerfile
environment:
- LOG_LEVEL=5
- UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml
- UNLYNX_GROUP_FILE_IDX=0
- OIDC_CLIENT_ID=medco
- CLIENT_QUERY_TIMEOUT_SECONDS=660
- PICSURE2_API_HOST=localhost
- PICSURE2_API_BASE_PATH=/pic-sure-api-2/PICSURE
- PICSURE2_API_SCHEME=http
- PICSURE2_RESOURCES=MEDCO_testnetwork_0_a,MEDCO_testnetwork_1_b,MEDCO_testnetwork_2_c
- OIDC_REQ_TOKEN_URL=http://localhost/auth/realms/master/protocol/openid-connect/token
volumes:
- ~/MedCo/repositories/medco-deployment/configuration-profiles/dev-local-3nodes:/medco-configuration
network_mode: host
command: >-
todo: default e2e query command;
2 changes: 1 addition & 1 deletion deployment/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [[ `ls -1 /medco-configuration/srv*-certificate.crt 2>/dev/null | wc -l` != 0
update-ca-certificates
fi

exec medco-connector-server
exec $@
49 changes: 27 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
module github.com/lca1/medco-connector

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/go-openapi/analysis v0.18.0 // indirect
github.com/go-openapi/errors v0.18.0
github.com/go-openapi/jsonpointer v0.18.0 // indirect
github.com/go-openapi/jsonreference v0.18.0 // indirect
github.com/go-openapi/loads v0.18.0
github.com/go-openapi/runtime v0.18.0
github.com/go-openapi/spec v0.18.0
github.com/go-openapi/strfmt v0.18.0
github.com/go-openapi/swag v0.18.0
github.com/go-openapi/validate v0.18.0
github.com/google/uuid v1.1.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/go-openapi/analysis v0.19.0 // indirect
github.com/go-openapi/errors v0.19.0
github.com/go-openapi/jsonpointer v0.19.0 // indirect
github.com/go-openapi/jsonreference v0.19.0 // indirect
github.com/go-openapi/loads v0.19.0
github.com/go-openapi/runtime v0.19.0
github.com/go-openapi/spec v0.19.0
github.com/go-openapi/strfmt v0.19.0
github.com/go-openapi/swag v0.19.0
github.com/go-openapi/validate v0.19.0
github.com/jessevdk/go-flags v1.4.0
github.com/lca1/medco-unlynx v0.0.0-20190326092154-e12359adb567
github.com/lca1/unlynx v0.0.0-20190312131415-2e3533f65afe
github.com/lestrrat-go/jwx v0.0.0-20190415045601-bee008e7f2ee
github.com/lestrrat-go/pdebug v0.0.0-20180220043849-39f9a71bcabe // indirect
github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.4.0
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
go.dedis.ch/onet/v3 v3.0.0
golang.org/x/net v0.0.0-20190311183353-d8887717615a
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/lca1/medco-loader v0.2.1
github.com/lca1/medco-unlynx v0.2.1
github.com/lca1/unlynx v1.3.1
github.com/lestrrat-go/jwx v0.9.0
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect
github.com/pkg/errors v0.8.1
github.com/r0fls/gostats v0.0.0-20180711082619-e793b1fda35c
github.com/sirupsen/logrus v1.4.2
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/urfave/cli v1.20.0
go.dedis.ch/onet/v3 v3.0.14
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect
golang.org/x/net v0.0.0-20190606173856-1492cefac77f
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444 // indirect
)
Loading

0 comments on commit 064a470

Please sign in to comment.