Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Add devfile, CONTRIBUTING.md file, set up image build for dev container. #68

Merged
merged 6 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ docker build -t eclipse/che-init-plugin-broker:latest -f ${ROOT_DIR}/build/init/
docker tag eclipse/che-init-plugin-broker:latest eclipse/che-init-plugin-broker:${TAG}
docker push eclipse/che-init-plugin-broker:latest
docker push eclipse/che-init-plugin-broker:${TAG}

# Development image
nickboldt marked this conversation as resolved.
Show resolved Hide resolved
docker build -t eclipse/che-plugin-broker-dev:latest -f ${ROOT_DIR}/build/dev/Dockerfile ${ROOT_DIR}
docker tag eclipse/che-plugin-broker-dev:latest eclipse/che-plugin-broker-dev:${TAG}
docker push eclipse/che-plugin-broker-dev:latest
docker push eclipse/che-plugin-broker-dev:${TAG}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ _testmain.go
*.prof
.idea/
.vscode/
.theia/

config.json
87 changes: 87 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
### 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 it up](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
```

Then, open the link to the workspace. After the workspace starts, the 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, `/plugins` is mounted as a volume on the `dev` container
to store plugins binaries downloaded with help of `unified` plugin broker.

### Plugin registry container target

`plugin-registry` container is a micro-service to serve Eclipse Che plugins meta.yaml definitions.
The devfile defines this container in the workspace, and the plugin-registry's service is exposed in the internal container's network.
The `unified` plugin broker can connect to this service to get plugins meta.yaml information.

### Development commands

devfile.yaml provides development `tasks` for the Eclipse Che workspace.
|These are defined in the devfile `commands` section.

To launch development commands in the Eclipse Che workspace, you can:

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.

### Compiling 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).

### Start 'unified' plugin broker

To start `unified` plugin broker 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.

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ test:
lint:
golangci-lint run -v

.PHONY: fmt
fmt:
go fmt ./...

.PHONY: dep-update
dep-update:
dep ensure

.PHONY: build-docker-init
build-docker-init:
docker build -t eclipse/che-init-plugin-broker:latest -f build/init/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion brokers/unified/cmd/config-plugin-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
{
"id": "redhat/java/0.43.0",
"registry": "https://raw.githubusercontent.com/eclipse/che-plugin-registry/master/v3/plugins"
"registry": "https://raw.githubusercontent.com/eclipse/che-plugin-registry/master/v3"
},
{
"id": "eclipse/che-theia/next"
Expand Down
22 changes: 22 additions & 0 deletions build/dev/Dockerfile
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
101 changes: 101 additions & 0 deletions devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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:latest'
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-local
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/
type: exec
command: >-
printf 'Launch "init" plugin broker compilation...\n' &&
make build-init &&
printf '\033[32mDone.\033[0m'
component: dev
- name: compile "unified" plugin broker
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: >-
printf 'Launch "unified" plugin broker compilation...\n' &&
make build-unified &&
printf '\033[32mDone.\033[0m'
component: dev
- name: run tests
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: make test
component: dev
- name: format code
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: 'make fmt && printf "\033[32mDone.\033[0m"'
component: dev
- name: lint code
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: 'make lint'
component: dev
- name: update dependencies
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: >-
printf 'Update dependencies...\n' &&
make dep-update &&
printf "\033[32mDone.\033[0m"
component: dev
- name: start "unified" plugin broker
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: './unified-plugin-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che --registry-address=http://plugin-registry-local:8080 --metas ./brokers/unified/cmd/config-plugin-ids.json'
component: dev
- name: start "init" plugin broker
actions:
- workdir: /projects/src/github.com/eclipse/che-plugin-broker
type: exec
command: './init-plugin-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che'
component: dev