From 6dbfb09f4b7c4ae7c32026f5111bc1912919f14f Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Wed, 4 Sep 2019 10:33:03 +0200 Subject: [PATCH] Add initial project structure With this commit I have prepared a full basic project structure, so far it doesn't embed phoenix itself and also no kit parts. It includes the whole Drone pipeline to continously publish binaries on push and on tag to our download mirrors (will be available at https://download.owncloud.com/reva/phoenix) and also publishes Docker images at owncloud/reva-phonix. For the Docker image auto_tag is enabled, which means latest is always based on the master branch and tags are automatically converted to minor, major and patch release tags. --- .dockerignore | 3 + .drone.starlark | 424 ++++++++++++++++++++++ .drone.yml | 643 ++++++++++++++++++++++++++++++++++ .editorconfig | 27 ++ .gitignore | 24 +- CHANGELOG.md | 1 + LICENSE | 202 +++++++++++ Makefile | 123 +++++++ README.md | 68 ++-- cmd/reva-hyper/main.go | 13 + config/.gitignore | 1 + config/example.yml | 0 docker/Dockerfile.linux.amd64 | 16 + docker/Dockerfile.linux.arm | 16 + docker/Dockerfile.linux.arm64 | 16 + docker/manifest.tmpl | 22 ++ go.mod | 5 +- go.sum | 139 +++++++- main.go | 64 ---- pkg/command/command.go | 102 ++++++ pkg/command/health.go | 27 ++ pkg/command/phoenix.go | 15 + pkg/version/version.go | 9 + 23 files changed, 1844 insertions(+), 116 deletions(-) create mode 100644 .dockerignore create mode 100644 .drone.starlark create mode 100644 .drone.yml create mode 100644 .editorconfig create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 cmd/reva-hyper/main.go create mode 100644 config/.gitignore create mode 100644 config/example.yml create mode 100644 docker/Dockerfile.linux.amd64 create mode 100644 docker/Dockerfile.linux.arm create mode 100644 docker/Dockerfile.linux.arm64 create mode 100644 docker/manifest.tmpl delete mode 100644 main.go create mode 100644 pkg/command/command.go create mode 100644 pkg/command/health.go create mode 100644 pkg/command/phoenix.go create mode 100644 pkg/version/version.go diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..26258eb1549 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!dist/ +!bin/ diff --git a/.drone.starlark b/.drone.starlark new file mode 100644 index 00000000000..15df8f61b66 --- /dev/null +++ b/.drone.starlark @@ -0,0 +1,424 @@ +def main(ctx): + before = testing() + + stages = [ + docker('amd64'), + docker('arm64'), + docker('arm'), + binary('linux'), + binary('darwin'), + binary('windows'), + ] + + after = manifest() + + for b in before: + for s in stages: + s['depends_on'].append(b['name']) + + for s in stages: + for a in after: + a['depends_on'].append(s['name']) + + return before + stages + after + +def testing(): + return [{ + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'testing', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make generate' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'vet', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make vet' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'staticcheck', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make staticcheck' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'lint', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make lint' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make build' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'test', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make test' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'codacy', + 'image': 'plugins/codacy:1', + 'pull': 'always', + 'settings': { + 'token': { + 'from_secret': 'codacy_token' + } + } + } + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {} + } + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**' + ] + } + }] + +def docker(arch): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': arch, + 'platform': { + 'os': 'linux', + 'arch': arch, + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make generate' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make build' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'dryrun', + 'image': 'plugins/docker:18.09', + 'pull': 'always', + 'settings': { + 'dry_run': True, + 'tags': 'linux-%s' % arch, + 'auto_tag_suffix': 'linux-%s' % arch, + 'dockerfile': 'docker/Dockerfile.linux.%s' % arch, + 'repo': 'owncloud/reva-hyper', + }, + 'when': { + 'event': [ + 'pull_request' + ] + } + }, + { + 'name': 'docker', + 'image': 'plugins/docker:18.09', + 'pull': 'always', + 'settings': { + 'username': { + 'from_secret': 'docker_username' + }, + 'password': { + 'from_secret': 'docker_password' + }, + 'auto_tag': True, + 'auto_tag_suffix': 'linux-%s' % arch, + 'dockerfile': 'docker/Dockerfile.linux.%s' % arch, + 'repo': 'owncloud/reva-hyper', + }, + 'when': { + 'event': { + 'exclude': [ + 'pull_request' + ] + } + } + }, + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {} + } + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**' + ] + } + } + +def binary(name): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': name, + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make generate' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make release-%s' % name + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'finish', + 'image': 'webhippie/golang:1.12', + 'pull': 'always', + 'commands': [ + 'make release-finish' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app' + } + ] + }, + { + 'name': 'upload-push', + 'image': 'plugins/s3:1', + 'pull': 'always', + 'settings': { + 'endpoint': { + 'from_secret': 's3_endpoint' + }, + 'access_key': { + 'from_secret': 'aws_access_key_id' + }, + 'secret_key': { + 'from_secret': 'aws_secret_access_key' + }, + 'bucket': { + 'from_secret': 's3_bucket' + }, + 'path_style': True, + 'strip_prefix': 'dist/release/', + 'source': 'dist/release/*', + 'target': '/reva/hyper/testing' + }, + 'when': { + 'event': [ + 'push' + ] + } + }, + { + 'name': 'upload-tag', + 'image': 'plugins/s3:1', + 'pull': 'always', + 'settings': { + 'endpoint': { + 'from_secret': 's3_endpoint' + }, + 'access_key': { + 'from_secret': 'aws_access_key_id' + }, + 'secret_key': { + 'from_secret': 'aws_secret_access_key' + }, + 'bucket': { + 'from_secret': 's3_bucket' + }, + 'path_style': True, + 'strip_prefix': 'dist/release/', + 'source': 'dist/release/*', + 'target': '/reva/hyper/${DRONE_TAG##v}' + }, + 'when': { + 'event': [ + 'tag' + ] + } + }, + { + 'name': 'github-release', + 'image': 'plugins/github-release:1', + 'pull': 'always', + 'settings': { + 'api_key': { + 'from_secret': 'github_token' + }, + 'files': [ + 'dist/release/*' + ] + }, + 'when': { + 'event': [ + 'tag' + ] + } + } + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {} + } + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**' + ] + } + } + +def manifest(): + return [{ + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'manifest', + 'steps': [ + { + 'name': 'manifest', + 'image': 'plugins/manifest', + 'pull': 'always', + 'settings': { + 'username': { + 'from_secret': 'docker_username' + }, + 'password': { + 'from_secret': 'docker_password' + }, + 'spec': 'docker/manifest.tmpl', + 'auto_tag': 'true', + 'ignore_missing': 'true', + }, + }, + { + 'name': 'microbadger', + 'image': 'plugins/webhook', + 'pull': 'always', + 'settings': { + 'urls': { + 'from_secret': 'microbadger_url' + } + }, + } + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**' + ] + } + }] diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000000..3d6e11052c1 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,643 @@ +--- +kind: pipeline +type: docker +name: testing + +platform: + os: linux + arch: amd64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: vet + pull: always + image: webhippie/golang:1.12 + commands: + - make vet + volumes: + - name: gopath + path: /srv/app + +- name: staticcheck + pull: always + image: webhippie/golang:1.12 + commands: + - make staticcheck + volumes: + - name: gopath + path: /srv/app + +- name: lint + pull: always + image: webhippie/golang:1.12 + commands: + - make lint + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make build + volumes: + - name: gopath + path: /srv/app + +- name: test + pull: always + image: webhippie/golang:1.12 + commands: + - make test + volumes: + - name: gopath + path: /srv/app + +- name: codacy + pull: always + image: plugins/codacy:1 + settings: + token: + from_secret: codacy_token + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +--- +kind: pipeline +type: docker +name: amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make build + volumes: + - name: gopath + path: /srv/app + +- name: dryrun + pull: always + image: plugins/docker:18.09 + settings: + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + dry_run: true + repo: owncloud/reva-hyper + tags: linux-amd64 + when: + event: + - pull_request + +- name: docker + pull: always + image: plugins/docker:18.09 + settings: + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: owncloud/reva-hyper + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: arm64 + +platform: + os: linux + arch: arm64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make build + volumes: + - name: gopath + path: /srv/app + +- name: dryrun + pull: always + image: plugins/docker:18.09 + settings: + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + dry_run: true + repo: owncloud/reva-hyper + tags: linux-arm64 + when: + event: + - pull_request + +- name: docker + pull: always + image: plugins/docker:18.09 + settings: + auto_tag: true + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + password: + from_secret: docker_password + repo: owncloud/reva-hyper + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: arm + +platform: + os: linux + arch: arm + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make build + volumes: + - name: gopath + path: /srv/app + +- name: dryrun + pull: always + image: plugins/docker:18.09 + settings: + auto_tag_suffix: linux-arm + dockerfile: docker/Dockerfile.linux.arm + dry_run: true + repo: owncloud/reva-hyper + tags: linux-arm + when: + event: + - pull_request + +- name: docker + pull: always + image: plugins/docker:18.09 + settings: + auto_tag: true + auto_tag_suffix: linux-arm + dockerfile: docker/Dockerfile.linux.arm + password: + from_secret: docker_password + repo: owncloud/reva-hyper + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: linux + +platform: + os: linux + arch: amd64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make release-linux + volumes: + - name: gopath + path: /srv/app + +- name: finish + pull: always + image: webhippie/golang:1.12 + commands: + - make release-finish + volumes: + - name: gopath + path: /srv/app + +- name: upload-push + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/testing + when: + event: + - push + +- name: upload-tag + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/${DRONE_TAG##v} + when: + event: + - tag + +- name: github-release + pull: always + image: plugins/github-release:1 + settings: + api_key: + from_secret: github_token + files: + - dist/release/* + when: + event: + - tag + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: darwin + +platform: + os: linux + arch: amd64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make release-darwin + volumes: + - name: gopath + path: /srv/app + +- name: finish + pull: always + image: webhippie/golang:1.12 + commands: + - make release-finish + volumes: + - name: gopath + path: /srv/app + +- name: upload-push + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/testing + when: + event: + - push + +- name: upload-tag + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/${DRONE_TAG##v} + when: + event: + - tag + +- name: github-release + pull: always + image: plugins/github-release:1 + settings: + api_key: + from_secret: github_token + files: + - dist/release/* + when: + event: + - tag + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: windows + +platform: + os: linux + arch: amd64 + +steps: +- name: generate + pull: always + image: webhippie/golang:1.12 + commands: + - make generate + volumes: + - name: gopath + path: /srv/app + +- name: build + pull: always + image: webhippie/golang:1.12 + commands: + - make release-windows + volumes: + - name: gopath + path: /srv/app + +- name: finish + pull: always + image: webhippie/golang:1.12 + commands: + - make release-finish + volumes: + - name: gopath + path: /srv/app + +- name: upload-push + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/testing + when: + event: + - push + +- name: upload-tag + pull: always + image: plugins/s3:1 + settings: + access_key: + from_secret: aws_access_key_id + bucket: + from_secret: s3_bucket + endpoint: + from_secret: s3_endpoint + path_style: true + secret_key: + from_secret: aws_secret_access_key + source: dist/release/* + strip_prefix: dist/release/ + target: /reva/hyper/${DRONE_TAG##v} + when: + event: + - tag + +- name: github-release + pull: always + image: plugins/github-release:1 + settings: + api_key: + from_secret: github_token + files: + - dist/release/* + when: + event: + - tag + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: manifest + +platform: + os: linux + arch: amd64 + +steps: +- name: manifest + pull: always + image: plugins/manifest + settings: + auto_tag: true + ignore_missing: true + password: + from_secret: docker_password + spec: docker/manifest.tmpl + username: + from_secret: docker_username + +- name: microbadger + pull: always + image: plugins/webhook + settings: + urls: + from_secret: microbadger_url + +trigger: + ref: + - refs/heads/master + - refs/tags/** + +depends_on: +- amd64 +- arm64 +- arm +- linux +- darwin +- windows + +... diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..bc321db7b21 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true + +[Makefile] +indent_style = tab +indent_size = 4 + +[*.go] +indent_style = tab +indent_size = 4 + +[*.starlark] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index 5c1315e3fb5..88846a9f3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,4 @@ -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, build with `go test -c` -*.test - -# Visual Studio Code -.vscode - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Ignore builds -reva-hyper - -# For Mac OS -.DS_Store +coverage.out +/bin +/dist diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..825c32f0d03 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +# Changelog diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..7eea0cf1ff7 --- /dev/null +++ b/Makefile @@ -0,0 +1,123 @@ +SHELL := bash +NAME := reva-hyper +IMPORT := github.com/owncloud/$(NAME) +BIN := bin +DIST := dist + +ifeq ($(OS), Windows_NT) + EXECUTABLE := $(NAME).exe + HAS_GORUNPKG := $(shell where gorunpkg) +else + EXECUTABLE := $(NAME) + HAS_GORUNPKG := $(shell command -v gorunpkg) +endif + +PACKAGES ?= $(shell go list ./...) +SOURCES ?= $(shell find . -name "*.go" -type f) +GENERATE ?= $(PACKAGES) + +TAGS ?= + +ifndef OUTPUT + ifneq ($(DRONE_TAG),) + OUTPUT ?= $(subst v,,$(DRONE_TAG)) + else + OUTPUT ?= testing + endif +endif + +ifndef VERSION + ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) + else + VERSION ?= $(shell git rev-parse --short HEAD) + endif +endif + +ifndef DATE + DATE := $(shell date -u '+%Y%m%d') +endif + +LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" + +.PHONY: all +all: build + +.PHONY: sync +sync: + go mod download + +.PHONY: clean +clean: + go clean -i ./... + rm -rf $(BIN) $(DIST) + +.PHONY: fmt +fmt: + gofmt -s -w $(SOURCES) + +.PHONY: vet +vet: + go vet $(PACKAGES) + +.PHONY: staticcheck +staticcheck: gorunpkg + gorunpkg honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES) + +.PHONY: lint +lint: gorunpkg + for PKG in $(PACKAGES); do gorunpkg golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done; + +.PHONY: generate +generate: gorunpkg + go generate $(GENERATE) + +.PHONY: test +test: gorunpkg + gorunpkg github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) + +.PHONY: install +install: $(SOURCES) + go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) + +.PHONY: build +build: $(BIN)/$(EXECUTABLE) + +$(BIN)/$(EXECUTABLE): $(SOURCES) + go build -i -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) + +.PHONY: release +release: release-dirs release-linux release-windows release-darwin release-copy release-check + +.PHONY: release-dirs +release-dirs: + mkdir -p $(DIST)/binaries $(DIST)/release + +.PHONY: release-linux +release-linux: gorunpkg release-dirs + gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -arch 'amd64 386 arm64 arm' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-windows +release-windows: gorunpkg release-dirs + gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-darwin +release-darwin: gorunpkg release-dirs + gorunpkg github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -arch 'amd64' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-copy +release-copy: + $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) + +.PHONY: release-check +release-check: + cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) + +.PHONY: release-finish +release-finish: release-copy release-check + +.PHONY: gorunpkg +gorunpkg: +ifndef HAS_GORUNPKG + go get -u github.com/vektah/gorunpkg +endif diff --git a/README.md b/README.md index 0ae4311a66d..5602248f15d 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,45 @@ -# reva-hyper - -## Organizational structure -* using reva as library -* building services around the library functionalities -* standalone repos for each service -* hyperreva as wrapper repository for standalone binary - -Suggested repos naming schema: -* reva-hyper - * reva-phoenix - * reva-my-service1 - * reva-my-service2 - * ... - -## Technical details -* microservices: [go-kit/kit](https://github.com/go-kit/kit) -* cli: [spf13/cobra](https://github.com/spf13/cobra) -* configuration: [spf13/viper](https://github.com/spf13/viper) - -## Next goals -* [ ] working integration demo -* [ ] minimal drone pipeline for nightly builds +# Reva: Hyper + +[![Build Status](https://cloud.drone.io/api/badges/owncloud/reva-hyper/status.svg)](https://cloud.drone.io/owncloud/reva-hyper) +[![Gitter chat](https://badges.gitter.im/cs3org/reva.svg)](https://gitter.im/cs3org/reva) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dc97ddfa167641d8b107e9b618823c71)](https://www.codacy.com/app/owncloud/reva-hyper?utm_source=github.com&utm_medium=referral&utm_content=owncloud/reva-hyper&utm_campaign=Badge_Grade) +[![Go Doc](https://godoc.org/github.com/owncloud/reva-hyper?status.svg)](http://godoc.org/github.com/owncloud/reva-hyper) +[![Go Report](http://goreportcard.com/badge/github.com/owncloud/reva-hyper)](http://goreportcard.com/report/github.com/owncloud/reva-hyper) +[![](https://images.microbadger.com/badges/image/owncloud/reva-hyper.svg)](http://microbadger.com/images/owncloud/reva-hyper "Get your own image badge on microbadger.com") + +**This project is under heavy development, it's not in a working state yet!** + +## Install + +You can download prebuilt binaries from the GitHub releases or from our [download mirrors](http://download.owncloud.com/reva/hyper/). + +## Development + +Make sure you have a working Go environment, for further reference or a guide take a look at the [install instructions](http://golang.org/doc/install.html). This project requires Go >= v1.11. + +```console +git clone https://github.com/owncloud/reva-hyper.git +cd reva-hyper + +make generate build + +./bin/reva-hyper -h +``` + +## Security + +If you find a security issue please contact security@owncloud.com first. + +## Contributing + +Fork -> Patch -> Push -> Pull Request + +## License + +Apache-2.0 + +## Copyright + +```console +Copyright (c) 2019 ownCloud GmbH +``` diff --git a/cmd/reva-hyper/main.go b/cmd/reva-hyper/main.go new file mode 100644 index 00000000000..bb5c844a1dc --- /dev/null +++ b/cmd/reva-hyper/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "os" + + "github.com/owncloud/reva-hyper/pkg/command" +) + +func main() { + if err := command.Root().Execute(); err != nil { + os.Exit(1) + } +} diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 00000000000..8156cfdcc2b --- /dev/null +++ b/config/.gitignore @@ -0,0 +1 @@ +hyper.yml diff --git a/config/example.yml b/config/example.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/docker/Dockerfile.linux.amd64 b/docker/Dockerfile.linux.amd64 new file mode 100644 index 00000000000..35d1ecaab9e --- /dev/null +++ b/docker/Dockerfile.linux.amd64 @@ -0,0 +1,16 @@ +FROM alpine:edge + +RUN apk update && \ + apk upgrade && \ + apk add ca-certificates mailcap && \ + rm -rf /var/cache/apk/* + +LABEL maintainer="ownCloud GmbH " \ + org.label-schema.name="Reva Hyper" \ + org.label-schema.vendor="ownCloud GmbH" \ + org.label-schema.schema-version="1.0" + +ENTRYPOINT ["/usr/bin/reva-hyper"] +CMD ["server"] + +COPY bin/reva-hyper /usr/bin/reva-hyper diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm new file mode 100644 index 00000000000..7af01b7eb1d --- /dev/null +++ b/docker/Dockerfile.linux.arm @@ -0,0 +1,16 @@ +FROM arm32v6/alpine:edge + +RUN apk update && \ + apk upgrade && \ + apk add ca-certificates mailcap && \ + rm -rf /var/cache/apk/* + +LABEL maintainer="ownCloud GmbH " \ + org.label-schema.name="Reva Hyper" \ + org.label-schema.vendor="ownCloud GmbH" \ + org.label-schema.schema-version="1.0" + +ENTRYPOINT ["/usr/bin/reva-hyper"] +CMD ["server"] + +COPY bin/reva-hyper /usr/bin/reva-hyper diff --git a/docker/Dockerfile.linux.arm64 b/docker/Dockerfile.linux.arm64 new file mode 100644 index 00000000000..3522337c40a --- /dev/null +++ b/docker/Dockerfile.linux.arm64 @@ -0,0 +1,16 @@ +FROM arm64v8/alpine:edge + +RUN apk update && \ + apk upgrade && \ + apk add ca-certificates mailcap && \ + rm -rf /var/cache/apk/* + +LABEL maintainer="ownCloud GmbH " \ + org.label-schema.name="Reva Hyper" \ + org.label-schema.vendor="ownCloud GmbH" \ + org.label-schema.schema-version="1.0" + +ENTRYPOINT ["/usr/bin/reva-hyper"] +CMD ["server"] + +COPY bin/reva-hyper /usr/bin/reva-hyper diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl new file mode 100644 index 00000000000..bb46870e8d4 --- /dev/null +++ b/docker/manifest.tmpl @@ -0,0 +1,22 @@ +image: owncloud/reva-hyper:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - image: owncloud/reva-hyper:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux + - image: owncloud/reva-hyper:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 + platform: + architecture: arm64 + variant: v8 + os: linux + - image: owncloud/reva-hyper:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm + platform: + architecture: arm + variant: v6 + os: linux diff --git a/go.mod b/go.mod index 5d4e9581d0e..dd57e2ff125 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,9 @@ module github.com/owncloud/reva-hyper go 1.12 require ( - github.com/owncloud/reva-phoenix v0.0.0-20190821144117-6ad779051ca6 + github.com/mitchellh/gox v1.0.1 // indirect + github.com/owncloud/reva-phoenix v0.0.0-20190904081830-66facde60aab + github.com/rs/zerolog v1.15.0 github.com/spf13/cobra v0.0.5 + github.com/spf13/viper v1.4.0 ) diff --git a/go.sum b/go.sum index 35977f3a8da..f3ff0292788 100644 --- a/go.sum +++ b/go.sum @@ -1,39 +1,164 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 h1:FdBGmSkD2QpQzRWup//SGObvWf2nq89zj9+ta9OvI3A= +github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5/go.mod h1:0YZ2wQSuwviXXXGUiK6zXzskyBLAbLXhamxzcFHSLoM= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/owncloud/reva-phoenix v0.0.0-20190821133836-432c57c406a8 h1:kW3UF3RTC0FfSEnZ5bYoLXzSt3nL2ZL7OGGBGcGMqLI= -github.com/owncloud/reva-phoenix v0.0.0-20190821135724-6aebb11b7574 h1:7B+vQUtltjUayyhKEi60MHRZF8Aoog8y23iFKIwfxGQ= -github.com/owncloud/reva-phoenix v0.0.0-20190821135724-6aebb11b7574/go.mod h1:eLLmZJn/oucdRh8Q6yYgljf8BsK/Uts7XEbx53qm1Qs= -github.com/owncloud/reva-phoenix v0.0.0-20190821140025-f7b3b4dcbb28 h1:X9nTgC0g/00os8CHEQod4WIdyzxqWLnWCy/+MiTvuqA= -github.com/owncloud/reva-phoenix v0.0.0-20190821140025-f7b3b4dcbb28/go.mod h1:eLLmZJn/oucdRh8Q6yYgljf8BsK/Uts7XEbx53qm1Qs= -github.com/owncloud/reva-phoenix v0.0.0-20190821144117-6ad779051ca6 h1:dIJDU+tcrciYAdfYoCbs0uA/rlOkzjIGjoYTWqN/F9M= -github.com/owncloud/reva-phoenix v0.0.0-20190821144117-6ad779051ca6/go.mod h1:eLLmZJn/oucdRh8Q6yYgljf8BsK/Uts7XEbx53qm1Qs= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/owncloud/reva-phoenix v0.0.0-20190904081830-66facde60aab h1:EnukxI1IQyXvQn8skaPSUCizsbOGVxHYc4N6IcES/38= +github.com/owncloud/reva-phoenix v0.0.0-20190904081830-66facde60aab/go.mod h1:KMSjvB329p95Ll2mEiLcu8DBV3FMMrxHcwMvv7rrPe4= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc h1:N3zlSgxkefUH/ecsl37RWTkESTB026kmXzNly8TuZCI= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go deleted file mode 100644 index 4f55a0efbad..00000000000 --- a/main.go +++ /dev/null @@ -1,64 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - - "github.com/spf13/cobra" - revaphoenix "github.com/owncloud/reva-phoenix/service" -) - -func main() { - - revahyperCommand, allCommandFns := NewRevaHyperCommand() - - basename := filepath.Base(os.Args[0]) - if err := commandFor(basename, revahyperCommand, allCommandFns).Execute(); err != nil { - os.Exit(1) - } -} - -// NewRevaHyperCommand is the entry point for reva-hyper -func NewRevaHyperCommand() (*cobra.Command, []func() *cobra.Command) { - - apiserver := func() *cobra.Command { return revaphoenix.NewRevaPhoenixCommand("phoenix") } - - commandFns := []func() *cobra.Command{ - apiserver, - } - - - cmd := &cobra.Command{ - Use: "reva-hyper", - Short: "Manage oCIS stack", - Run: func(cmd *cobra.Command, args []string) { - if len(args) != 0 { - cmd.Help() - os.Exit(1) - } - - }, - } - - for i := range commandFns { - cmd.AddCommand(commandFns[i]()) - } - - return cmd, commandFns -} - -func commandFor(basename string, defaultCommand *cobra.Command, commands []func() *cobra.Command) *cobra.Command { - for _, commandFn := range commands { - command := commandFn() - if command.Name() == basename { - return command - } - for _, alias := range command.Aliases { - if alias == basename { - return command - } - } - } - - return defaultCommand -} diff --git a/pkg/command/command.go b/pkg/command/command.go new file mode 100644 index 00000000000..20276e37386 --- /dev/null +++ b/pkg/command/command.go @@ -0,0 +1,102 @@ +package command + +import ( + "os" + "strings" + + "github.com/owncloud/reva-hyper/pkg/version" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Root is the entry point for the reva-phoenix command. +func Root() *cobra.Command { + cmd := &cobra.Command{ + Use: "reva-hyper", + Short: "ownCloud infinite scale stack", + Long: ``, + Version: version.String, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + setupLogger() + setupConfig() + }, + } + + cmd.PersistentFlags().String("log-level", "", "Set logging level") + viper.BindPFlag("log.level", cmd.PersistentFlags().Lookup("log-level")) + viper.SetDefault("log.level", "info") + viper.BindEnv("log.level", "HYPER_LOG_LEVEL") + + cmd.PersistentFlags().Bool("log-pretty", false, "Enable pretty logging") + viper.BindPFlag("log.pretty", cmd.PersistentFlags().Lookup("log-pretty")) + viper.SetDefault("log.pretty", true) + viper.BindEnv("log.pretty", "HYPER_LOG_PRETTY") + + cmd.PersistentFlags().Bool("log-color", false, "Enable colored logging") + viper.BindPFlag("log.color", cmd.PersistentFlags().Lookup("log-color")) + viper.SetDefault("log.color", true) + viper.BindEnv("log.color", "HYPER_LOG_COLOR") + + cmd.AddCommand(Phoenix()) + cmd.AddCommand(Health()) + + return cmd +} + +func setupLogger() { + switch strings.ToLower(viper.GetString("log.level")) { + case "panic": + zerolog.SetGlobalLevel(zerolog.PanicLevel) + case "fatal": + zerolog.SetGlobalLevel(zerolog.FatalLevel) + case "error": + zerolog.SetGlobalLevel(zerolog.ErrorLevel) + case "warn": + zerolog.SetGlobalLevel(zerolog.WarnLevel) + case "info": + zerolog.SetGlobalLevel(zerolog.InfoLevel) + case "debug": + zerolog.SetGlobalLevel(zerolog.DebugLevel) + default: + zerolog.SetGlobalLevel(zerolog.InfoLevel) + } + + if viper.GetBool("log.pretty") { + log.Logger = log.Output( + zerolog.ConsoleWriter{ + Out: os.Stderr, + NoColor: !viper.GetBool("log.color"), + }, + ) + } +} + +func setupConfig() { + viper.SetConfigName("hyper") + + viper.AddConfigPath("/etc/reva") + viper.AddConfigPath("$HOME/.reva") + viper.AddConfigPath("./config") + + if err := viper.ReadInConfig(); err != nil { + switch err.(type) { + case viper.ConfigFileNotFoundError: + log.Debug(). + Msg("Continue without config") + case viper.UnsupportedConfigError: + log.Fatal(). + Msg("Unsupported config type") + default: + if e := log.Debug(); e.Enabled() { + log.Fatal(). + Err(err). + Msg("Failed to read config") + } else { + log.Fatal(). + Msg("Failed to read config") + } + } + } +} diff --git a/pkg/command/health.go b/pkg/command/health.go new file mode 100644 index 00000000000..f500358886e --- /dev/null +++ b/pkg/command/health.go @@ -0,0 +1,27 @@ +package command + +import ( + "github.com/rs/zerolog/log" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Health is the entrypoint for the health command. +func Health() *cobra.Command { + cmd := &cobra.Command{ + Use: "health", + Short: "Check health status", + Long: "", + Run: func(cmd *cobra.Command, args []string) { + log.Info(). + Str("addr", viper.GetString("metrics.addr")). + Msg("Executed health command") + }, + } + + cmd.Flags().String("metrics-addr", "", "Address to metrics endpoint") + viper.BindPFlag("metrics.addr", cmd.Flags().Lookup("metrics-addr")) + viper.BindEnv("metrics.addr", "HYPER_METRICS_ADDR") + + return cmd +} diff --git a/pkg/command/phoenix.go b/pkg/command/phoenix.go new file mode 100644 index 00000000000..149621856d1 --- /dev/null +++ b/pkg/command/phoenix.go @@ -0,0 +1,15 @@ +package command + +import ( + phoenix "github.com/owncloud/reva-phoenix/pkg/command" + "github.com/spf13/cobra" +) + +// Phoenix is the entry point for the phoenix command. +func Phoenix() *cobra.Command { + cmd := phoenix.Server() + cmd.Use = "phoenix" + cmd.Short = "Start phoenix server" + + return cmd +} diff --git a/pkg/version/version.go b/pkg/version/version.go new file mode 100644 index 00000000000..baf2e2df3be --- /dev/null +++ b/pkg/version/version.go @@ -0,0 +1,9 @@ +package version + +var ( + // String gets defined by the build system. + String = "0.0.0" + + // Date indicates the build date. + Date = "00000000" +)