-
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
Open
zeerorg
wants to merge
5
commits into
openfaas:master
Choose a base branch
from
zeerorg:connector-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7fc17fb
Connector sdk example
zeerorg ac979d4
Referencing dockerhub image zeerorg/connector-sample
zeerorg c8a09b1
Added README for sample connector
zeerorg 8987d86
Added vendor folder and suggested fixes
zeerorg 52e384f
Rebase with upstream. Added topic environment variable.
zeerorg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
tester | ||
tester.exe |
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,29 @@ | ||
FROM golang:1.10.4 as builder | ||
RUN mkdir -p /go/src/github.com/openfaas-incubator/connector-sdk | ||
WORKDIR /go/src/github.com/openfaas-incubator/connector-sdk | ||
|
||
COPY vendor vendor | ||
COPY main.go . | ||
|
||
# Run a gofmt and exclude all vendored code. | ||
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" | ||
|
||
RUN go test -v ./... | ||
|
||
# Stripping via -ldflags "-s -w" | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector | ||
|
||
FROM alpine:3.8 | ||
|
||
RUN addgroup -S app \ | ||
&& adduser -S -g app app | ||
|
||
WORKDIR /home/app | ||
|
||
COPY --from=builder /go/src/github.com/openfaas-incubator/connector-sdk/ . | ||
|
||
RUN chown -R app:app ./ | ||
|
||
USER app | ||
|
||
CMD ["./connector"] |
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,20 @@ | ||
FROM golang:1.10.4 as builder | ||
RUN mkdir -p /go/src/github.com/openfaas-incubator/connector-sdk | ||
WORKDIR /go/src/github.com/openfaas-incubator/connector-sdk | ||
|
||
COPY vendor vendor | ||
COPY main.go . | ||
|
||
# Run a gofmt and exclude all vendored code. | ||
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" | ||
|
||
RUN go test -v ./... | ||
|
||
# Stripping via -ldflags "-s -w" | ||
RUN GOARM=7 CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector | ||
|
||
FROM alpine:3.8 | ||
|
||
COPY --from=builder /go/src/github.com/openfaas-incubator/connector-sdk/ . | ||
|
||
CMD ["./connector"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/openfaas-incubator/connector-sdk" | ||
version = "0.3.1" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
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,18 @@ | ||
# OpenFaas Sample Connector | ||
|
||
This folder contains a sample OpenFaas connector. You can use this as a base for creating your own connectors. | ||
For a more complex example checkout [kafka-connector](https://github.com/openfaas-incubator/kafka-connector) | ||
|
||
## How to Use | ||
|
||
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` | ||
4. For OpenFaas deployed on kubernetes do: `kubectl create -f ./kubernetes --namespace openfaas` | ||
|
||
To check if it actually works and triggers a function, deploy any function with annotation `topic=faas-request`. | ||
You can also run this command to deploy a sample function and see `trigger-func` invocation count growing in ui. | ||
|
||
```bash | ||
faas-cli deploy --image=functions/nodeinfo --name=trigger-func --annotation topic=vm.powered.on | ||
``` |
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
22 changes: 22 additions & 0 deletions
22
cmd/tester/vendor/github.com/openfaas-incubator/connector-sdk/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
136 changes: 136 additions & 0 deletions
136
cmd/tester/vendor/github.com/openfaas-incubator/connector-sdk/types/controller.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ?