forked from knative/eventing-contrib
-
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.
Used Deployment as receive adapter instead of CronJob becasue of the batched job side car issue. kubernetes/kubernetes#25908 If this issue is resolved in the future, we can switch to use CronJob.
- Loading branch information
Showing
41 changed files
with
3,552 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2018 The Knative Authors | ||
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 ( | ||
"flag" | ||
"log" | ||
"os" | ||
|
||
"github.com/knative/eventing-sources/pkg/adapter/cronjobevents" | ||
"go.uber.org/zap" | ||
|
||
"golang.org/x/net/context" | ||
) | ||
|
||
const ( | ||
// Environment variable container schedule. | ||
envSchedue = "SCHEDULE" | ||
|
||
// Environment variable containing data. | ||
envData = "DATA" | ||
|
||
// Sink for messages. | ||
envSinkURI = "SINK_URI" | ||
) | ||
|
||
func getRequiredEnv(envKey string) string { | ||
val, defined := os.LookupEnv(envKey) | ||
if !defined { | ||
log.Fatalf("required environment variable not defined '%s'", envKey) | ||
} | ||
return val | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
ctx := context.Background() | ||
logger, err := zap.NewProduction() | ||
if err != nil { | ||
log.Fatalf("Unable to create logger: %v", err) | ||
} | ||
|
||
adapter := &cronjobevents.Adapter{ | ||
Schedule: getRequiredEnv(envSchedue), | ||
Data: getRequiredEnv(envData), | ||
SinkURI: getRequiredEnv(envSinkURI), | ||
} | ||
|
||
logger.Info("Starting Receive Adapter. %v", zap.Reflect("adapter", adapter)) | ||
if err := adapter.Start(ctx); err != nil { | ||
logger.Fatal("Failed to start adapter: ", zap.Error(err)) | ||
} | ||
} |
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,70 @@ | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
controller-tools.k8s.io: "1.0" | ||
name: cronjobsources.sources.eventing.knative.dev | ||
spec: | ||
group: sources.eventing.knative.dev | ||
names: | ||
categories: | ||
- all | ||
- knative | ||
- eventing | ||
- sources | ||
kind: CronJobSource | ||
plural: cronjobsources | ||
scope: Namespaced | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
apiVersion: | ||
type: string | ||
kind: | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
properties: | ||
schedule: | ||
type: string | ||
data: | ||
type: string | ||
serviceAccountName: | ||
type: string | ||
sink: | ||
type: object | ||
type: object | ||
status: | ||
properties: | ||
conditions: | ||
items: | ||
properties: | ||
lastTransitionTime: | ||
type: object | ||
message: | ||
type: string | ||
reason: | ||
type: string | ||
severity: | ||
type: string | ||
status: | ||
type: string | ||
type: | ||
type: string | ||
required: | ||
- type | ||
- status | ||
type: object | ||
type: array | ||
sinkUri: | ||
type: string | ||
type: object | ||
version: v1alpha1 | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
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,17 @@ | ||
# this fixes the auto-detected object, we use a string in the stored object but | ||
# a wrapper object for time at runtime. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: cronjobsources.sources.eventing.knative.dev | ||
spec: | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
status: | ||
properties: | ||
conditions: | ||
items: | ||
properties: | ||
lastTransitionTime: | ||
type: string |
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
Oops, something went wrong.