Skip to content

Commit

Permalink
Move to new SDK generators (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Jan 13, 2020
1 parent 85d838c commit 4f51a09
Show file tree
Hide file tree
Showing 517 changed files with 984 additions and 47,082 deletions.
66 changes: 21 additions & 45 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
version: 2.1

orbs:
changelog: ory/[email protected]
sdk: ory/[email protected]

jobs:
format:
docker:
- image: circleci/golang:1.11
- image: circleci/golang:1.13
working_directory: /go/src/github.com/ory/keto
steps:
- checkout
Expand All @@ -18,22 +20,9 @@ jobs:
- run: go mod download
- run: golangci-lint run ./...

release-npm:
docker:
- image: circleci/node:8.9.3
working_directory: ~/hydra
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run: |
npm version -f --no-git-tag-version $CIRCLE_TAG
- run: npm view ory-hydra-sdk
- run: npm whoami
- run: npm publish

test:
docker:
- image: circleci/golang:1.11
- image: circleci/golang:1.13
environment:
- TEST_DATABASE_POSTGRESQL=postgres://test:test@localhost:5432/keto?sslmode=disable
- TEST_DATABASE_MYSQL=root:test@(localhost:3306)/mysql?parseTime=true
Expand Down Expand Up @@ -101,26 +90,6 @@ jobs:
- run: "cp configuration.md ../docs/docs/keto/configuration.md"
- run: "(cd ../docs && git add -A && git commit -a -m \"Updates ORY Keto Swagger and config definitions\" && git push origin) || exit 0"

release-changelog:
docker:
- image: circleci/ruby:2.4-node
steps:
- checkout
- run: gem install github_changelog_generator
- run: sudo npm i -g doctoc
- run: github_changelog_generator -u ory -p keto -o CHANGELOG.md --token $GITHUB_TOKEN
- run: doctoc CHANGELOG.md
- run: doctoc README.md
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "ORY Continuous Integration"
- run: git add CHANGELOG.md
- run: git add README.md
- run: |
git commit -a -m "docs: Incorporates changes from version $(git describe --tags)" || true
- run: git remote rm origin
- run: git remote add origin https://arekkas:[email protected]/ory/keto.git
- run: git push origin HEAD:master || true

workflows:
version: 2
"test, build, and relase":
Expand All @@ -146,20 +115,27 @@ workflows:
filters:
branches:
only: master
- release-npm:
- changelog/generate:
requires:
- release
- test
- format
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- release-changelog:
only: master
- sdk/generate:
appname: Ory_Keto
requires:
- test
- format
- sdk/release:
requires:
- test
- format
- release
- release-npm
filters:
tags:
only: /.*/
branches:
ignore: /.*/
ignore: /.*/
42 changes: 12 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
.PHONY: format
format:
goreturns -w -local github.com/ory $$(listx .)
# goimports -w -v -local github.com/ory $$(listx .)

.PHONY: swagger
swagger:
swagger generate spec -m -o ./docs/api.swagger.json

.PHONY: sdk
sdk:
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
GO111MODULE=off swagger generate spec -m -o ./docs/api.swagger.json
GO111MODULE=off swagger validate ./docs/api.swagger.json

rm -rf ./sdk/go/keto/*
rm -rf ./sdk/js/swagger
rm -rf ./sdk/php/swagger

GO111MODULE=off swagger generate client -f ./docs/api.swagger.json -t sdk/go/keto -A Ory_Keto

java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l javascript -o ./sdk/js/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l php -o ./sdk/php/ \
--invoker-package keto\\SDK --git-repo-id swagger --git-user-id ory --additional-properties "packagePath=swagger,description=Client for keto"

make format

rm -f ./sdk/js/swagger/package.json
rm -rf ./sdk/js/swagger/test
rm -f ./sdk/php/swagger/composer.json ./sdk/php/swagger/phpunit.xml.dist
rm -rf ./sdk/php/swagger/test
rm -rf ./vendor

.PHONY: install-stable
install-stable:
Expand All @@ -48,3 +18,15 @@ install:
$(go env GOPATH)/bin/packr
GO111MODULE=on go install .
$(go env GOPATH)/bin/packr clean

# Generates the SDKs
.PHONY: sdk
sdk:
$$(go env GOPATH)/bin/swagger generate spec -m -o ./docs/api.swagger.json -x internal/httpclient
$$(go env GOPATH)/bin/swagutil sanitize ./docs/api.swagger.json
$$(go env GOPATH)/bin/swagger flatten --with-flatten=remove-unused -o ./docs/api.swagger.json ./docs/api.swagger.json
$$(go env GOPATH)/bin/swagger validate ./docs/api.swagger.json
rm -rf internal/httpclient
mkdir -p internal/httpclient
$$(go env GOPATH)/bin/swagger generate client -f ./docs/api.swagger.json -t internal/httpclient -A Ory_Keto
make format
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<a href="https://discord.gg/PAMQWkr">Chat</a> |
<a href="https://community.ory.am/">Forums</a> |
<a href="http://eepurl.com/di390P">Newsletter</a><br/><br/>
<a href="https://www.ory.sh/docs/next/keto/">Guide</a> |
<a href="https://www.ory.sh/docs/next/keto/sdk/api">API Docs</a> |
<a href="https://www.ory.sh/docs/keto/">Guide</a> |
<a href="https://www.ory.sh/docs/keto/sdk/api">API Docs</a> |
<a href="https://godoc.org/github.com/ory/keto">Code Docs</a><br/><br/>
<a href="https://opencollective.com/ory">Support this project!</a>
</h4>
Expand Down
60 changes: 45 additions & 15 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,54 @@ before finalizing the upgrade process.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Upgrading](#upgrading)
- [0.2.0-sandbox](#020-sandbox)
- [Conceptual changes](#conceptual-changes)
- [Deprecated](#deprecated)
- [Changes](#changes)
- [Additions](#additions)
- [Untouched](#untouched)
- [API Changes](#api-changes)
- [Renamed Endpoints](#renamed-endpoints)
- [Reworked Endpoints](#reworked-endpoints)
- [New Endpoints](#new-endpoints)
- [Migration](#migration)
- [SQL](#sql)
- [0.0.1](#001)
- [CORS is disabled by default](#cors-is-disabled-by-default)

- [0.4.0](#040)
- [0.3.0-sandbox](#030-sandbox)
- [Configuration](#configuration)
- [ORY Access Control Policies Allowed Endpoint](#ory-access-control-policies-allowed-endpoint)
- [SDK](#sdk)
- [0.2.0-sandbox](#020-sandbox)
- [Conceptual changes](#conceptual-changes)
- [Deprecated](#deprecated)
- [Changes](#changes)
- [Additions](#additions)
- [Untouched](#untouched)
- [API Changes](#api-changes)
- [Renamed Endpoints](#renamed-endpoints)
- [Reworked Endpoints](#reworked-endpoints)
- [New Endpoints](#new-endpoints)
- [Migration](#migration)
- [SQL](#sql)
- [0.0.1](#001)
- [CORS is disabled by default](#cors-is-disabled-by-default)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 0.4.0-sandbox

This release focuses on a rework of the SDK pipeline. First of all, we have introduced new SDKs for all popular programming
languages and published them on their respective package repositories:

- [Python](https://pypi.org/project/ory-keto-client/)
- [PHP](https://packagist.org/packages/ory/keto-client)
- [Go](https://github.com/ory/keto-client-go)
- [NodeJS](https://www.npmjs.com/package/@oryd/keto-client) (with TypeScript)
- [Java](https://search.maven.org/artifact/sh.ory.keto/keto-client)
- [Ruby](https://rubygems.org/gems/ory-keto-client)

The SDKs hosted in this repository (under ./sdk/...) have been completely removed. Please use only the SDKs from the
above sources from now on as it will also remove several issues that were caused by the previous SDK pipeline.

Unfortunately, there were breaking changes introduced by the new SDK generation:

- Several structs and fields have been renamed in the Go SDK. However, nothing else changed so upgrading should be a matter of
half an hour if you made extensive use of the SDK, or several minutes if just one or two methods are being used.
- All other SDKs changed to `openapi-generator`, which is a better maintained generator that creates
better code than the one previously used. This manifests in TypeScript definitions for the NodeJS SDK and
several other goodies. We do not have a proper migration path for those, unfortunately.

If you have issues with upgrading the SDK, please let us know in an issue on this repository!

## 0.3.0-sandbox

### Configuration
Expand Down
5 changes: 3 additions & 2 deletions cmd/client/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"path/filepath"
"strings"

"github.com/ory/keto/sdk/go/keto/client"
"github.com/ory/keto/internal/httpclient/client"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/ory/viper"

"github.com/ory/keto/engine/ladon"
"github.com/ory/x/cmdx"
Expand Down
4 changes: 2 additions & 2 deletions cmd/engines_acp_ory_allowed.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package cmd
import (
"fmt"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/sdk/go/keto/models"
"github.com/ory/keto/internal/httpclient/client/engines"
"github.com/ory/keto/internal/httpclient/models"

"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_policies_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package cmd

import (
"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_policies_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd
import (
"fmt"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/spf13/cobra"

Expand Down
4 changes: 2 additions & 2 deletions cmd/engines_acp_ory_policies_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package cmd

import (
"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/sdk/go/keto/models"
"github.com/ory/keto/internal/httpclient/client/engines"
"github.com/ory/keto/internal/httpclient/models"

"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_policies_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd
import (
"fmt"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_roles_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd
import (
"github.com/spf13/cobra"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/ory/keto/cmd/client"
"github.com/ory/x/cmdx"
Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_roles_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd
import (
"fmt"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/spf13/cobra"

Expand Down
4 changes: 2 additions & 2 deletions cmd/engines_acp_ory_roles_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package cmd

import (
"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/sdk/go/keto/models"
"github.com/ory/keto/internal/httpclient/client/engines"
"github.com/ory/keto/internal/httpclient/models"

"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cmd/engines_acp_ory_roles_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd
import (
"fmt"

"github.com/ory/keto/sdk/go/keto/client/engines"
"github.com/ory/keto/internal/httpclient/client/engines"

"github.com/spf13/cobra"

Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/ory/viper"

"github.com/ory/x/logrusx"
)
Expand Down
3 changes: 3 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ import (
"time"

"github.com/stretchr/testify/assert"

"github.com/ory/viper"
)

func TestExecute(t *testing.T) {
viper.Set("dsn", "memory")
ep := fmt.Sprintf("http://127.0.0.1:%d", port)

for _, c := range []struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ on configuration options, open the configuration documentation:
func init() {
RootCmd.AddCommand(serveCmd)

disableTelemetryEnv := viperx.GetBool(logrusx.New(), "sqa.opt_out", "DISABLE_TELEMETRY")
disableTelemetryEnv := viperx.GetBool(logrusx.New(), "sqa.opt_out", false, "DISABLE_TELEMETRY")
serveCmd.PersistentFlags().Bool("disable-telemetry", disableTelemetryEnv, "Disable anonymized telemetry reports - for more information please visit https://www.ory.sh/docs/ecosystem/sqa")
serveCmd.PersistentFlags().Bool("sqa-opt-out", disableTelemetryEnv, "Disable anonymized telemetry reports - for more information please visit https://www.ory.sh/docs/ecosystem/sqa")
}
1 change: 0 additions & 1 deletion cmd/server/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion cmd/server/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/urfave/negroni"

"github.com/ory/viper"

"github.com/ory/graceful"
"github.com/ory/keto/engine/ladon"
"github.com/ory/x/stringslice"
Expand Down
2 changes: 2 additions & 0 deletions cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ import (
_ "github.com/gobuffalo/packr/packr"
_ "github.com/sqs/goreturns"

_ "github.com/ory/sdk/swagutil"

_ "github.com/ory/x/tools/listx"
)
Loading

0 comments on commit 4f51a09

Please sign in to comment.