This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devfile, CONTRIBUTING.md file, set up image build for dev container.
Signed-off-by: Oleksandr Andriienko <[email protected]>
- Loading branch information
1 parent
5e4ec9d
commit 2d6dbea
Showing
5 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ _testmain.go | |
*.prof | ||
.idea/ | ||
.vscode/ | ||
|
||
config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
### Development flow | ||
|
||
You can do che-plugin-broker development inside Eclipse CHE workspace. | ||
|
||
To install Eclipse CHE you need to choose infrastructure(openshift, kubernetes) | ||
and [set up it](https://www.eclipse.org/che/docs/che-7/che-quick-starts.html#setting-up-a-local-kubernetes-or-openshift-cluster). | ||
To create development Eclipse CHE workspace we provide che-plugin-broker devfile [devfile.yaml](devfile.yaml). | ||
> See more about [devfile](https://redhat-developer.github.io/devfile) | ||
### Create Eclipse CHE workspace from devfile | ||
|
||
To start Eclipse CHE workspace, [install the latest chectl](https://www.eclipse.org/che/docs/che-7/che-quick-starts.html#installing-the-chectl-management-tool) and start new workspace from devfile: | ||
|
||
```shell | ||
$ chectl workspace:start --devfile=https://raw.githubusercontent.com/eclipse/che-plugin-broker/master/devfile.yaml | ||
``` | ||
|
||
Open link to the workspace. After workspace start Eclipse CHE editor | ||
clones che-plugin-broker source code to the folder `/projects/src/github.com/eclipse/che-plugin-broker`. | ||
There are two development linux containers inside workspace: `dev` and `plugin-registry`. | ||
|
||
### Dev container target | ||
|
||
`dev` container created for development che-plugin-broker. It contains pre-installed development binaries: | ||
golang, dep tool, git, golangci-lint and so on. In the devfile mounted volume `/plugins` to the `dev` container | ||
to store plugins binaries downloaded with help of `unified` plugin broker. | ||
|
||
### Plugin registry container target | ||
|
||
`plugin-registry` container it's micro-service to serve Eclipse CHE plugins meta.yaml definitions. | ||
devfile defines this container in the workspace like plugin-registry service exposed in the internal container's network. | ||
`unified` plugin broker can connect to this service to get plugins meta.yaml information. | ||
|
||
### Development commands | ||
|
||
devfile.yaml provides development `tasks` for Eclipse CHE workspace. | ||
List development tasks defined in the devfile `commands` section. | ||
|
||
To launch development commands in the Eclipse CHE workspace there are three ways: | ||
|
||
1. `My Workspace` panel. In this panel you can find development tasks and launch them by click. | ||
|
||
2. `Run task...` menu: click `Terminal` menu in the main toolbar => click `Run task...` menu => select task by name and click it. | ||
> Notice: also you can find menu `Run task...` using command palette. Type shortcut `Ctrl/Cmd + Shift + P` to call command palette, type `run task`. | ||
3. Manually type task content in the terminal: `Terminal` => `Open Terminal in specific container` => select container with name `dev` and click Enter. | ||
> Notice: use correct working dir for commands in the terminal. | ||
### Compilation plugin brokers | ||
|
||
There are two plugin brokers, that's why we have two commands to compile each of them. | ||
|
||
To compile `init` plugin broker use task with name `compile "init" plugin broker`. Compiled binary will be located in the [init-plugin-broker binary folder](brokers/init/cmd). | ||
|
||
To compile `unified` plugin broker use task with name `compile "unified" plugin broker`. Compiled binary will be located in the [unified-plugin-broker binary folder](brokers/unified/cmd). | ||
|
||
### Start 'init' plugin broker | ||
|
||
To start `init` plugin broker use command `start "init" plugin broker`. After execution this task volume `/plugins` in the `dev` container should be clean | ||
(you can check it with help of terminal). | ||
|
||
### Generate config.json with list plugins for 'unified' plugin broker | ||
|
||
`unified` plugin broker uses config.json to get "workspace" plugin list. Then broker uses this 'list' to get meta.yaml information from plugin-registry service and download plugin binaries to the folder `plugins/sidecars`. | ||
|
||
We provide simple task to generate sample config.json file in the same folder with `unified` plugin broker binary. Use task `generate test config.json with "list workspace" plugins for "unified" plugin broker` to invoke it. | ||
|
||
### Start 'unified' plugin broker | ||
|
||
Before start `unified` plugin broker first [generate config.json with list plugins](generate_config.json_with_list_plugins_for_'unified'_plugin_broker). Then use task `start "unified" plugin broker`. After execution this task volume `/plugins` should contains downloaded plugin binaries in the subfolder `sidecars`(you can check it with help of terminal). | ||
|
||
### Run tests | ||
|
||
To launch che-plugin-broker tests use task with name `run tests`. | ||
|
||
### Format code | ||
|
||
During development don't forget to format code. | ||
To format che-plugin-broker code use task with name `format code`. | ||
|
||
### Lint code | ||
|
||
To lint che-plugin-broker code use task `lint code`. | ||
|
||
### Update golang dependencies | ||
|
||
To manage che-plugin-broker golang dependencies we are using [dep tool](https://golang.github.io/dep). | ||
List dependencies stored in the [Gopkg.toml](Gopkg.toml). To change dependencies you need modify this file. | ||
Use task with name `update dependencies` to flash Gopkg.toml changes: | ||
this task call dep tool to synchronize `vendor` folder and [Gopkg.lock](Gopkg.lock) with updated list dependencies. | ||
|
||
> Notice: `Gopkg.lock and vendor folder` changes should be contributed too. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (c) 2018-2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
FROM quay.io/eclipse/che-golang-1.12:nightly | ||
|
||
ARG GO_BIN_LOCATION=${GOPATH}/bin | ||
|
||
RUN cd ${GOPATH} && \ | ||
# Download golang ci lint binary | ||
wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0 && \ | ||
# Download dep tool to manage golang dependencies | ||
wget -q https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 -O ${GO_BIN_LOCATION}/dep && \ | ||
chmod +x ${GO_BIN_LOCATION}/dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
apiVersion: 1.0.0 | ||
metadata: | ||
name: che-plugin-broker | ||
projects: | ||
- name: che-plugin-broker | ||
source: | ||
location: 'https://github.com/eclipse/che-plugin-broker.git' | ||
type: git | ||
branch: master | ||
clonePath: src/github.com/eclipse/che-plugin-broker | ||
components: | ||
- id: ms-vscode/go/0.11.0 | ||
type: chePlugin | ||
alias: ms-vscode.go | ||
|
||
- type: dockerimage | ||
image: 'eclipse/che-plugin-broker-dev:next' | ||
alias: dev | ||
mountSources: true | ||
memoryLimit: 1G | ||
env: | ||
- value: '/go:$(CHE_PROJECTS_ROOT)' | ||
name: GOPATH | ||
- value: /tmp/.cache | ||
name: GOCACHE | ||
volumes: | ||
- name: plugins | ||
containerPath: /plugins | ||
|
||
- type: dockerimage | ||
image: 'quay.io/eclipse/che-plugin-registry:nightly' | ||
alias: plugin-registry | ||
endpoints: | ||
- name: plugin-registry | ||
attributes: | ||
protocol: http | ||
public: 'true' | ||
discoverable: 'true' | ||
type: plugin-registry | ||
secure: 'false' | ||
port: 8080 | ||
memoryLimit: 256M | ||
|
||
commands: | ||
- name: compile "init" plugin broker | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker/brokers/init/cmd | ||
type: exec | ||
command: >- | ||
printf 'Start "init" plugin broker compilation...\n' && | ||
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-w -s' -installsuffix cgo -o init-plugin-broker main.go && | ||
printf '\033[32mDone.\033[0m' | ||
component: dev | ||
- name: compile "unified" plugin broker | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker/brokers/unified/cmd | ||
type: exec | ||
command: >- | ||
printf 'Start "unified" plugin broker compilation...\n' && | ||
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-w -s' -installsuffix cgo -o unified-plugin-broker main.go && | ||
printf '\033[32mDone.\033[0m' | ||
component: dev | ||
- name: run tests | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker | ||
type: exec | ||
command: go test -race ./... | ||
component: dev | ||
- name: format code | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker | ||
type: exec | ||
command: 'go fmt ./... && printf "\033[32mDone.\033[0m"' | ||
component: dev | ||
- name: lint code | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker | ||
type: exec | ||
command: 'golangci-lint run -v' | ||
component: dev | ||
- name: update dependencies | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker | ||
type: exec | ||
command: >- | ||
printf 'Update dependencies...\n' && | ||
dep ensure && | ||
printf "\033[32mDone.\033[0m" | ||
component: dev | ||
- name: start "unified" plugin broker | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker/brokers/unified/cmd | ||
type: exec | ||
command: './unified-plugin-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che --registry-address=http://plugin-registry:8080' | ||
component: dev | ||
- name: start "init" plugin broker | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker/brokers/init/cmd | ||
type: exec | ||
command: './init-plugin-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che' | ||
component: dev | ||
- name: generate test config.json with "list workspace" plugins for "unified" plugin broker | ||
actions: | ||
- workdir: /projects/src/github.com/eclipse/che-plugin-broker/brokers/unified/cmd | ||
type: exec | ||
command: |- | ||
if [ -f config.json ]; then rm config.json; fi; | ||
cat <<EOF>>config.json | ||
[ | ||
{ | ||
"id": "ms-kubernetes-tools/vscode-kubernetes-tools/latest" | ||
}, | ||
{ | ||
"id": "eclipse/che-machine-exec-plugin/latest" | ||
}, | ||
{ | ||
"id": "eclipse/che-theia/latest" | ||
} | ||
] | ||
EOF | ||
echo 'config.json for unified plugin broker successfully generated.' | ||
component: dev |