未验证 提交 147f5022 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #3356 from wanjunlei/nm

support customize notification receiver
......@@ -37,6 +37,7 @@ import (
"kubesphere.io/kubesphere/pkg/controller/network/ippool"
"kubesphere.io/kubesphere/pkg/controller/network/nsnetworkpolicy"
"kubesphere.io/kubesphere/pkg/controller/network/nsnetworkpolicy/provider"
"kubesphere.io/kubesphere/pkg/controller/notification"
"kubesphere.io/kubesphere/pkg/controller/pipeline"
"kubesphere.io/kubesphere/pkg/controller/s2ibinary"
"kubesphere.io/kubesphere/pkg/controller/s2irun"
......@@ -284,6 +285,11 @@ func addControllers(
if multiClusterEnabled {
controllers["globalrole-controller"] = globalRoleController
notificationController, err := notification.NewController(client.Kubernetes(), mgr.GetClient(), mgr.GetCache())
if err != nil {
return err
}
controllers["notification-controller"] = notificationController
}
for name, ctrl := range controllers {
......
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: configs.notification.kubesphere.io
spec:
group: notification.kubesphere.io
names:
categories:
- notification-manager
kind: Config
listKind: ConfigList
plural: configs
shortNames:
- nc
singular: config
scope: Cluster
versions:
- name: v2beta1
schema:
openAPIV3Schema:
description: DingTalkConfig is the Schema for the dingtalkconfigs API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ConfigSpec defines the desired state of Config
properties:
dingtalk:
properties:
conversation:
description: Only needed when send alerts to the conversation.
properties:
appkey:
description: The key of the application with which to send messages.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
appsecret:
description: The key in the secret to be used. Must be a valid secret key.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
labels:
additionalProperties:
type: string
type: object
type: object
email:
properties:
authIdentify:
description: The identity for PLAIN authentication.
type: string
authPassword:
description: The secret contains the SMTP password for LOGIN and PLAIN authentications.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
authSecret:
description: The secret contains the SMTP secret for CRAM-MD5 authentication.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
authUsername:
description: The username for CRAM-MD5, LOGIN and PLAIN authentications.
type: string
from:
description: The sender address.
type: string
hello:
description: The hostname to use when identifying to the SMTP server.
type: string
labels:
additionalProperties:
type: string
type: object
requireTLS:
description: The default SMTP TLS requirement.
type: boolean
smartHost:
description: The address of the SMTP server.
properties:
host:
type: string
port:
type: integer
required:
- host
- port
type: object
tls:
description: TLSConfig configures the options for TLS connections.
properties:
clientCertificate:
description: The certificate of the client.
properties:
cert:
description: The client cert file for the targets.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
key:
description: The client key file for the targets.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
rootCA:
description: RootCA defines the root certificate authorities that clients use when verifying server certificates.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
serverName:
description: Used to verify the hostname for the targets.
type: string
type: object
required:
- from
- smartHost
type: object
slack:
properties:
labels:
additionalProperties:
type: string
type: object
slackTokenSecret:
description: The token of user or bot.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
webhook:
properties:
labels:
additionalProperties:
type: string
type: object
type: object
wechat:
properties:
labels:
additionalProperties:
type: string
type: object
wechatApiAgentId:
description: The id of the application which sending message.
type: string
wechatApiCorpId:
description: The corp id for authentication.
type: string
wechatApiSecret:
description: The API key to use when talking to the WeChat API.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
wechatApiUrl:
description: The WeChat API URL.
type: string
required:
- wechatApiAgentId
- wechatApiCorpId
- wechatApiSecret
type: object
type: object
status:
description: ConfigStatus defines the observed state of Config
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
此差异已折叠。
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: federatednamespaces.types.kubefed.io
spec:
group: types.kubefed.io
names:
kind: FederatedNamespace
listKind: FederatedNamespaceList
plural: federatednamespaces
singular: federatednamespace
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
overrides:
items:
properties:
clusterName:
type: string
clusterOverrides:
items:
properties:
op:
type: string
path:
type: string
value:
type: object
required:
- path
type: object
type: array
required:
- clusterName
type: object
type: array
placement:
properties:
clusterSelector:
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
clusters:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
type: object
template:
properties:
spec:
description: NamespaceSpec describes the attributes on a Namespace.
properties:
finalizers:
description: 'Finalizers is an opaque list of values that must be empty to permanently remove object from storage. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/'
items:
description: FinalizerName is the name identifying a finalizer during namespace lifecycle.
type: string
type: array
type: object
type: object
required:
- placement
- template
type: object
status:
properties:
clusters:
items:
properties:
name:
type: string
status:
type: string
required:
- name
type: object
type: array
conditions:
items:
properties:
lastTransitionTime:
description: Last time the condition transit from one status to another.
type: string
lastUpdateTime:
description: Last time reconciliation resulted in an error or the last time a change was propagated to member clusters.
type: string
reason:
description: (brief) reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of cluster condition
type: string
required:
- status
- type
type: object
type: array
observedGeneration:
format: int64
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: federatednotificationconfigs.types.kubefed.io
spec:
group: types.kubefed.io
names:
kind: FederatedNotificationConfig
listKind: FederatedNotificationConfigList
plural: federatednotificationconfigs
singular: federatednotificationconfig
scope: Cluster
versions:
- name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
overrides:
items:
properties:
clusterName:
type: string
clusterOverrides:
items:
properties:
op:
type: string
path:
type: string
value:
type: object
required:
- path
type: object
type: array
required:
- clusterName
type: object
type: array
placement:
properties:
clusterSelector:
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
clusters:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
type: object
template:
properties:
metadata:
type: object
x-kubernetes-preserve-unknown-fields: true
spec:
description: ConfigSpec defines the desired state of Config
properties:
dingtalk:
properties:
conversation:
description: Only needed when send alerts to the conversation.
properties:
appkey:
description: The key of the application with which to send messages.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
appsecret:
description: The key in the secret to be used. Must be a valid secret key.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
labels:
additionalProperties:
type: string
type: object
type: object
email:
properties:
authIdentify:
description: The identity for PLAIN authentication.
type: string
authPassword:
description: The secret contains the SMTP password for LOGIN and PLAIN authentications.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
authSecret:
description: The secret contains the SMTP secret for CRAM-MD5 authentication.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
authUsername:
description: The username for CRAM-MD5, LOGIN and PLAIN authentications.
type: string
from:
description: The sender address.
type: string
hello:
description: The hostname to use when identifying to the SMTP server.
type: string
labels:
additionalProperties:
type: string
type: object
requireTLS:
description: The default SMTP TLS requirement.
type: boolean
smartHost:
description: The address of the SMTP server.
properties:
host:
type: string
port:
type: integer
required:
- host
- port
type: object
tls:
description: TLSConfig configures the options for TLS connections.
properties:
clientCertificate:
description: The certificate of the client.
properties:
cert:
description: The client cert file for the targets.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
key:
description: The client key file for the targets.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
rootCA:
description: RootCA defines the root certificate authorities that clients use when verifying server certificates.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
serverName:
description: Used to verify the hostname for the targets.
type: string
type: object
required:
- from
- smartHost
type: object
slack:
properties:
labels:
additionalProperties:
type: string
type: object
slackTokenSecret:
description: The token of user or bot.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
type: object
webhook:
properties:
labels:
additionalProperties:
type: string
type: object
type: object
wechat:
properties:
labels:
additionalProperties:
type: string
type: object
wechatApiAgentId:
description: The id of the application which sending message.
type: string
wechatApiCorpId:
description: The corp id for authentication.
type: string
wechatApiSecret:
description: The API key to use when talking to the WeChat API.
properties:
key:
description: The key of the secret to select from. Must be a valid secret key.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: The namespace of the secret, default to the pod's namespace.
type: string
required:
- key
type: object
wechatApiUrl:
description: The WeChat API URL.
type: string
required:
- wechatApiAgentId
- wechatApiCorpId
- wechatApiSecret
type: object
type: object
type: object
required:
- placement
- template
type: object
status:
properties:
clusters:
items:
properties:
name:
type: string
status:
type: string
required:
- name
type: object
type: array
conditions:
items:
properties:
lastTransitionTime:
description: Last time the condition transit from one status to another.
type: string
lastUpdateTime:
description: Last time reconciliation resulted in an error or the last time a change was propagated to member clusters.
type: string
reason:
description: (brief) reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of cluster condition
type: string
required:
- status
- type
type: object
type: array
observedGeneration:
format: int64
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: federatedsecrets.types.kubefed.io
spec:
group: types.kubefed.io
names:
kind: FederatedSecret
listKind: FederatedSecretList
plural: federatedsecrets
singular: federatedsecret
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
overrides:
items:
properties:
clusterName:
type: string
clusterOverrides:
items:
properties:
op:
type: string
path:
type: string
value:
type: object
required:
- path
type: object
type: array
required:
- clusterName
type: object
type: array
placement:
properties:
clusterSelector:
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
clusters:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
type: object
template:
properties:
data:
additionalProperties:
format: byte
type: string
type: object
stringData:
additionalProperties:
type: string
type: object
type:
type: string
type: object
required:
- placement
- template
type: object
status:
properties:
clusters:
items:
properties:
name:
type: string
status:
type: string
required:
- name
type: object
type: array
conditions:
items:
properties:
lastTransitionTime:
description: Last time the condition transit from one status to another.
type: string
lastUpdateTime:
description: Last time reconciliation resulted in an error or the last time a change was propagated to member clusters.
type: string
reason:
description: (brief) reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of cluster condition
type: string
required:
- status
- type
type: object
type: array
observedGeneration:
format: int64
type: integer
type: object
required:
- spec
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
......@@ -2,8 +2,7 @@
set -e
GV="network:v1alpha1 servicemesh:v1alpha2 tenant:v1alpha1 tenant:v1alpha2 devops:v1alpha1 iam:v1alpha2 devops:v1alpha3 cluster:v1alpha1 storage:v1alpha1 auditing:v1alpha1 types:v1beta1 quota:v1alpha2 application:v1alpha1"
GV="network:v1alpha1 servicemesh:v1alpha2 tenant:v1alpha1 tenant:v1alpha2 devops:v1alpha1 iam:v1alpha2 devops:v1alpha3 cluster:v1alpha1 storage:v1alpha1 auditing:v1alpha1 types:v1beta1 quota:v1alpha2 application:v1alpha1 notification:v2beta1"
rm -rf ./pkg/client
./hack/generate_group.sh "client,lister,informer" kubesphere.io/kubesphere/pkg/client kubesphere.io/kubesphere/pkg/apis "$GV" --output-base=./ -h "$PWD/hack/boilerplate.go.txt"
......
/*
Copyright 2019 The KubeSphere 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 apis
import (
"kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
)
func init() {
AddToSchemes = append(AddToSchemes, v2beta1.SchemeBuilder.AddToScheme)
}
/*
Copyright 2020 The KubeSphere 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 auditing contains auditing API versions
package notification
/*
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 v2beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Configuration of conversation
type DingTalkApplicationConfig struct {
// The key of the application with which to send messages.
AppKey *SecretKeySelector `json:"appkey,omitempty"`
// The key in the secret to be used. Must be a valid secret key.
AppSecret *SecretKeySelector `json:"appsecret,omitempty"`
}
type DingTalkConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// Only needed when send alerts to the conversation.
Conversation *DingTalkApplicationConfig `json:"conversation,omitempty"`
}
type ClientCertificate struct {
// The client cert file for the targets.
Cert *SecretKeySelector `json:"cert,omitempty"`
// The client key file for the targets.
Key *SecretKeySelector `json:"key,omitempty"`
}
// TLSConfig configures the options for TLS connections.
type TLSConfig struct {
// RootCA defines the root certificate authorities
// that clients use when verifying server certificates.
RootCA *SecretKeySelector `json:"rootCA,omitempty"`
// The certificate of the client.
*ClientCertificate `json:"clientCertificate,omitempty"`
// Used to verify the hostname for the targets.
ServerName string `json:"serverName,omitempty"`
// Disable target certificate validation.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
}
// BasicAuth contains basic HTTP authentication credentials.
type BasicAuth struct {
Username string `json:"username"`
Password *SecretKeySelector `json:"password,omitempty"`
}
// HTTPClientConfig configures an HTTP client.
type HTTPClientConfig struct {
// The HTTP basic authentication credentials for the targets.
BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
// The bearer token for the targets.
BearerToken *SecretKeySelector `json:"bearerToken,omitempty"`
// HTTP proxy server to use to connect to the targets.
ProxyURL string `json:"proxyUrl,omitempty"`
// TLSConfig to use to connect to the targets.
TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
}
type HostPort struct {
Host string `json:"host"`
Port int `json:"port"`
}
type EmailConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The sender address.
From string `json:"from"`
// The address of the SMTP server.
SmartHost HostPort `json:"smartHost"`
// The hostname to use when identifying to the SMTP server.
Hello *string `json:"hello,omitempty"`
// The username for CRAM-MD5, LOGIN and PLAIN authentications.
AuthUsername *string `json:"authUsername,omitempty"`
// The identity for PLAIN authentication.
AuthIdentify *string `json:"authIdentify,omitempty"`
// The secret contains the SMTP password for LOGIN and PLAIN authentications.
AuthPassword *SecretKeySelector `json:"authPassword,omitempty"`
// The secret contains the SMTP secret for CRAM-MD5 authentication.
AuthSecret *SecretKeySelector `json:"authSecret,omitempty"`
// The default SMTP TLS requirement.
RequireTLS *bool `json:"requireTLS,omitempty"`
TLS *TLSConfig `json:"tls,omitempty"`
}
type SlackConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The token of user or bot.
SlackTokenSecret *SecretKeySelector `json:"slackTokenSecret,omitempty"`
}
type WebhookConfig struct {
Labels map[string]string `json:"labels,omitempty"`
}
type WechatConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The WeChat API URL.
WechatApiUrl string `json:"wechatApiUrl,omitempty"`
// The corp id for authentication.
WechatApiCorpId string `json:"wechatApiCorpId"`
// The id of the application which sending message.
WechatApiAgentId string `json:"wechatApiAgentId"`
// The API key to use when talking to the WeChat API.
WechatApiSecret *SecretKeySelector `json:"wechatApiSecret"`
}
//ConfigSpec defines the desired state of Config
type ConfigSpec struct {
DingTalk *DingTalkConfig `json:"dingtalk,omitempty"`
Email *EmailConfig `json:"email,omitempty"`
Slack *SlackConfig `json:"slack,omitempty"`
Webhook *WebhookConfig `json:"webhook,omitempty"`
Wechat *WechatConfig `json:"wechat,omitempty"`
}
// ConfigStatus defines the observed state of Config
type ConfigStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,shortName=nc,categories=notification-manager
// +kubebuilder:subresource:status
// +genclient
// +genclient:nonNamespaced
// DingTalkConfig is the Schema for the dingtalkconfigs API
type Config struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ConfigSpec `json:"spec,omitempty"`
Status ConfigStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// ConfigList contains a list of Config
type ConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Config `json:"items"`
}
func init() {
SchemeBuilder.Register(&Config{}, &ConfigList{})
}
/*
Copyright 2020 The KubeSphere 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 v2beta1 contains API Schema definitions for the notification v2beta1 API group
// +groupName=notification.kubesphere.io
// +genclient
// +genclient:nonNamespaced
package v2beta1
/*
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 v2beta1
import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)
// SecretKeySelector selects a key of a Secret.
type SecretKeySelector struct {
// The namespace of the secret, default to the pod's namespace.
// +optional
Namespace string `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
// Name of the secret.
// +optional
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// The key of the secret to select from. Must be a valid secret key.
Key string `json:"key" protobuf:"bytes,2,opt,name=key"`
}
// NotificationManagerSpec defines the desired state of NotificationManager
type NotificationManagerSpec struct {
// Compute Resources required by container.
Resources v1.ResourceRequirements `json:"resources,omitempty"`
// Docker Image used to start Notification Manager container,
// for example kubesphere/notification-manager:v0.1.0
Image *string `json:"image,omitempty"`
// Image pull policy. One of Always, Never, IfNotPresent.
// Defaults to IfNotPresent if not specified
ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"`
// Number of instances to deploy for Notification Manager deployment.
Replicas *int32 `json:"replicas,omitempty"`
// Define which Nodes the Pods will be scheduled to.
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Pod's scheduling constraints.
Affinity *v1.Affinity `json:"affinity,omitempty"`
// Pod's tolerations.
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// ServiceAccountName is the name of the ServiceAccount to use to run Notification Manager Pods.
// ServiceAccount 'default' in notification manager's namespace will be used if not specified.
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// Port name used for the pods and service, defaults to webhook
PortName string `json:"portName,omitempty"`
// Default Email/Wechat/Slack/Webhook Config to be selected
DefaultConfigSelector *metav1.LabelSelector `json:"defaultConfigSelector,omitempty"`
// Receivers to send notifications to
Receivers *ReceiversSpec `json:"receivers"`
// The default namespace to which notification manager secrets belong.
DefaultSecretNamespace string `json:"defaultSecretNamespace,omitempty"`
// List of volumes that can be mounted by containers belonging to the pod.
Volumes []v1.Volume `json:"volumes,omitempty"`
// Pod volumes to mount into the container's filesystem.
// Cannot be updated.
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
// Arguments to the entrypoint.
// The docker image's CMD is used if this is not provided.
// Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
// cannot be resolved, the reference in the input string will remain unchanged. The $(VAR_NAME) syntax
// can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded,
// regardless of whether the variable exists or not.
// Cannot be updated.
// +optional
Args []string `json:"args,omitempty"`
}
type ReceiversSpec struct {
// Key used to identify tenant, default to be "namespace" if not specified
TenantKey string `json:"tenantKey"`
// Selector to find global notification receivers
// which will be used when tenant receivers cannot be found.
// Only matchLabels expression is allowed.
GlobalReceiverSelector *metav1.LabelSelector `json:"globalReceiverSelector"`
// Selector to find tenant notification receivers.
// Only matchLabels expression is allowed.
TenantReceiverSelector *metav1.LabelSelector `json:"tenantReceiverSelector"`
// Various receiver options
Options *Options `json:"options,omitempty"`
}
type GlobalOptions struct {
// Template file path, must be a absolute path.
TemplateFiles []string `json:"templateFile,omitempty"`
// The name of the template to generate message.
// If the receiver dose not setup template, it will use this.
Template string `json:"template,omitempty"`
// The name of the cluster in which the notification manager is deployed.
Cluster string `json:"cluster,omitempty"`
}
type EmailOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// Type of sending email, bulk or single
DeliveryType string `json:"deliveryType,omitempty"`
// The maximum size of receivers in one email.
MaxEmailReceivers int `json:"maxEmailReceivers,omitempty"`
// The name of the template to generate email message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
// The name of the template to generate email subject
SubjectTemplate string `json:"subjectTemplate,omitempty"`
}
type WechatOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate wechat message.
Template string `json:"template,omitempty"`
// The maximum message size that can be sent in a request.
MessageMaxSize int `json:"messageMaxSize,omitempty"`
// The time of token expired.
TokenExpires time.Duration `json:"tokenExpires,omitempty"`
}
type SlackOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate slack message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
}
type WebhookOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate webhook message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
}
// The config of flow control.
type Throttle struct {
// The maximum calls in `Unit`.
Threshold int `json:"threshold,omitempty"`
Unit time.Duration `json:"unit,omitempty"`
// The maximum tolerable waiting time when the calls trigger flow control, if the actual waiting time is more than this time, it will
// return a error, else it will wait for the flow restriction lifted, and send the message.
// Nil means do not wait, the maximum value is `Unit`.
MaxWaitTime time.Duration `json:"maxWaitTime,omitempty"`
}
type DingTalkOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate DingTalk message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
// The time of token expired.
TokenExpires time.Duration `json:"tokenExpires,omitempty"`
// The maximum message size that can be sent to conversation in a request.
ConversationMessageMaxSize int `json:"conversationMessageMaxSize,omitempty"`
// The maximum message size that can be sent to chatbot in a request.
ChatbotMessageMaxSize int `json:"chatbotMessageMaxSize,omitempty"`
// The flow control fo chatbot.
ChatBotThrottle *Throttle `json:"chatBotThrottle,omitempty"`
// The flow control fo conversation.
ConversationThrottle *Throttle `json:"conversationThrottle,omitempty"`
}
type Options struct {
Global *GlobalOptions `json:"global,omitempty"`
Email *EmailOptions `json:"email,omitempty"`
Wechat *WechatOptions `json:"wechat,omitempty"`
Slack *SlackOptions `json:"slack,omitempty"`
Webhook *WebhookOptions `json:"webhook,omitempty"`
DingTalk *DingTalkOptions `json:"dingtalk,omitempty"`
}
// NotificationManagerStatus defines the observed state of NotificationManager
type NotificationManagerStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,shortName=nm,categories=notification-manager
// +kubebuilder:subresource:status
// NotificationManager is the Schema for the notificationmanagers API
type NotificationManager struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NotificationManagerSpec `json:"spec,omitempty"`
Status NotificationManagerStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// NotificationManagerList contains a list of NotificationManager
type NotificationManagerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NotificationManager `json:"items"`
}
func init() {
SchemeBuilder.Register(&NotificationManager{}, &NotificationManagerList{})
}
/*
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 v2beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Configuration of ChatBot
type DingTalkChatBot struct {
// The webhook of ChatBot which the message will send to.
Webhook *SecretKeySelector `json:"webhook"`
// Custom keywords of ChatBot
Keywords []string `json:"keywords,omitempty"`
// Secret of ChatBot, you can get it after enabled Additional Signature of ChatBot.
Secret *SecretKeySelector `json:"secret,omitempty"`
}
// Configuration of conversation
type DingTalkConversation struct {
ChatIDs []string `json:"chatids"`
}
type DingTalkReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// DingTalkConfig to be selected for this receiver
DingTalkConfigSelector *metav1.LabelSelector `json:"dingtalkConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// Be careful, a ChatBot only can send 20 message per minute.
ChatBot *DingTalkChatBot `json:"chatbot,omitempty"`
// The conversation which message will send to.
Conversation *DingTalkConversation `json:"conversation,omitempty"`
}
type EmailReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// Receivers' email addresses
To []string `json:"to"`
// EmailConfig to be selected for this receiver
EmailConfigSelector *metav1.LabelSelector `json:"emailConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
}
type SlackReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// SlackConfig to be selected for this receiver
SlackConfigSelector *metav1.LabelSelector `json:"slackConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// The channel or user to send notifications to.
Channels []string `json:"channels"`
}
// ServiceReference holds a reference to Service.legacy.k8s.io
type ServiceReference struct {
// `namespace` is the namespace of the service.
// Required
Namespace string `json:"namespace"`
// `name` is the name of the service.
// Required
Name string `json:"name"`
// `path` is an optional URL path which will be sent in any request to
// this service.
// +optional
Path *string `json:"path,omitempty"`
// If specified, the port on the service that hosting webhook.
// Default to 443 for backward compatibility.
// `port` should be a valid port number (1-65535, inclusive).
// +optional
Port *int32 `json:"port,omitempty"`
// Http scheme, default is http.
// +optional
Scheme *string `json:"scheme,omitempty"`
}
type WebhookReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// WebhookConfig to be selected for this receiver
WebhookConfigSelector *metav1.LabelSelector `json:"webhookConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// `url` gives the location of the webhook, in standard URL form
// (`scheme://host:port/path`). Exactly one of `url` or `service`
// must be specified.
//
// The `host` should not refer to a service running in the cluster; use
// the `service` field instead. The host might be resolved via external
// DNS in some api servers (e.g., `kube-apiserver` cannot resolve
// in-cluster DNS as that would be a layering violation). `host` may
// also be an IP address.
//
// Please note that using `localhost` or `127.0.0.1` as a `host` is
// risky unless you take great care to run this webhook on all hosts
// which run an apiserver which might need to make calls to this
// webhook. Such installs are likely to be non-portable, i.e., not easy
// to turn up in a new cluster.
//
// A path is optional, and if present may be any string permissible in
// a URL. You may use the path to pass an arbitrary string to the
// webhook, for example, a cluster identifier.
//
// Attempting to use a user or basic auth e.g. "user:password@" is not
// allowed. Fragments ("#...") and query parameters ("?...") are not
// allowed, either.
//
// +optional
URL *string `json:"url,omitempty"`
// `service` is a reference to the service for this webhook. Either
// `service` or `url` must be specified.
//
// If the webhook is running within the cluster, then you should use `service`.
//
// +optional
Service *ServiceReference `json:"service,omitempty"`
HTTPConfig *HTTPClientConfig `json:"httpConfig,omitempty"`
}
type WechatReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// WechatConfig to be selected for this receiver
WechatConfigSelector *metav1.LabelSelector `json:"wechatConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// +optional
ToUser []string `json:"toUser,omitempty"`
ToParty []string `json:"toParty,omitempty"`
ToTag []string `json:"toTag,omitempty"`
}
//ReceiverSpec defines the desired state of Receiver
type ReceiverSpec struct {
DingTalk *DingTalkReceiver `json:"dingtalk,omitempty"`
Email *EmailReceiver `json:"email,omitempty"`
Slack *SlackReceiver `json:"slack,omitempty"`
Webhook *WebhookReceiver `json:"webhook,omitempty"`
Wechat *WechatReceiver `json:"wechat,omitempty"`
}
// ReceiverStatus defines the observed state of Receiver
type ReceiverStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,shortName=nr,categories=notification-manager
// +kubebuilder:subresource:status
// +genclient
// +genclient:nonNamespaced
// Receiver is the Schema for the receivers API
type Receiver struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ReceiverSpec `json:"spec,omitempty"`
Status ReceiverStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// ReceiverList contains a list of Receiver
type ReceiverList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Receiver `json:"items"`
}
func init() {
SchemeBuilder.Register(&Receiver{}, &ReceiverList{})
}
/*
Copyright 2020 The KubeSphere 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.
*/
// NOTE: Boilerplate only. Ignore this file.
// Package v2beta1 contains API Schema definitions for the notification v2beta1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=notification.kubesphere.io
package v2beta1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
)
var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "notification.kubesphere.io", Version: "v2beta1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
AddToScheme = SchemeBuilder.AddToScheme
)
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
/*
Copyright 2020 The KubeSphere 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 v2beta1
const (
ResourceKindConfig = "Configs"
ResourcesSingularConfig = "config"
ResourcesPluralConfig = "configs"
ResourceKindReceiver = "Receiver"
ResourcesSingularReceiver = "receiver"
ResourcesPluralReceiver = "receivers"
)
/*
Copyright 2020 The KubeSphere 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 v2beta1
import (
"log"
"os"
"path/filepath"
"testing"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
)
var cfg *rest.Config
func TestMain(m *testing.M) {
t := &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")},
}
err := SchemeBuilder.AddToScheme(scheme.Scheme)
if err != nil {
log.Fatal(err)
}
if cfg, err = t.Start(); err != nil {
log.Fatal(err)
}
if _, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}); err != nil {
log.Fatal(err)
}
code := m.Run()
_ = t.Stop()
os.Exit(code)
}
此差异已折叠。
/*
Copyright 2020 KubeSphere 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 v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
)
const (
ResourcePluralFederatedNotificationConfig = "federatednotificationconfigs"
ResourceSingularFederatedNotificationConfig = "federatednotificationconfig"
FederatedNotificationConfigKind = "FederatedNotificationConfig"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
type FederatedNotificationConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationConfigSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationConfigSpec struct {
Template NotificationConfigTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationConfigTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta1.ConfigSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationConfigList contains a list of federatednotificationconfiglists
type FederatedNotificationConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationConfig `json:"items"`
}
/*
Copyright 2020 KubeSphere 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 v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
)
const (
ResourcePluralFederatedNotificationReceiver = "federatednotificationreceivers"
ResourceSingularFederatedNotificationReceiver = "federatednotificationreceiver"
FederatedNotificationReceiverKind = "FederatedNotificationReceiver"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
type FederatedNotificationReceiver struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationReceiverSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationReceiverSpec struct {
Template NotificationReceiverTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationReceiverTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta1.ReceiverSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationConfigList contains a list of federatednotificationreceiverlists
type FederatedNotificationReceiverList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationReceiver `json:"items"`
}
......@@ -62,6 +62,10 @@ func init() {
&FederatedLimitRangeList{},
&FederatedNamespace{},
&FederatedNamespaceList{},
&FederatedNotificationConfig{},
&FederatedNotificationConfigList{},
&FederatedNotificationReceiver{},
&FederatedNotificationReceiverList{},
&FederatedPersistentVolumeClaim{},
&FederatedPersistentVolumeClaimList{},
&FederatedResourceQuota{},
......
......@@ -20,6 +20,7 @@ import (
"bytes"
"context"
"fmt"
"kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
"net/http"
rt "runtime"
"time"
......@@ -37,6 +38,7 @@ import (
"k8s.io/klog"
clusterv1alpha1 "kubesphere.io/kubesphere/pkg/apis/cluster/v1alpha1"
iamv1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
tenantv1alpha1 "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
typesv1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
audit "kubesphere.io/kubesphere/pkg/apiserver/auditing"
......@@ -68,6 +70,7 @@ import (
monitoringv1alpha3 "kubesphere.io/kubesphere/pkg/kapis/monitoring/v1alpha3"
networkv1alpha2 "kubesphere.io/kubesphere/pkg/kapis/network/v1alpha2"
notificationv1 "kubesphere.io/kubesphere/pkg/kapis/notification/v1"
notificationkapisv2beta1 "kubesphere.io/kubesphere/pkg/kapis/notification/v2beta1"
"kubesphere.io/kubesphere/pkg/kapis/oauth"
openpitrixv1 "kubesphere.io/kubesphere/pkg/kapis/openpitrix/v1"
operationsv1alpha2 "kubesphere.io/kubesphere/pkg/kapis/operations/v1alpha2"
......@@ -270,6 +273,8 @@ func (s *APIServer) installKubeSphereAPIs() {
s.KubernetesClient.Prometheus(), s.AlertingClient, s.Config.AlertingOptions))
urlruntime.Must(version.AddToContainer(s.container, s.KubernetesClient.Discovery()))
urlruntime.Must(kubeedgev1alpha1.AddToContainer(s.container, s.Config.KubeEdgeOptions.Endpoint))
urlruntime.Must(notificationkapisv2beta1.AddToContainer(s.container, s.InformerFactory, s.KubernetesClient.Kubernetes(),
s.KubernetesClient.KubeSphere()))
}
func (s *APIServer) Run(stopCh <-chan struct{}) (err error) {
......@@ -310,6 +315,8 @@ func (s *APIServer) buildHandlerChain(stopCh <-chan struct{}) {
tenantv1alpha2.Resource(clusterv1alpha1.ResourcesPluralCluster),
clusterv1alpha1.Resource(clusterv1alpha1.ResourcesPluralCluster),
resourcev1alpha3.Resource(clusterv1alpha1.ResourcesPluralCluster),
notificationv2beta1.Resource(v2beta1.ResourcesPluralConfig),
notificationv2beta1.Resource(v2beta1.ResourcesPluralReceiver),
},
}
......@@ -443,6 +450,8 @@ func (s *APIServer) waitForResourceSync(stopCh <-chan struct{}) error {
{Group: "cluster.kubesphere.io", Version: "v1alpha1", Resource: "clusters"},
{Group: "devops.kubesphere.io", Version: "v1alpha3", Resource: "devopsprojects"},
{Group: "network.kubesphere.io", Version: "v1alpha1", Resource: "ippools"},
{Group: "notification.kubesphere.io", Version: "v2beta1", Resource: v2beta1.ResourcesPluralConfig},
{Group: "notification.kubesphere.io", Version: "v2beta1", Resource: v2beta1.ResourcesPluralReceiver},
}
devopsGVRs := []schema.GroupVersionResource{
......
......@@ -31,6 +31,7 @@ import (
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/devops/v1alpha3"
iamv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/network/v1alpha1"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/storage/v1alpha1"
......@@ -48,6 +49,7 @@ type Interface interface {
DevopsV1alpha3() devopsv1alpha3.DevopsV1alpha3Interface
IamV1alpha2() iamv1alpha2.IamV1alpha2Interface
NetworkV1alpha1() networkv1alpha1.NetworkV1alpha1Interface
NotificationV2beta1() notificationv2beta1.NotificationV2beta1Interface
QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface
ServicemeshV1alpha2() servicemeshv1alpha2.ServicemeshV1alpha2Interface
StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface
......@@ -67,6 +69,7 @@ type Clientset struct {
devopsV1alpha3 *devopsv1alpha3.DevopsV1alpha3Client
iamV1alpha2 *iamv1alpha2.IamV1alpha2Client
networkV1alpha1 *networkv1alpha1.NetworkV1alpha1Client
notificationV2beta1 *notificationv2beta1.NotificationV2beta1Client
quotaV1alpha2 *quotav1alpha2.QuotaV1alpha2Client
servicemeshV1alpha2 *servicemeshv1alpha2.ServicemeshV1alpha2Client
storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client
......@@ -110,6 +113,11 @@ func (c *Clientset) NetworkV1alpha1() networkv1alpha1.NetworkV1alpha1Interface {
return c.networkV1alpha1
}
// NotificationV2beta1 retrieves the NotificationV2beta1Client
func (c *Clientset) NotificationV2beta1() notificationv2beta1.NotificationV2beta1Interface {
return c.notificationV2beta1
}
// QuotaV1alpha2 retrieves the QuotaV1alpha2Client
func (c *Clientset) QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface {
return c.quotaV1alpha2
......@@ -189,6 +197,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.notificationV2beta1, err = notificationv2beta1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.quotaV1alpha2, err = quotav1alpha2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
......@@ -232,6 +244,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
cs.devopsV1alpha3 = devopsv1alpha3.NewForConfigOrDie(c)
cs.iamV1alpha2 = iamv1alpha2.NewForConfigOrDie(c)
cs.networkV1alpha1 = networkv1alpha1.NewForConfigOrDie(c)
cs.notificationV2beta1 = notificationv2beta1.NewForConfigOrDie(c)
cs.quotaV1alpha2 = quotav1alpha2.NewForConfigOrDie(c)
cs.servicemeshV1alpha2 = servicemeshv1alpha2.NewForConfigOrDie(c)
cs.storageV1alpha1 = storagev1alpha1.NewForConfigOrDie(c)
......@@ -253,6 +266,7 @@ func New(c rest.Interface) *Clientset {
cs.devopsV1alpha3 = devopsv1alpha3.New(c)
cs.iamV1alpha2 = iamv1alpha2.New(c)
cs.networkV1alpha1 = networkv1alpha1.New(c)
cs.notificationV2beta1 = notificationv2beta1.New(c)
cs.quotaV1alpha2 = quotav1alpha2.New(c)
cs.servicemeshV1alpha2 = servicemeshv1alpha2.New(c)
cs.storageV1alpha1 = storagev1alpha1.New(c)
......
......@@ -39,6 +39,8 @@ import (
fakeiamv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/iam/v1alpha2/fake"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/network/v1alpha1"
fakenetworkv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/network/v1alpha1/fake"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1"
fakenotificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1/fake"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2"
fakequotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2/fake"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
......@@ -135,6 +137,11 @@ func (c *Clientset) NetworkV1alpha1() networkv1alpha1.NetworkV1alpha1Interface {
return &fakenetworkv1alpha1.FakeNetworkV1alpha1{Fake: &c.Fake}
}
// NotificationV2beta1 retrieves the NotificationV2beta1Client
func (c *Clientset) NotificationV2beta1() notificationv2beta1.NotificationV2beta1Interface {
return &fakenotificationv2beta1.FakeNotificationV2beta1{Fake: &c.Fake}
}
// QuotaV1alpha2 retrieves the QuotaV1alpha2Client
func (c *Clientset) QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface {
return &fakequotav1alpha2.FakeQuotaV1alpha2{Fake: &c.Fake}
......
......@@ -31,6 +31,7 @@ import (
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
iamv1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/apis/network/v1alpha1"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/apis/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/kubesphere/pkg/apis/storage/v1alpha1"
......@@ -50,6 +51,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
devopsv1alpha3.AddToScheme,
iamv1alpha2.AddToScheme,
networkv1alpha1.AddToScheme,
notificationv2beta1.AddToScheme,
quotav1alpha2.AddToScheme,
servicemeshv1alpha2.AddToScheme,
storagev1alpha1.AddToScheme,
......
......@@ -31,6 +31,7 @@ import (
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
iamv1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/apis/network/v1alpha1"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/apis/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/kubesphere/pkg/apis/storage/v1alpha1"
......@@ -50,6 +51,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
devopsv1alpha3.AddToScheme,
iamv1alpha2.AddToScheme,
networkv1alpha1.AddToScheme,
notificationv2beta1.AddToScheme,
quotav1alpha2.AddToScheme,
servicemeshv1alpha2.AddToScheme,
storagev1alpha1.AddToScheme,
......
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2beta1
import (
"context"
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v2beta1 "kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// ConfigsGetter has a method to return a ConfigInterface.
// A group's client should implement this interface.
type ConfigsGetter interface {
Configs() ConfigInterface
}
// ConfigInterface has methods to work with Config resources.
type ConfigInterface interface {
Create(ctx context.Context, config *v2beta1.Config, opts v1.CreateOptions) (*v2beta1.Config, error)
Update(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (*v2beta1.Config, error)
UpdateStatus(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (*v2beta1.Config, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v2beta1.Config, error)
List(ctx context.Context, opts v1.ListOptions) (*v2beta1.ConfigList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.Config, err error)
ConfigExpansion
}
// configs implements ConfigInterface
type configs struct {
client rest.Interface
}
// newConfigs returns a Configs
func newConfigs(c *NotificationV2beta1Client) *configs {
return &configs{
client: c.RESTClient(),
}
}
// Get takes name of the config, and returns the corresponding config object, and an error if there is any.
func (c *configs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.Config, err error) {
result = &v2beta1.Config{}
err = c.client.Get().
Resource("configs").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of Configs that match those selectors.
func (c *configs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.ConfigList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2beta1.ConfigList{}
err = c.client.Get().
Resource("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested configs.
func (c *configs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a config and creates it. Returns the server's representation of the config, and an error, if there is any.
func (c *configs) Create(ctx context.Context, config *v2beta1.Config, opts v1.CreateOptions) (result *v2beta1.Config, err error) {
result = &v2beta1.Config{}
err = c.client.Post().
Resource("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a config and updates it. Returns the server's representation of the config, and an error, if there is any.
func (c *configs) Update(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (result *v2beta1.Config, err error) {
result = &v2beta1.Config{}
err = c.client.Put().
Resource("configs").
Name(config.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *configs) UpdateStatus(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (result *v2beta1.Config, err error) {
result = &v2beta1.Config{}
err = c.client.Put().
Resource("configs").
Name(config.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
Do(ctx).
Into(result)
return
}
// Delete takes name of the config and deletes it. Returns an error if one occurs.
func (c *configs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("configs").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *configs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("configs").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched config.
func (c *configs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.Config, err error) {
result = &v2beta1.Config{}
err = c.client.Patch(pt).
Resource("configs").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v2beta1
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v2beta1 "kubesphere.io/kubesphere/pkg/apis/notification/v2beta1"
)
// FakeConfigs implements ConfigInterface
type FakeConfigs struct {
Fake *FakeNotificationV2beta1
}
var configsResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta1", Resource: "configs"}
var configsKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta1", Kind: "Config"}
// Get takes name of the config, and returns the corresponding config object, and an error if there is any.
func (c *FakeConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(configsResource, name), &v2beta1.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta1.Config), err
}
// List takes label and field selectors, and returns the list of Configs that match those selectors.
func (c *FakeConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.ConfigList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(configsResource, configsKind, opts), &v2beta1.ConfigList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta1.ConfigList{ListMeta: obj.(*v2beta1.ConfigList).ListMeta}
for _, item := range obj.(*v2beta1.ConfigList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested configs.
func (c *FakeConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(configsResource, opts))
}
// Create takes the representation of a config and creates it. Returns the server's representation of the config, and an error, if there is any.
func (c *FakeConfigs) Create(ctx context.Context, config *v2beta1.Config, opts v1.CreateOptions) (result *v2beta1.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(configsResource, config), &v2beta1.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta1.Config), err
}
// Update takes the representation of a config and updates it. Returns the server's representation of the config, and an error, if there is any.
func (c *FakeConfigs) Update(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (result *v2beta1.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(configsResource, config), &v2beta1.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta1.Config), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeConfigs) UpdateStatus(ctx context.Context, config *v2beta1.Config, opts v1.UpdateOptions) (*v2beta1.Config, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(configsResource, "status", config), &v2beta1.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta1.Config), err
}
// Delete takes name of the config and deletes it. Returns an error if one occurs.
func (c *FakeConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(configsResource, name), &v2beta1.Config{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(configsResource, listOpts)
_, err := c.Fake.Invokes(action, &v2beta1.ConfigList{})
return err
}
// Patch applies the patch and returns the patched config.
func (c *FakeConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(configsResource, name, pt, data, subresources...), &v2beta1.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta1.Config), err
}
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1"
)
type FakeNotificationV2beta1 struct {
*testing.Fake
}
func (c *FakeNotificationV2beta1) Configs() v2beta1.ConfigInterface {
return &FakeConfigs{c}
}
func (c *FakeNotificationV2beta1) Receivers() v2beta1.ReceiverInterface {
return &FakeReceivers{c}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeNotificationV2beta1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
此差异已折叠。
此差异已折叠。
......@@ -125,6 +125,9 @@ const (
ApplicationName = "app.kubernetes.io/name"
ApplicationVersion = "app.kubernetes.io/version"
AlertingTag = "Alerting"
NotificationTag = "Notification"
NotificationSecretNamespace = "kubesphere-monitoring-federated"
)
var (
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册