From 65df4ff9b80ce68d0a9a2f2ca7b6ee7a90374364 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 15:21:55 +0100 Subject: [PATCH 1/7] changes to add an example --- .github/workflows/generate_docs.yaml | 6 ++-- .gitignore | 1 + examples/lineage/go.mod | 20 +++++++++++ examples/lineage/go.sum | 35 ++++++++++++++++++++ examples/lineage/main.go | 44 +++++++++++++++++++++++++ generate_docs.sh => generate.sh | 18 +++++++++- go.work | 3 ++ go.work.sum | 20 +++++++++++ protos/core/v1/entity.proto | 2 +- protos/core/v1/entity_type.proto | 2 +- protos/core/v1/platforms.proto | 2 +- protos/example/v1/example.proto | 2 ++ protos/example/v1/example_service.proto | 2 ++ protos/example/v2/example.proto | 2 ++ protos/example/v2/example_service.proto | 2 ++ protos/schemas/v1/lineage.proto | 2 +- protos/schemas/v1/lineage_service.proto | 2 +- 17 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 examples/lineage/go.mod create mode 100644 examples/lineage/go.sum create mode 100644 examples/lineage/main.go rename generate_docs.sh => generate.sh (57%) create mode 100644 go.work create mode 100644 go.work.sum diff --git a/.github/workflows/generate_docs.yaml b/.github/workflows/generate_docs.yaml index 3660977..2efaa42 100644 --- a/.github/workflows/generate_docs.yaml +++ b/.github/workflows/generate_docs.yaml @@ -5,7 +5,7 @@ on: - main paths: - 'protos/**' - - 'generate_docs.sh' + - 'generate.sh' - '.github/workflows/generate_docs.yaml' workflow_dispatch: @@ -21,7 +21,7 @@ jobs: if: '!contains(github.event.commits[0].message, ''ci skip'')' runs-on: ubuntu-latest env: - CI_COMMIT_MESSAGE: CI generated docs + CI_COMMIT_MESSAGE: Generated API Docs CI_COMMIT_AUTHOR_NAME: Synqlair CI_COMMIT_AUTHOR_EMAIL: ci@synq.io steps: @@ -42,7 +42,7 @@ jobs: go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest - name: Generate and push run: | - bash generate_docs.sh + bash generate.sh git config --global user.name "${{ env.CI_COMMIT_AUTHOR_NAME }}" git config --global user.email "${{ env.CI_COMMIT_AUTHOR_EMAIL }}" git add docs diff --git a/.gitignore b/.gitignore index 722d5e7..6860b5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +gen diff --git a/examples/lineage/go.mod b/examples/lineage/go.mod new file mode 100644 index 0000000..48500e0 --- /dev/null +++ b/examples/lineage/go.mod @@ -0,0 +1,20 @@ +module lineage + +go 1.21.1 + +replace github.com/getsynq/api => ../../gen/ + +require ( + github.com/getsynq/api v0.0.0-20240118130644-9d44c1f0e96d + github.com/sirupsen/logrus v1.9.3 +) + +require ( + github.com/golang/protobuf v1.5.3 // indirect + golang.org/x/net v0.16.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.60.1 // indirect + google.golang.org/protobuf v1.32.0 // indirect +) diff --git a/examples/lineage/go.sum b/examples/lineage/go.sum new file mode 100644 index 0000000..d0d6f1a --- /dev/null +++ b/examples/lineage/go.sum @@ -0,0 +1,35 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= +golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/lineage/main.go b/examples/lineage/main.go new file mode 100644 index 0000000..1ac46f3 --- /dev/null +++ b/examples/lineage/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "context" + "fmt" + "log" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + corev1 "github.com/getsynq/api/core/v1" + schemasv1 "github.com/getsynq/api/schemas/v1" +) + +func main() { + // TODO: add connection mechanism here + conn, err := grpc.Dial("localhost:8080", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal("could not connect to server") + } + + client := schemasv1.NewLineageServiceClient(conn) + + // Add example. + resp, err := client.GetLineage(context.Background(), &schemasv1.GetLineageRequest{ + StartPoint: &schemasv1.GetLineageStartPoint{ + From: &schemasv1.GetLineageStartPoint_Entities{ + Entities: &schemasv1.EntitiesStartPoint{ + Entities: []*corev1.EntityRef{ + { + Path: "asset_path1", + Type: corev1.EntityType_ENTITY_TYPE_DBT_MODEL, + }, + }, + }, + }, + }, + }) + if err != nil { + log.Fatalf("error fetching lineage -> %v", err) + } + + fmt.Printf("Lineage -> %+v", resp.Lineage) +} diff --git a/generate_docs.sh b/generate.sh similarity index 57% rename from generate_docs.sh rename to generate.sh index aae42c4..e7347ea 100644 --- a/generate_docs.sh +++ b/generate.sh @@ -2,6 +2,7 @@ PROTOS_DIR="protos" DOCS_DIR="docs" +GEN_DIR="gen" # Expected structure of protos dir for document generation. # @@ -15,6 +16,10 @@ set -e rm -rf $DOCS_DIR mkdir -p $DOCS_DIR +rm -rf $GEN_DIR +mkdir -p $GEN_DIR + +PREFIX="github.com/getsynq/api" entity_dirs=`find $PROTOS_DIR -maxdepth 1 -mindepth 1 -type d` for entity_dir in $entity_dirs; do entity=`basename $entity_dir` @@ -22,9 +27,20 @@ for entity_dir in $entity_dirs; do for version_dir in $version_dirs; do version=`basename $version_dir` proto_files=`find $version_dir -name *.proto -type f` - protoc --proto_path=${PROTOS_DIR} --doc_out=${DOCS_DIR} --doc_opt=markdown,${entity}_${version}.md ${proto_files} + protoc --proto_path=${PROTOS_DIR} \ + --doc_out=${DOCS_DIR} \ + --doc_opt=markdown,${entity}_${version}.md \ + --go_out=${GEN_DIR} \ + --go_opt=module=${PREFIX} \ + --go-grpc_out=${GEN_DIR} \ + --go-grpc_opt=module=${PREFIX} \ + ${proto_files} done done +cd $GEN_DIR +go mod init $PREFIX +go mod tidy + set +e exit 0 diff --git a/go.work b/go.work new file mode 100644 index 0000000..565b021 --- /dev/null +++ b/go.work @@ -0,0 +1,3 @@ +go 1.21.1 + +use ./examples/lineage diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..61d2ece --- /dev/null +++ b/go.work.sum @@ -0,0 +1,20 @@ +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/envoyproxy/go-control-plane v0.11.1/go.mod h1:uhMcXKCQMEJHiAb0w+YGefQLaTEw+YhGluxZkrTmD0g= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/protos/core/v1/entity.proto b/protos/core/v1/entity.proto index 9c40b59..2d0a4ee 100644 --- a/protos/core/v1/entity.proto +++ b/protos/core/v1/entity.proto @@ -5,7 +5,7 @@ package core.v1; import "core/v1/entity_type.proto"; import "core/v1/platforms.proto"; -option go_package = "github.com/getsynq/cloud/api/core/v1"; +option go_package = "github.com/getsynq/api/core/v1"; // Lightweight reference to an Entity message EntityRef { diff --git a/protos/core/v1/entity_type.proto b/protos/core/v1/entity_type.proto index 7535f1e..041d24d 100644 --- a/protos/core/v1/entity_type.proto +++ b/protos/core/v1/entity_type.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package core.v1; -option go_package = "github.com/getsynq/cloud/api/core/v1"; +option go_package = "github.com/getsynq/api/core/v1"; // Type of Entity. // This enum lists all the types currently supported by Synq. diff --git a/protos/core/v1/platforms.proto b/protos/core/v1/platforms.proto index ca9a395..31c97e0 100644 --- a/protos/core/v1/platforms.proto +++ b/protos/core/v1/platforms.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package core.v1; -option go_package = "github.com/getsynq/cloud/api/core/v1"; +option go_package = "github.com/getsynq/api/core/v1"; // Platforms supported by Synq. enum Platform { diff --git a/protos/example/v1/example.proto b/protos/example/v1/example.proto index 51e77a8..1364cc5 100644 --- a/protos/example/v1/example.proto +++ b/protos/example/v1/example.proto @@ -4,6 +4,8 @@ package example.v1; import "google/protobuf/timestamp.proto"; +option go_package = "github.com/getsynq/api/example/v1"; + /** * Example is the core model of this package. diff --git a/protos/example/v1/example_service.proto b/protos/example/v1/example_service.proto index eb1f476..1a53505 100644 --- a/protos/example/v1/example_service.proto +++ b/protos/example/v1/example_service.proto @@ -4,6 +4,8 @@ package example.v1; import "example/v1/example.proto"; +option go_package = "github.com/getsynq/api/example/v1"; + // ExamplesService is a sample service to display how documentation in protos will work. // The service implements a basic CRUD API and contains server streaming example. diff --git a/protos/example/v2/example.proto b/protos/example/v2/example.proto index b0cb73e..9cd22f5 100644 --- a/protos/example/v2/example.proto +++ b/protos/example/v2/example.proto @@ -4,6 +4,8 @@ package example.v2; import "google/protobuf/timestamp.proto"; +option go_package = "github.com/getsynq/api/example/v2"; + /** * Example is the core model of this package. diff --git a/protos/example/v2/example_service.proto b/protos/example/v2/example_service.proto index 27125ca..7766ffb 100644 --- a/protos/example/v2/example_service.proto +++ b/protos/example/v2/example_service.proto @@ -4,6 +4,8 @@ package example.v2; import "example/v2/example.proto"; +option go_package = "github.com/getsynq/api/example/v2"; + // ExamplesService is a sample service to display how documentation in protos will work. // The service implements a basic CRUD API and contains server streaming example. diff --git a/protos/schemas/v1/lineage.proto b/protos/schemas/v1/lineage.proto index 2f64ac8..b6c0cfd 100644 --- a/protos/schemas/v1/lineage.proto +++ b/protos/schemas/v1/lineage.proto @@ -4,7 +4,7 @@ package schemas.v1; import "core/v1/entity.proto"; -option go_package = "github.com/getsynq/cloud/api/schemas/v1"; +option go_package = "github.com/getsynq/api/schemas/v1"; // Lineage defines the lineage of table-like entities. message Lineage { diff --git a/protos/schemas/v1/lineage_service.proto b/protos/schemas/v1/lineage_service.proto index b51fd2c..4a8b516 100644 --- a/protos/schemas/v1/lineage_service.proto +++ b/protos/schemas/v1/lineage_service.proto @@ -4,7 +4,7 @@ package schemas.v1; import "schemas/v1/lineage.proto"; -option go_package = "github.com/getsynq/cloud/api/schemas/v1"; +option go_package = "github.com/getsynq/api/schemas/v1"; import "core/v1/entity.proto"; From c9a07888474cd0465bce047cd8cd931c74950302 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 18:57:36 +0100 Subject: [PATCH 2/7] working example --- .github/workflows/generate_docs.yaml | 2 +- examples/lineage/go.mod | 7 ++- examples/lineage/go.sum | 47 +++++++++++----- examples/lineage/main.go | 82 ++++++++++++++++++++++++++-- generate.sh => generate_docs.sh | 6 -- go.work.sum | 12 ++-- 6 files changed, 124 insertions(+), 32 deletions(-) rename generate.sh => generate_docs.sh (87%) diff --git a/.github/workflows/generate_docs.yaml b/.github/workflows/generate_docs.yaml index 2efaa42..5eca4ec 100644 --- a/.github/workflows/generate_docs.yaml +++ b/.github/workflows/generate_docs.yaml @@ -42,7 +42,7 @@ jobs: go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest - name: Generate and push run: | - bash generate.sh + bash generate_docs.sh git config --global user.name "${{ env.CI_COMMIT_AUTHOR_NAME }}" git config --global user.email "${{ env.CI_COMMIT_AUTHOR_EMAIL }}" git add docs diff --git a/examples/lineage/go.mod b/examples/lineage/go.mod index 48500e0..8908e33 100644 --- a/examples/lineage/go.mod +++ b/examples/lineage/go.mod @@ -6,15 +6,18 @@ replace github.com/getsynq/api => ../../gen/ require ( github.com/getsynq/api v0.0.0-20240118130644-9d44c1f0e96d - github.com/sirupsen/logrus v1.9.3 + golang.org/x/oauth2 v0.13.0 + google.golang.org/grpc v1.60.1 ) require ( + cloud.google.com/go/compute v1.23.0 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/golang/protobuf v1.5.3 // indirect golang.org/x/net v0.16.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/grpc v1.60.1 // indirect google.golang.org/protobuf v1.32.0 // indirect ) diff --git a/examples/lineage/go.sum b/examples/lineage/go.sum index d0d6f1a..464d62a 100644 --- a/examples/lineage/go.sum +++ b/examples/lineage/go.sum @@ -1,27 +1,49 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= +golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= @@ -30,6 +52,3 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/lineage/main.go b/examples/lineage/main.go index 1ac46f3..afba45a 100644 --- a/examples/lineage/main.go +++ b/examples/lineage/main.go @@ -2,8 +2,13 @@ package main import ( "context" + "encoding/json" "fmt" "log" + "net/http" + "net/url" + "os" + "strings" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -12,16 +17,45 @@ import ( schemasv1 "github.com/getsynq/api/schemas/v1" ) +// Bearer authentication +type bearerAuth struct { + token string +} + +// Convert user credentials to request metadata. +func (b bearerAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) { + return map[string]string{ + "authorization": "Bearer " + b.token, + }, nil +} + +// Specify whether channel security is required to pass these credentials. +func (b bearerAuth) RequireTransportSecurity() bool { + return false +} + func main() { - // TODO: add connection mechanism here - conn, err := grpc.Dial("localhost:8080", grpc.WithTransportCredentials(insecure.NewCredentials())) + // Configure credentials. + token, err := getToken() if err != nil { - log.Fatal("could not connect to server") + panic(err) + } + fmt.Println(token) + opts := []grpc.DialOption{ + grpc.WithPerRPCCredentials(bearerAuth{ + token: token, + }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + } + + conn, err := grpc.Dial("localhost:8000", opts...) + if err != nil { + log.Fatalf("could not connect to server -> %+v", err) } client := schemasv1.NewLineageServiceClient(conn) - // Add example. + // Fetch lineage. resp, err := client.GetLineage(context.Background(), &schemasv1.GetLineageRequest{ StartPoint: &schemasv1.GetLineageStartPoint{ From: &schemasv1.GetLineageStartPoint_Entities{ @@ -29,7 +63,7 @@ func main() { Entities: []*corev1.EntityRef{ { Path: "asset_path1", - Type: corev1.EntityType_ENTITY_TYPE_DBT_MODEL, + Type: corev1.EntityType_ENTITY_TYPE_UNSPECIFIED, }, }, }, @@ -42,3 +76,41 @@ func main() { fmt.Printf("Lineage -> %+v", resp.Lineage) } + +func getToken() (string, error) { + type oauth2Token struct { + AccessToken string `json:"access_token"` + } + + tokenUrl := "http://localhost:8000/oauth2/token" + clientID := os.Getenv("SYNQ_CLIENT_ID") + clientSecret := os.Getenv("SYNQ_CLIENT_SECRET") + + v := &url.Values{} + v.Set("client_id", clientID) + v.Set("client_secret", clientSecret) + v.Set("grant_type", "client_credentials") + + req, err := http.NewRequest("POST", tokenUrl, strings.NewReader(v.Encode())) + if err != nil { + return "", err + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + client := &http.Client{} + res, err := client.Do(req) + if err != nil { + return "", err + } + defer res.Body.Close() + + token := &oauth2Token{} + if err := json.NewDecoder(res.Body).Decode(token); err != nil { + return "", err + } + if res.StatusCode != http.StatusOK { + return "", fmt.Errorf("error fetching token. status code %d", res.StatusCode) + } + + return token.AccessToken, nil +} diff --git a/generate.sh b/generate_docs.sh similarity index 87% rename from generate.sh rename to generate_docs.sh index e7347ea..ddc15b4 100644 --- a/generate.sh +++ b/generate_docs.sh @@ -2,7 +2,6 @@ PROTOS_DIR="protos" DOCS_DIR="docs" -GEN_DIR="gen" # Expected structure of protos dir for document generation. # @@ -16,8 +15,6 @@ set -e rm -rf $DOCS_DIR mkdir -p $DOCS_DIR -rm -rf $GEN_DIR -mkdir -p $GEN_DIR PREFIX="github.com/getsynq/api" entity_dirs=`find $PROTOS_DIR -maxdepth 1 -mindepth 1 -type d` @@ -30,15 +27,12 @@ for entity_dir in $entity_dirs; do protoc --proto_path=${PROTOS_DIR} \ --doc_out=${DOCS_DIR} \ --doc_opt=markdown,${entity}_${version}.md \ - --go_out=${GEN_DIR} \ --go_opt=module=${PREFIX} \ - --go-grpc_out=${GEN_DIR} \ --go-grpc_opt=module=${PREFIX} \ ${proto_files} done done -cd $GEN_DIR go mod init $PREFIX go mod tidy diff --git a/go.work.sum b/go.work.sum index 61d2ece..ffa16b9 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,19 +1,23 @@ -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA= +cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/envoyproxy/go-control-plane v0.11.1/go.mod h1:uhMcXKCQMEJHiAb0w+YGefQLaTEw+YhGluxZkrTmD0g= github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= From 78cf73f7100bc41a44af03befc054783a877130f Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 19:00:32 +0100 Subject: [PATCH 3/7] removing go mod files --- examples/lineage/go.mod | 23 ------------------ examples/lineage/go.sum | 54 ----------------------------------------- 2 files changed, 77 deletions(-) delete mode 100644 examples/lineage/go.mod delete mode 100644 examples/lineage/go.sum diff --git a/examples/lineage/go.mod b/examples/lineage/go.mod deleted file mode 100644 index 8908e33..0000000 --- a/examples/lineage/go.mod +++ /dev/null @@ -1,23 +0,0 @@ -module lineage - -go 1.21.1 - -replace github.com/getsynq/api => ../../gen/ - -require ( - github.com/getsynq/api v0.0.0-20240118130644-9d44c1f0e96d - golang.org/x/oauth2 v0.13.0 - google.golang.org/grpc v1.60.1 -) - -require ( - cloud.google.com/go/compute v1.23.0 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect - github.com/golang/protobuf v1.5.3 // indirect - golang.org/x/net v0.16.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/protobuf v1.32.0 // indirect -) diff --git a/examples/lineage/go.sum b/examples/lineage/go.sum deleted file mode 100644 index 464d62a..0000000 --- a/examples/lineage/go.sum +++ /dev/null @@ -1,54 +0,0 @@ -cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= From 379497eaa7c8fc5cef1ac7ccba826f56506d11a4 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 19:04:02 +0100 Subject: [PATCH 4/7] apiurl cleanup --- examples/lineage/main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/lineage/main.go b/examples/lineage/main.go index afba45a..188b05e 100644 --- a/examples/lineage/main.go +++ b/examples/lineage/main.go @@ -17,6 +17,12 @@ import ( schemasv1 "github.com/getsynq/api/schemas/v1" ) +const ( + apiUrl = "https://api.synq.io/" + clientId = os.Getenv("SYNQ_CLIENT_ID") + clientSecret = os.Getenv("SYNQ_CLIENT_SECRET") +) + // Bearer authentication type bearerAuth struct { token string @@ -48,7 +54,7 @@ func main() { grpc.WithTransportCredentials(insecure.NewCredentials()), } - conn, err := grpc.Dial("localhost:8000", opts...) + conn, err := grpc.Dial(apiUrl, opts...) if err != nil { log.Fatalf("could not connect to server -> %+v", err) } @@ -82,16 +88,12 @@ func getToken() (string, error) { AccessToken string `json:"access_token"` } - tokenUrl := "http://localhost:8000/oauth2/token" - clientID := os.Getenv("SYNQ_CLIENT_ID") - clientSecret := os.Getenv("SYNQ_CLIENT_SECRET") - v := &url.Values{} v.Set("client_id", clientID) v.Set("client_secret", clientSecret) v.Set("grant_type", "client_credentials") - req, err := http.NewRequest("POST", tokenUrl, strings.NewReader(v.Encode())) + req, err := http.NewRequest("POST", fmt.Sprintf("%soauth2/token", apiUrl), strings.NewReader(v.Encode())) if err != nil { return "", err } From 79683c5172eaddf333ae70db046f2f956c0de218 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 19:05:13 +0100 Subject: [PATCH 5/7] entity path cleanup --- examples/lineage/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/lineage/main.go b/examples/lineage/main.go index 188b05e..a96f5d8 100644 --- a/examples/lineage/main.go +++ b/examples/lineage/main.go @@ -68,8 +68,8 @@ func main() { Entities: &schemasv1.EntitiesStartPoint{ Entities: []*corev1.EntityRef{ { - Path: "asset_path1", - Type: corev1.EntityType_ENTITY_TYPE_UNSPECIFIED, + Path: "xxxxxxxxxxxxxxxxxxxxx", // replace with entity path + Type: corev1.EntityType_ENTITY_TYPE_UNSPECIFIED, // replace with entity type }, }, }, From b80715c9de159e2c3c5f0cc79c38878d02b0bf60 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 19:06:14 +0100 Subject: [PATCH 6/7] cleanup --- .github/workflows/generate_docs.yaml | 2 +- go.work | 3 --- go.work.sum | 24 ------------------------ 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 go.work delete mode 100644 go.work.sum diff --git a/.github/workflows/generate_docs.yaml b/.github/workflows/generate_docs.yaml index 5eca4ec..aa41e26 100644 --- a/.github/workflows/generate_docs.yaml +++ b/.github/workflows/generate_docs.yaml @@ -5,7 +5,7 @@ on: - main paths: - 'protos/**' - - 'generate.sh' + - 'generate_docs.sh' - '.github/workflows/generate_docs.yaml' workflow_dispatch: diff --git a/go.work b/go.work deleted file mode 100644 index 565b021..0000000 --- a/go.work +++ /dev/null @@ -1,3 +0,0 @@ -go 1.21.1 - -use ./examples/lineage diff --git a/go.work.sum b/go.work.sum deleted file mode 100644 index ffa16b9..0000000 --- a/go.work.sum +++ /dev/null @@ -1,24 +0,0 @@ -cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA= -cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= -github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/envoyproxy/go-control-plane v0.11.1/go.mod h1:uhMcXKCQMEJHiAb0w+YGefQLaTEw+YhGluxZkrTmD0g= -github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From eb2e0c9258e1735e357c261b6756e1c94be8dc27 Mon Sep 17 00:00:00 2001 From: grasskode Date: Thu, 18 Jan 2024 19:07:06 +0100 Subject: [PATCH 7/7] cleanup --- generate_docs.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/generate_docs.sh b/generate_docs.sh index ddc15b4..2617a22 100644 --- a/generate_docs.sh +++ b/generate_docs.sh @@ -16,7 +16,6 @@ rm -rf $DOCS_DIR mkdir -p $DOCS_DIR -PREFIX="github.com/getsynq/api" entity_dirs=`find $PROTOS_DIR -maxdepth 1 -mindepth 1 -type d` for entity_dir in $entity_dirs; do entity=`basename $entity_dir` @@ -27,14 +26,9 @@ for entity_dir in $entity_dirs; do protoc --proto_path=${PROTOS_DIR} \ --doc_out=${DOCS_DIR} \ --doc_opt=markdown,${entity}_${version}.md \ - --go_opt=module=${PREFIX} \ - --go-grpc_opt=module=${PREFIX} \ ${proto_files} done done -go mod init $PREFIX -go mod tidy - set +e exit 0