Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions config/300-cronjobsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2019 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.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
labels:
eventing.knative.dev/source: "true"
knative.dev/crd-install: "true"
name: cronjobsources.sources.eventing.knative.dev
spec:
group: sources.eventing.knative.dev
names:
categories:
- all
- knative
- eventing
- sources
kind: CronJobSource
plural: cronjobsources
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
data:
type: string
schedule:
type: string
serviceAccountName:
type: string
sink:
type: object
required:
- schedule
type: object
status:
properties:
conditions:
items:
properties:
lastTransitionTime:
# we use a string in the stored object but a wrapper object
# at runtime.
type: string
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
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/k8s.io/code-
# instead of the $GOPATH directly. For normal projects this can be dropped.
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/knative/eventing/pkg/client github.com/knative/eventing/pkg/apis \
"eventing:v1alpha1" \
"eventing:v1alpha1 sources:v1alpha1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# Only deepcopy the Duck types, as they are not real resources.
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/sources/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2019 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 sources

const (
GroupName = "sources.eventing.knative.dev"
)
95 changes: 95 additions & 0 deletions pkg/apis/sources/v1alpha1/cron_job_lifecycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
Copyright 2019 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 v1alpha1

import (
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
)

const (
// CronJobConditionReady has status True when the CronJobSource is ready to send events.
CronJobConditionReady = duckv1alpha1.ConditionReady

// CronJobConditionValidSchedule has status True when the CronJobSource has been configured with a valid schedule.
CronJobConditionValidSchedule duckv1alpha1.ConditionType = "ValidSchedule"

// CronJobConditionSinkProvided has status True when the CronJobSource has been configured with a sink target.
CronJobConditionSinkProvided duckv1alpha1.ConditionType = "SinkProvided"

// CronJobConditionDeployed has status True when the CronJobSource has had it's receive adapter deployment created.
CronJobConditionDeployed duckv1alpha1.ConditionType = "Deployed"
)

var cronJobSourceCondSet = duckv1alpha1.NewLivingConditionSet(
CronJobConditionValidSchedule,
CronJobConditionSinkProvided,
CronJobConditionDeployed)

// GetCondition returns the condition currently associated with the given type, or nil.
func (s *CronJobSourceStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition {
return cronJobSourceCondSet.Manage(s).GetCondition(t)
}

// IsReady returns true if the resource is ready overall.
func (s *CronJobSourceStatus) IsReady() bool {
return cronJobSourceCondSet.Manage(s).IsHappy()
}

// InitializeConditions sets relevant unset conditions to Unknown state.
func (s *CronJobSourceStatus) InitializeConditions() {
cronJobSourceCondSet.Manage(s).InitializeConditions()
}

// MarkSchedule sets the condition that the source has a valid schedule configured.
func (s *CronJobSourceStatus) MarkSchedule() {
cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionValidSchedule)
}

// MarkInvalidSchedule sets the condition that the source does not have a valid schedule configured.
func (s *CronJobSourceStatus) MarkInvalidSchedule(reason, messageFormat string, messageA ...interface{}) {
cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionValidSchedule, reason, messageFormat, messageA...)
}

// MarkSink sets the condition that the source has a sink configured.
func (s *CronJobSourceStatus) MarkSink(uri string) {
s.SinkURI = uri
if len(uri) > 0 {
cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionSinkProvided)
} else {
cronJobSourceCondSet.Manage(s).MarkUnknown(CronJobConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "")
}
}

// MarkNoSink sets the condition that the source does not have a sink configured.
func (s *CronJobSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) {
cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionSinkProvided, reason, messageFormat, messageA...)
}

// MarkDeployed sets the condition that the source has been deployed.
func (s *CronJobSourceStatus) MarkDeployed() {
cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionDeployed)
}

// MarkDeploying sets the condition that the source is deploying.
func (s *CronJobSourceStatus) MarkDeploying(reason, messageFormat string, messageA ...interface{}) {
cronJobSourceCondSet.Manage(s).MarkUnknown(CronJobConditionDeployed, reason, messageFormat, messageA...)
}

// MarkNotDeployed sets the condition that the source has not been deployed.
func (s *CronJobSourceStatus) MarkNotDeployed(reason, messageFormat string, messageA ...interface{}) {
cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionDeployed, reason, messageFormat, messageA...)
}
Loading