Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

tmctl dump - Add support for Docker-Compose & DigitalOcean#197

Merged
FranBarrera merged 21 commits intotriggermesh:mainfrom
FranBarrera:compose-do
Jan 19, 2023
Merged

tmctl dump - Add support for Docker-Compose & DigitalOcean#197
FranBarrera merged 21 commits intotriggermesh:mainfrom
FranBarrera:compose-do

Conversation

@FranBarrera
Copy link
Copy Markdown
Contributor

Added a new parameter to tmctl dump [--platform| -p] with multiple platforms [kubernetes | knative | docker-compose | digitalocean]. By default is kubernetes.

Example:

tmctl dump -p docker-compose

services:
  console:
    container_name: console
    environment: []
    image: gcr.io/triggermesh/triggermesh-console:v0.0.1
    ports:
    - 54772:8080
    volumes: []
  foo:
    command: start --memory.buffer-size 100 --memory.produce-timeout 1s --broker-config-path
      /etc/triggermesh/broker.conf
    container_name: foo
    environment: []
    image: gcr.io/triggermesh/memory-broker:latest
    ports:
    - 54758:8080
    volumes:
    - source: /Users/fran/.triggermesh/cli/foo/broker.conf
      target: /etc/triggermesh/broker.conf
      type: bind
  foo-httppollersource:
    container_name: foo-httppollersource
    environment:
    - HTTPPOLLER_EVENT_TYPE=buzzword.phrase
    - HTTPPOLLER_EVENT_SOURCE=local.foo-httppollersource
    - HTTPPOLLER_ENDPOINT=https://corporatebs-generator.sameerkumar.website/
    - HTTPPOLLER_METHOD=GET
    - HTTPPOLLER_SKIP_VERIFY=false
    - HTTPPOLLER_INTERVAL=20s
    - K_SINK=http://host.docker.internal:54758
    image: gcr.io/triggermesh/httppollersource-adapter:v1.22.0
    ports:
    - "8080"
    volumes: []
  foo-transformation:
    container_name: foo-transformation
    environment:
    - TRANSFORMATION_CONTEXT=[{"operation":"add","paths":[{"key":"type","value":"foo-transformation.output"}]}]
    - TRANSFORMATION_DATA=[{"operation":"add","paths":[{"key":"new-field","value":"hello
      from Transformation!"}]}]
    image: gcr.io/triggermesh/transformation-adapter:v1.22.0
    ports:
    - 54777:8080
    volumes: []

@sebgoa
Copy link
Copy Markdown
Member

sebgoa commented Dec 21, 2022

it works.

but for DO:

  • sources need to be of type workers and not services
  • the sources need to sink to the broker with a route of /broker like
  - key: K_SINK
    scope: RUN_AND_BUILD_TIME
    value: ${broker.PRIVATE_URL}/broker
  • the broker is indeed of type services but with a route set to broker like:
  name: broker
  routes:
  - path: /broker

@sebgoa
Copy link
Copy Markdown
Member

sebgoa commented Dec 21, 2022

Can you remove the gcr.io/triggermesh from the DO dump. Those images will need to be in the DO registry, right now we can reference them implicitly with only the adapter name.

For compose the full gcr.io/triggermesh name is correct.

@FranBarrera
Copy link
Copy Markdown
Contributor Author

@sebgoa DO issues should be fine now

@sebgoa
Copy link
Copy Markdown
Member

sebgoa commented Dec 28, 2022

This could be a follow on ticket.

When there are more than one services (i.e targets) each should have its own route (instead of being just root /) and this should get reflected in the broker config if need be.

@jmcx jmcx linked an issue Jan 4, 2023 that may be closed by this pull request
@sebgoa
Copy link
Copy Markdown
Member

sebgoa commented Jan 10, 2023

A bit dirty but I am putting a diff here so that I don't loose it

$ git diff cmd/dump/dump.go
diff --git a/cmd/dump/dump.go b/cmd/dump/dump.go
index fdaeba8..492f4ba 100644
--- a/cmd/dump/dump.go
+++ b/cmd/dump/dump.go
@@ -25,6 +25,7 @@ import (
        "strings"
 
        "github.com/digitalocean/godo"
+       "github.com/google/uuid"
        "github.com/spf13/cobra"
        "github.com/spf13/viper"
 
@@ -147,7 +148,7 @@ func (o *dumpOptions) dump() error {
                                                targetURL = fmt.Sprintf("http://%s:8080", target.Ref.Name)
                                        }
                                        if o.Platform == platformDigitalOcean {
-                                               targetURL = fmt.Sprintf("${%s.PRIVATE_URL}", target.Ref.Name)
+                                               targetURL = fmt.Sprintf("${%s.PRIVATE_URL}/%s", target.Ref.Name, target.Ref.Name)
                                        }
                                        trigger := tmbroker.LocalTriggerSpec{}
                                        filter := eventingbroker.Filter{}
@@ -214,7 +215,7 @@ func (o *dumpOptions) dump() error {
                        }
                }
                doObject := godo.AppSpec{
-                       Name:     "triggermesh",
+                       Name:     "triggermesh-" + uuid.NewString()[:5],
                        Services: doServices,
                        Workers:  doWorkers,
                        Region:   "fra",
(⎈ |prod:sebgoa)MacBook-Air:tmctl sebgoa$ git diff pkg/triggermesh/components/target/target.go
diff --git a/pkg/triggermesh/components/target/target.go b/pkg/triggermesh/components/target/target.go
index 20f6eb2..1407568 100644
--- a/pkg/triggermesh/components/target/target.go
+++ b/pkg/triggermesh/components/target/target.go
@@ -156,7 +156,7 @@ func (t *Target) AsDigitalOcean(additionalEnvs map[string]string) (*digitalocean
                HTTPPort: 8080,
                Routes: []*godo.AppRouteSpec{
                        {
-                               Path: "/",
+                               Path: "/" + t.Name,
                        },
                },
                Envs:

@FranBarrera FranBarrera requested a review from sebgoa January 11, 2023 10:56
Copy link
Copy Markdown
Member

@sebgoa sebgoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first functionality is there. so I am approving.

thanks for switching the transformation to a ServiceSpec

@tzununbekov
Copy link
Copy Markdown
Member

Looks like I cannot merge my branch with this PR because it is based on the personal fork. @FranBarrera could you cherry-pick 3017928? Alternatively, we can merge this one and then mine on the top, but cherry-picking is preferable to keep the change history clean.

@FranBarrera FranBarrera merged commit f805a28 into triggermesh:main Jan 19, 2023
@FranBarrera FranBarrera deleted the compose-do branch January 19, 2023 09:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a dump to docker-compose

3 participants