-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connector example #3
base: master
Are you sure you want to change the base?
Conversation
cmd/tester/main.go
Outdated
} | ||
} | ||
|
||
func getControllerConfig() *types.ControllerConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If running in a the default is gateway.openfaas:8080
/ gateway:8080
on Swarm. We should just not default at all if not passed and return an error (types.ControllerConfig, error)
cmd/tester/main.go
Outdated
} | ||
fmt.Println("Gateway Url: ", gURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not print this here.
|
||
controller := types.NewController(creds, config) | ||
fmt.Println(controller) | ||
controller.BeginMapBuilder() | ||
|
||
topics := getTopics() | ||
|
||
// Simulate events emitting from queue/pub-sub | ||
for { | ||
time.Sleep(2 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this configurable to please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add an env-var to make this configurable ? Or a simple variable is enough ?
cmd/tester/main.go
Outdated
PrintResponse: true, | ||
} | ||
creds := types.GetCredentials() // Get credentials for gateway login | ||
config := getControllerConfig() | ||
|
||
controller := types.NewController(creds, config) | ||
fmt.Println(controller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
cmd/tester/main.go
Outdated
PrintResponse: true, | ||
} | ||
creds := types.GetCredentials() // Get credentials for gateway login | ||
config := getControllerConfig() | ||
|
||
controller := types.NewController(creds, config) | ||
fmt.Println(controller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace fmt
with log
for use in the container.
cmd/tester/Dockerfile
Outdated
@@ -0,0 +1,16 @@ | |||
FROM golang:1.9.2 as builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy the example from the vcenter connector please it has an updated Golang version.
cmd/tester/Dockerfile
Outdated
# Stripping via -ldflags "-s -w" | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector | ||
|
||
FROM alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy the example from the vcenter connector please it has an updated alpine version, we must always pin to 3.8
or whatever version we are targeting.
cmd/tester/Dockerfile
Outdated
@@ -0,0 +1,16 @@ | |||
FROM golang:1.9.2 as builder | |||
RUN mkdir -p /go/src/github.com/openfaas-incubator/connector | |||
WORKDIR /go/src/github.com/openfaas-incubator/connector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path I guess is connector-sdk
right? To match the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it's:
/go/src/github.com/openfaas-incubator/connector-sdk/cmd/tester/
correct?
cmd/tester/Dockerfile
Outdated
|
||
COPY main.go . | ||
|
||
RUN go get -d -v ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove go get
It should use vendoring via dep
or the correct path.
cmd/tester/README.md
Outdated
|
||
1. Clone this repository: `git clone https://github.com/openfaas-incubator/connector-sdk.git` | ||
2. Go into the directory: `cd ./connector-sdk/cmd/tester/yaml` | ||
3. For openfaas deployed on docker swarm do: `docker stack deploy func -c ./docker-compose.yml` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openfaas
-> OpenFaaS
cmd/tester/README.md
Outdated
|
||
1. Clone this repository: `git clone https://github.com/openfaas-incubator/connector-sdk.git` | ||
2. Go into the directory: `cd ./connector-sdk/cmd/tester/yaml` | ||
3. For openfaas deployed on docker swarm do: `docker stack deploy func -c ./docker-compose.yml` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker swarm
-> Docker Swarm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, thanks for working on this PR. I had some mixed feelings on creating and maintaining a separate set of Dockerfiles and Kubernetes YAML files, but since you've done it I'd like to give you some feedback so that we can merge it.
The items are very minor and once done can be merged. Just ping me again when you've worked through the suggestions.
I've worked through all the suggestions. This should be good to go. Some major changes:
|
cmd/tester/main.go
Outdated
} | ||
|
||
func getControllerConfig() (*types.ControllerConfig, error) { | ||
gURL, ok := os.LookupEnv("gateway_url") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to gatewayURL
containers: | ||
- name: sample-connector | ||
image: zeerorg/connector-sample:1.0 | ||
env: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add topics as an env-var, this is how connectors are intended to work.
The scope of this PR was simply to provide a Dockerfile and Kubernetes YAML, not to change the example behaviour or functionality. Please can you revert the below?
I think the extracting the configuration loading is fine to keep in the changes, but in a separate PR. Alex |
6f97e78
to
ddcf919
Compare
Signed-off-by: Rishabh Gupta <[email protected]>
Signed-off-by: Rishabh Gupta<[email protected]>
Signed-off-by: Rishabh Gupta<[email protected]>
Signed-off-by: Rishabh Gupta<[email protected]>
Signed-off-by: Rishabh Gupta<[email protected]>
ddcf919
to
52e384f
Compare
The previous example had fixed gateway url, I changed it to rely on environment variable and same is done for topic which rely on environment variable. This pretty much resembles a very trimmed down version of kafka connector. |
This PR updates the connector example with swarm and kubernetes deployment files.
How it is tested:
cd ./connector-sdk/cmd/tester/yaml
docker stack deploy func -c ./docker-compose.yml
kubectl create -f ./kubernetes --namespace openfaas
Run this command to deploy a sample function and see
trigger-func
invocation count growing in ui.Signed-off-by: Rishabh Gupta [email protected]