-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactoring gateway * Updated state handling of event sources * updating gateways * refactor resource gateway * updating gateways * updating gateways * updating gateways * updating gateways * updating gateways * refactoring sensor * refactoring controllers * refactoring controllers * Updating hack * Updating documentation * updated examples * Adding recover in gateways * Gateway is now deployed as a pod instead of deployment * refactoring state machine of sensor and gateway * Updating sensor and gateway state machine * Updating sensor and gateway state machine * Updating examples * Add custom GitHub gateway Issue #95
- Loading branch information
1 parent
0bb0273
commit a671891
Showing
13 changed files
with
520 additions
and
0 deletions.
There are no files selected for viewing
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,20 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: github-gateway-configmap | ||
data: | ||
project_1: |- | ||
owner: "owner-example" | ||
repository: "repo-example" | ||
url: "http://webhook-gateway-gateway-svc/push" | ||
events: | ||
- "*" | ||
apiToken: | ||
name: github-access | ||
key: token | ||
webHookSecret: | ||
name: github-access | ||
key: secret | ||
insecure: false | ||
active: true | ||
contentType: "json" |
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,32 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Gateway | ||
metadata: | ||
name: github-gateway | ||
labels: | ||
gateways.argoproj.io/gateway-controller-instanceid: argo-events | ||
gateway-name: "github-gateway" | ||
spec: | ||
deploySpec: | ||
metadata: | ||
labels: | ||
gateway-type: github | ||
dispatch-mechanism: http | ||
spec: | ||
containers: | ||
- name: "gateway-client" | ||
image: "metalgearsolid/gateway-client:v0.6.1" | ||
imagePullPolicy: "Always" | ||
command: ["/bin/gateway-client"] | ||
- name: "file-events" | ||
image: "metalgearsolid/github-gateway:v0.6.1" | ||
imagePullPolicy: "Always" | ||
command: ["/bin/github-gateway"] | ||
serviceAccountName: "argo-events-sa" | ||
configMap: "github-gateway-configmap" | ||
type: "github" | ||
dispatchProtocol: "HTTP" | ||
eventVersion: "1.0" | ||
processorPort: "9330" | ||
watchers: | ||
sensors: | ||
- name: "github-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,36 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Sensor | ||
metadata: | ||
name: github-sensor | ||
labels: | ||
sensors.argoproj.io/sensor-controller-instanceid: argo-events | ||
spec: | ||
repeat: true | ||
serviceAccountName: argo-events-sa | ||
imageVersion: "latest" | ||
imagePullPolicy: Always | ||
signals: | ||
- name: webhook-gateway/index | ||
triggers: | ||
- name: github-workflow-trigger | ||
resource: | ||
namespace: argo-events | ||
group: argoproj.io | ||
version: v1alpha1 | ||
kind: Workflow | ||
source: | ||
inline: | | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: hello-world- | ||
spec: | ||
entrypoint: whalesay | ||
templates: | ||
- name: whalesay | ||
container: | ||
args: | ||
- "hello world" | ||
command: | ||
- cowsay | ||
image: "docker/whalesay:latest" |
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,7 @@ | ||
FROM alpine:latest as certs | ||
RUN apk --update add ca-certificates | ||
|
||
FROM scratch | ||
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY dist/github-gateway /bin/ | ||
ENTRYPOINT [ "/bin/github-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,43 @@ | ||
/* | ||
Copyright 2018 KompiTech GmbH | ||
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 ( | ||
"github.com/argoproj/argo-events/common" | ||
"github.com/argoproj/argo-events/gateways" | ||
"github.com/argoproj/argo-events/gateways/custom/github" | ||
"k8s.io/client-go/kubernetes" | ||
"os" | ||
) | ||
|
||
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(&github.GithubEventSourceExecutor{ | ||
Log: common.GetLoggerContext(common.LoggerConf()).Logger(), | ||
Namespace: namespace, | ||
Clientset: clientset, | ||
}) | ||
} |
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,90 @@ | ||
/* | ||
Copyright 2018 KompiTech GmbH | ||
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 github | ||
|
||
import ( | ||
"github.com/ghodss/yaml" | ||
"github.com/rs/zerolog" | ||
"k8s.io/client-go/kubernetes" | ||
"github.com/google/go-github/github" | ||
) | ||
|
||
// GithubEventSourceExecutor implements ConfigExecutor | ||
type GithubEventSourceExecutor struct { | ||
Log zerolog.Logger | ||
// GitlabClient is client for gitlab api | ||
GithubClient *github.Client | ||
// Clientset is kubernetes client | ||
Clientset kubernetes.Interface | ||
// Namespace where gateway is deployed | ||
Namespace string | ||
} | ||
|
||
// GithubConfig contains information to setup a github project integration | ||
// +k8s:openapi-gen=true | ||
type GithubConfig struct { | ||
// GitHub owner name i.e. argoproj | ||
Owner string `json:"owner"` | ||
|
||
// GitHub repo name i.e. argo-events | ||
Repository string `json:"repository"` | ||
|
||
// Github events to subscribe to which the gateway will subscribe | ||
Events []string `json:"events"` | ||
|
||
// External URL for hooks | ||
URL string `json:"url"` | ||
|
||
// K8s secret containing github api token | ||
APIToken *GithubSecret `json:"apiToken"` | ||
|
||
// K8s secret containing WebHook Secret | ||
WebHookSecret *GithubSecret `json:"webHookSecret"` | ||
|
||
// Insecure tls verification | ||
Insecure bool `json:"insecure"` | ||
|
||
// Active | ||
Active bool `json:"active"` | ||
|
||
// ContentType json or form | ||
ContentType string `json:"contentType"` | ||
} | ||
|
||
// GithubSecret contains information of k8 secret which holds the github api access token key | ||
// +k8s:openapi-gen=true | ||
type GithubSecret struct { | ||
// Name of k8 secret containing api token or webhook secret | ||
Name string | ||
// Key for api token/webhook secret | ||
Key string | ||
} | ||
|
||
// cred stores the api access token or webhook secret | ||
type cred struct { | ||
secret string | ||
} | ||
|
||
// parseEventSource parses a configuration of gateway | ||
func parseEventSource(config *string) (*GithubConfig, error) { | ||
var g *GithubConfig | ||
err := yaml.Unmarshal([]byte(*config), &g) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return g, err | ||
} |
Oops, something went wrong.