forked from argoproj/argo-events
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature(): adding trello gateway * feat(): update trello gateway * feat(): update trello gateway
- Loading branch information
1 parent
3e18dd1
commit 6b95290
Showing
13 changed files
with
489 additions
and
2 deletions.
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
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
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
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,16 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: trello-gateway-configmap | ||
data: | ||
notification_1: |- | ||
endpoint: "/" | ||
port: "9600" | ||
apiKey: | ||
name: trello-secret | ||
key: apikey | ||
token: | ||
name trello-secret | ||
key: tokenkey | ||
url: "URL_TO_REGISTER" | ||
description: "test webhook" |
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,35 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Gateway | ||
metadata: | ||
name: trello-gateway | ||
labels: | ||
gateways.argoproj.io/gateway-controller-instanceid: argo-events | ||
gateway-name: "trello-gateway" | ||
spec: | ||
processorPort: "9330" | ||
eventProtocol: | ||
type: "HTTP" | ||
http: | ||
port: "9300" | ||
deploySpec: | ||
metadata: | ||
name: "trello-gateway" | ||
labels: | ||
gateway-name: "trello-gateway" | ||
spec: | ||
containers: | ||
- name: "gateway-client" | ||
image: "argoproj/gateway-client" | ||
imagePullPolicy: "Always" | ||
command: ["/bin/gateway-client"] | ||
- name: "trello-events" | ||
image: "argoproj/trello-gateway" | ||
imagePullPolicy: "Always" | ||
command: ["/bin/trello-gateway"] | ||
serviceAccountName: "argo-events-sa" | ||
configMap: "trello-gateway-configmap" | ||
type: "trello" | ||
eventVersion: "1.0" | ||
watchers: | ||
sensors: | ||
- name: "trello-sensor" |
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,52 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Sensor | ||
metadata: | ||
name: trello-sensor | ||
labels: | ||
sensors.argoproj.io/sensor-controller-instanceid: argo-events | ||
spec: | ||
deploySpec: | ||
containers: | ||
- name: "sensor" | ||
image: "argoproj/sensor" | ||
imagePullPolicy: Always | ||
serviceAccountName: argo-events-sa | ||
eventProtocol: | ||
type: "HTTP" | ||
http: | ||
port: "9300" | ||
dependencies: | ||
- name: "trello-gateway:notification_1" | ||
triggers: | ||
- name: trello-workflow | ||
resource: | ||
namespace: argo-events | ||
group: argoproj.io | ||
version: v1alpha1 | ||
kind: Workflow | ||
parameters: | ||
- src: | ||
event: "trello-gateway:notification_1" | ||
dest: spec.arguments.parameters.0.value | ||
source: | ||
inline: | | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: trello- | ||
spec: | ||
entrypoint: whalesay | ||
arguments: | ||
parameters: | ||
- name: message | ||
# this is the value that should be overridden | ||
value: hello world | ||
templates: | ||
- name: whalesay | ||
inputs: | ||
parameters: | ||
- name: message | ||
container: | ||
image: docker/whalesay:latest | ||
command: [cowsay] | ||
args: ["{{inputs.parameters.message}}"] |
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,3 @@ | ||
FROM scratch | ||
COPY dist/trello-gateway /bin/ | ||
ENTRYPOINT [ "/bin/trello-gateway" ] |
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,44 @@ | ||
/* | ||
Copyright 2018 BlackRock, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/argoproj/argo-events/common" | ||
"github.com/argoproj/argo-events/gateways" | ||
"github.com/argoproj/argo-events/gateways/community/trello" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
func main() { | ||
kubeConfig, _ := os.LookupEnv(common.EnvVarKubeConfig) | ||
restConfig, err := common.GetClientConfig(kubeConfig) | ||
if err != nil { | ||
panic(err) | ||
} | ||
clientset := kubernetes.NewForConfigOrDie(restConfig) | ||
namespace, ok := os.LookupEnv(common.EnvVarGatewayNamespace) | ||
if !ok { | ||
panic("namespace is not provided") | ||
} | ||
gateways.StartGateway(&trello.TrelloEventSourceExecutor{ | ||
Log: common.GetLoggerContext(common.LoggerConf()).Logger(), | ||
Clientset: clientset, | ||
Namespace: namespace, | ||
}) | ||
} |
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,57 @@ | ||
/* | ||
Copyright 2018 BlackRock, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package trello | ||
|
||
import ( | ||
"github.com/ghodss/yaml" | ||
"github.com/rs/zerolog" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
type TrelloEventSourceExecutor struct { | ||
Log zerolog.Logger | ||
// Clientset is kubernetes client | ||
Clientset kubernetes.Interface | ||
// Namespace where gateway is deployed | ||
Namespace string | ||
} | ||
|
||
type trello struct { | ||
// ApiKey for client | ||
ApiKey *corev1.SecretKeySelector `json:"apiKey"` | ||
// Token for client | ||
Token *corev1.SecretKeySelector `json:"token"` | ||
// Endpoint is REST API endpoint | ||
Endpoint string `json:"endpoint"` | ||
// Port to run the http server on | ||
Port string `json:"port"` | ||
// URL to register at trello | ||
URL string `json:"url"` | ||
// Description for webhook | ||
// +optional | ||
Description string `json:"description,omitempty"` | ||
} | ||
|
||
func parseEventSource(es string) (interface{}, error) { | ||
var n *trello | ||
err := yaml.Unmarshal([]byte(es), &n) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return n, nil | ||
} |
Oops, something went wrong.