Skip to content

Commit

Permalink
Merge ef21704 into 7554db9
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavPage committed Mar 13, 2019
2 parents 7554db9 + ef21704 commit 1b293a0
Show file tree
Hide file tree
Showing 83 changed files with 770 additions and 669 deletions.
2 changes: 1 addition & 1 deletion controllers/gateway/operator.go
Expand Up @@ -141,7 +141,7 @@ func (goc *gwOperationCtx) createGatewayResources() error {
goc.log.Info().Str("pod-name", pod.Name).Msg("gateway pod is created")

// expose gateway if service is configured
if goc.gw.Spec.ServiceSpec != nil {
if goc.gw.Spec.Service != nil {
svc, err := goc.createGatewayService()
if err != nil {
err = errors.Wrap(err, "failed to create gateway service")
Expand Down
12 changes: 6 additions & 6 deletions controllers/gateway/operator_test.go
Expand Up @@ -45,7 +45,7 @@ spec:
url: "nats://nats.argo-events:4222"
type: "Standard"
eventVersion: "1.0"
deploySpec:
template:
metadata:
name: "webhook-gateway"
labels:
Expand All @@ -61,7 +61,7 @@ spec:
imagePullPolicy: "Always"
command: ["/bin/webhook-gateway"]
serviceAccountName: "argo-events-sa"
serviceSpec:
service:
metadata:
name: webhook-gateway-svc
spec:
Expand Down Expand Up @@ -218,8 +218,8 @@ func TestGatewayOperateLifecycle(t *testing.T) {
})

convey.Convey("Change pod and service spec", func() {
goc.gwrctx.gw.Spec.DeploySpec.Spec.RestartPolicy = "Never"
goc.gwrctx.gw.Spec.ServiceSpec.Spec.ClusterIP = "127.0.0.1"
goc.gwrctx.gw.Spec.Template.Spec.RestartPolicy = "Never"
goc.gwrctx.gw.Spec.Service.Spec.ClusterIP = "127.0.0.1"

gatewayPod, gatewaySvc, err := getPodAndService(fakeController, gateway.Namespace)
convey.So(err, convey.ShouldBeNil)
Expand Down Expand Up @@ -315,8 +315,8 @@ func TestGatewayOperateLifecycle(t *testing.T) {
})

convey.Convey("Change pod and service spec", func() {
goc.gwrctx.gw.Spec.DeploySpec.Spec.RestartPolicy = "Never"
goc.gwrctx.gw.Spec.ServiceSpec.Spec.ClusterIP = "127.0.0.1"
goc.gwrctx.gw.Spec.Template.Spec.RestartPolicy = "Never"
goc.gwrctx.gw.Spec.Service.Spec.ClusterIP = "127.0.0.1"

gatewayPod, gatewaySvc, err := getPodAndService(fakeController, gateway.Namespace)
convey.So(err, convey.ShouldBeNil)
Expand Down
4 changes: 2 additions & 2 deletions controllers/gateway/resource.go
Expand Up @@ -71,7 +71,7 @@ func (grc *gwResourceCtx) getGatewayService() (*corev1.Service, error) {

// newGatewayService returns a new service that exposes gateway.
func (grc *gwResourceCtx) newGatewayService() (*corev1.Service, error) {
servicTemplateSpec := grc.gw.Spec.ServiceSpec.DeepCopy()
servicTemplateSpec := grc.gw.Spec.Service.DeepCopy()
if servicTemplateSpec == nil {
return nil, nil
}
Expand Down Expand Up @@ -117,7 +117,7 @@ func (grc *gwResourceCtx) deleteGatewayPod(pod *corev1.Pod) error {

// newGatewayPod returns a new pod of gateway
func (grc *gwResourceCtx) newGatewayPod() (*corev1.Pod, error) {
podTemplateSpec := grc.gw.Spec.DeploySpec.DeepCopy()
podTemplateSpec := grc.gw.Spec.Template.DeepCopy()
pod := &corev1.Pod{
ObjectMeta: podTemplateSpec.ObjectMeta,
Spec: podTemplateSpec.Spec,
Expand Down
4 changes: 2 additions & 2 deletions controllers/gateway/validate.go
Expand Up @@ -25,8 +25,8 @@ import (
// Validate validates the gateway resource.
// Exporting this function so that external APIs can use this to validate gateway resource.
func Validate(gw *v1alpha1.Gateway) error {
if gw.Spec.DeploySpec == nil {
return fmt.Errorf("gateway deploy specification is not specified")
if gw.Spec.Template == nil {
return fmt.Errorf("gateway pod template is not specified")
}
if gw.Spec.Type == "" {
return fmt.Errorf("gateway type is not specified")
Expand Down
8 changes: 4 additions & 4 deletions controllers/sensor/operator.go
Expand Up @@ -98,7 +98,7 @@ func (soc *sOperationCtx) operate() error {
}

case v1alpha1.NodePhaseActive:
soc.log.Info().Msg("sensor is running")
soc.log.Debug().Msg("sensor is running")

err := soc.updateSensorResources()
if err != nil {
Expand All @@ -120,15 +120,15 @@ func (soc *sOperationCtx) createSensorResources() error {
err := ValidateSensor(soc.s)
if err != nil {
soc.log.Error().Err(err).Msg("failed to validate sensor")
errors.Wrap(err, "failed to validate sensor")
err = errors.Wrap(err, "failed to validate sensor")
soc.markSensorPhase(v1alpha1.NodePhaseError, false, err.Error())
return err
}

soc.initializeAllNodes()
pod, err := soc.createSensorPod()
if err != nil {
errors.Wrap(err, "failed to create sensor pod")
err = errors.Wrap(err, "failed to create sensor pod")
soc.markSensorPhase(v1alpha1.NodePhaseError, false, err.Error())
return err
}
Expand All @@ -139,7 +139,7 @@ func (soc *sOperationCtx) createSensorResources() error {
if soc.srctx.getServiceTemplateSpec() != nil {
svc, err := soc.createSensorService()
if err != nil {
errors.Wrap(err, "failed to create sensor service")
err = errors.Wrap(err, "failed to create sensor service")
soc.markSensorPhase(v1alpha1.NodePhaseError, false, err.Error())
return err
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/sensor/operator_test.go
Expand Up @@ -36,10 +36,10 @@ metadata:
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
deploySpec:
template:
containers:
- name: "sensor"
image: "argoproj/sensor:v0.7"
image: "argoproj/sensor"
imagePullPolicy: Always
serviceAccountName: argo-events-sa
dependencies:
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestSensorOperations(t *testing.T) {
})

convey.Convey("Change pod and service spec", func() {
soc.srctx.s.Spec.DeploySpec.Spec.RestartPolicy = "Never"
soc.srctx.s.Spec.Template.Spec.RestartPolicy = "Never"
soc.srctx.s.Spec.EventProtocol.Http.Port = "1234"

sensorPod, sensorSvc, err := getPodAndService(controller, sensor.Namespace)
Expand Down Expand Up @@ -335,7 +335,7 @@ func TestSensorOperations(t *testing.T) {
})

convey.Convey("Change pod and service spec", func() {
soc.srctx.s.Spec.DeploySpec.Spec.RestartPolicy = "Never"
soc.srctx.s.Spec.Template.Spec.RestartPolicy = "Never"
soc.srctx.s.Spec.EventProtocol.Http.Port = "1234"

sensorPod, sensorSvc, err := getPodAndService(controller, sensor.Namespace)
Expand Down
2 changes: 1 addition & 1 deletion controllers/sensor/resource.go
Expand Up @@ -119,7 +119,7 @@ func (src *sResourceCtx) deleteSensorPod(pod *corev1.Pod) error {

// newSensorPod returns a new pod of sensor
func (src *sResourceCtx) newSensorPod() (*corev1.Pod, error) {
podTemplateSpec := src.s.Spec.DeploySpec.DeepCopy()
podTemplateSpec := src.s.Spec.Template.DeepCopy()
pod := &corev1.Pod{
ObjectMeta: podTemplateSpec.ObjectMeta,
Spec: podTemplateSpec.Spec,
Expand Down
5 changes: 4 additions & 1 deletion controllers/sensor/validate.go
Expand Up @@ -39,7 +39,10 @@ func ValidateSensor(s *v1alpha1.Sensor) error {
if err != nil {
return err
}
if len(s.Spec.DeploySpec.Spec.Containers) > 1 {
if s.Spec.Template == nil {
return fmt.Errorf("sensor pod template not defined")
}
if len(s.Spec.Template.Spec.Containers) > 1 {
return fmt.Errorf("sensor pod specification can't have more than one container")
}
switch s.Spec.EventProtocol.Type {
Expand Down
4 changes: 2 additions & 2 deletions docs/gateway-protocol.md
Expand Up @@ -91,11 +91,11 @@ GatewaySpec represents gateway specifications

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| deploySpec | [k8s.io.api.core.v1.Pod](#k8s.io.api.core.v1.Pod) | optional | DeploySpec is the pod specification for the gateway Refer https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#pod-v1-core |
| deploySpec | [k8s.io.api.core.v1.Pod](#k8s.io.api.core.v1.Pod) | optional | Template is the pod specification for the gateway Refer https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#pod-v1-core |
| configmap | [string](#string) | optional | ConfigMap is name of the configmap for gateway. This configmap contains event sources. |
| type | [string](#string) | optional | Type is the type of gateway. Used as metadata. |
| eventVersion | [string](#string) | optional | Version is used for marking event version |
| serviceSpec | [k8s.io.api.core.v1.Service](#k8s.io.api.core.v1.Service) | optional | ServiceSpec is the specifications of the service to expose the gateway Refer https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#service-v1-core |
| serviceSpec | [k8s.io.api.core.v1.Service](#k8s.io.api.core.v1.Service) | optional | Service is the specifications of the service to expose the gateway Refer https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#service-v1-core |
| watchers | [NotificationWatchers](#github.com.argoproj.argo_events.pkg.apis.gateway.v1alpha1.NotificationWatchers) | optional | Watchers are components which are interested listening to notifications from this gateway These only need to be specified when gateway dispatch mechanism is through HTTP POST notifications. In future, support for NATS, KAFKA will be added as a means to dispatch notifications in which case specifying watchers would be unnecessary. |
| processorPort | [string](#string) | optional | Port on which the gateway event source processor is running on. |
| eventProtocol | [github.com.argoproj.argo_events.pkg.apis.common.EventProtocol](#github.com.argoproj.argo_events.pkg.apis.common.EventProtocol) | optional | EventProtocol is the underlying protocol used to send events from gateway to watchers(components interested in listening to event from this gateway) |
Expand Down
2 changes: 1 addition & 1 deletion docs/sensor-protocol.md
Expand Up @@ -334,7 +334,7 @@ SensorSpec represents desired sensor state
| ----- | ---- | ----- | ----------- |
| dependencies | [EventDependency](#github.com.argoproj.argo_events.pkg.apis.sensor.v1alpha1.EventDependency) | repeated | Dependencies is a list of the events that this sensor is dependent on. |
| triggers | [Trigger](#github.com.argoproj.argo_events.pkg.apis.sensor.v1alpha1.Trigger) | repeated | Triggers is a list of the things that this sensor evokes. These are the outputs from this sensor. |
| deploySpec | [k8s.io.api.core.v1.PodSpec](#k8s.io.api.core.v1.PodSpec) | optional | DeploySpec contains sensor pod specification. For more information, read https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#pod-v1-core |
| deploySpec | [k8s.io.api.core.v1.PodSpec](#k8s.io.api.core.v1.PodSpec) | optional | Template contains sensor pod specification. For more information, read https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#pod-v1-core |
| eventProtocol | [github.com.argoproj.argo_events.pkg.apis.common.EventProtocol](#github.com.argoproj.argo_events.pkg.apis.common.EventProtocol) | optional | EventProtocol is the protocol through which sensor receives events from gateway |
| circuit | [string](#string) | optional | Circuit is a boolean expression of dependency groups |
| dependencyGroups | [DependencyGroup](#github.com.argoproj.argo_events.pkg.apis.sensor.v1alpha1.DependencyGroup) | repeated | DependencyGroups is a list of the groups of events. |
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/amqp.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "amqp-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/artifact-http.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "artifact-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/artifact-nats-standard.yaml
Expand Up @@ -12,7 +12,7 @@ spec:
nats:
url: "nats://example-nats.argo-events:4222"
type: "Standard"
deploySpec:
template:
metadata:
name: "artifact-gateway-nats-standard"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/artifact-nats-streaming.yaml
Expand Up @@ -14,7 +14,7 @@ spec:
clusterId: "example-stan"
clientId: "myclient"
type: "Streaming"
deploySpec:
template:
metadata:
name: "artifact-gateway-nats-streaming"
labels:
Expand Down
4 changes: 2 additions & 2 deletions examples/gateways/aws-sns.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "aws-sns-gateway"
labels:
Expand All @@ -27,7 +27,7 @@ spec:
imagePullPolicy: "Always"
command: ["/bin/aws-sns-gateway"]
serviceAccountName: "argo-events-sa"
serviceSpec:
service:
metadata:
name: aws-sns-gateway-svc
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/aws-sqs.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "aws-sqs-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/calendar.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "calendar-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/file.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "file-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/gcp-pubsub.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "gcp-pubsub-gateway"
labels:
Expand Down
4 changes: 2 additions & 2 deletions examples/gateways/github.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "github-gateway"
labels:
Expand All @@ -27,7 +27,7 @@ spec:
imagePullPolicy: "Always"
command: ["/bin/github-gateway"]
serviceAccountName: "argo-events-sa"
serviceSpec:
service:
metadata:
name: github-gateway-svc
spec:
Expand Down
4 changes: 2 additions & 2 deletions examples/gateways/gitlab.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "gitlab-gateway"
labels:
Expand All @@ -27,7 +27,7 @@ spec:
imagePullPolicy: "Always"
command: ["/bin/gitlab-gateway"]
serviceAccountName: "argo-events-sa"
serviceSpec:
service:
metadata:
name: gitlab-gateway-svc
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/hdfs.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "hdfs-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/kafka.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "kafka-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/mqtt.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "mqtt-gateway"
labels:
Expand Down
4 changes: 2 additions & 2 deletions examples/gateways/multi-watchers.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "webhook-gateway"
labels:
Expand All @@ -30,7 +30,7 @@ spec:
configMap: "webhook-gateway-configmap"
type: "webhook"
eventVersion: "1.0"
serviceSpec:
service:
metadata:
name: webhook-gateway-svc
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/nats.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "nats-gateway"
labels:
Expand Down
2 changes: 1 addition & 1 deletion examples/gateways/resource.yaml
Expand Up @@ -11,7 +11,7 @@ spec:
type: "HTTP"
http:
port: "9300"
deploySpec:
template:
metadata:
name: "resource-gateway"
labels:
Expand Down
4 changes: 2 additions & 2 deletions examples/gateways/secure-webhook.yaml
Expand Up @@ -14,7 +14,7 @@ spec:
http:
port: "9300"
eventVersion: "1.0"
deploySpec:
template:
metadata:
name: "webhook-gateway-http"
labels:
Expand All @@ -39,7 +39,7 @@ spec:
secret:
secretName: cert-and-key-secret
serviceAccountName: "argo-events-sa"
serviceSpec:
service:
metadata:
name: webhook-gateway-svc
spec:
Expand Down

0 comments on commit 1b293a0

Please sign in to comment.