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 plugin metadata broker
    actions:
      - workdir: /projects/src/github.com/eclipse/che-plugin-broker/
        type: exec
        command: >-
          printf 'Starting plugin metadata broker compilation...\n' &&
          make build-metadata &&
          printf '\033[32mDone.\033[0m'
        component: dev
  - name: compile "artifacts" plugin broker
    actions:
      - workdir: /projects/src/github.com/eclipse/che-plugin-broker
        type: exec
        command: >-
          printf 'Starting plugin artifacts broker compilation...\n' &&
          make build-artifacts  &&
          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' &&
          go mod tidy && go mod vendor
          printf "\033[32mDone.\033[0m"
        component: dev
  - name: start plugin artifacts broker
    actions:
      - workdir: /projects/src/github.com/eclipse/che-plugin-broker
        type: exec
        command: './plugin-artifacts-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che --registry-address=http://plugin-registry-local:8080 --metas ./brokers/testdata/config-plugin-ids.json'
        component: dev
  - name: start plugin metadata broker
    actions:
      - workdir: /projects/src/github.com/eclipse/che-plugin-broker
        type: exec
        command: './plugin-metadata-broker --disable-push=true --runtime-id=workspace:developer:eclipse-che --registry-address=http://plugin-registry-local:8080 --metas ./brokers/testdata/config-plugin-ids.json'
        component: dev
