diff --git a/VERSION b/VERSION index 8294c18436..8adc70fdd9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.2 \ No newline at end of file +0.8.0 \ No newline at end of file diff --git a/common/common.go b/common/common.go index de3f91d55f..606e7e1eb7 100644 --- a/common/common.go +++ b/common/common.go @@ -125,7 +125,7 @@ const ( // LabelGatewayEventSourceID is the label for gateway configuration ID LabelGatewayEventSourceID = "event-source-id" - // Server Connection Timeout, 5 seconds + // Server Connection Timeout, 10 seconds ServerConnTimeout = 10 ) diff --git a/controllers/gateway/informer.go b/controllers/gateway/informer.go index 86879e8bd4..d7ee0883c7 100644 --- a/controllers/gateway/informer.go +++ b/controllers/gateway/informer.go @@ -13,6 +13,7 @@ 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 gateway import ( diff --git a/controllers/gateway/state.go b/controllers/gateway/state.go index d853d53b7b..ed7d54a75c 100644 --- a/controllers/gateway/state.go +++ b/controllers/gateway/state.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) -// persist the updates to the gateway resource +// PersistUpdates of the gateway resource func PersistUpdates(client gwclient.Interface, gw *v1alpha1.Gateway, log *zerolog.Logger) (*v1alpha1.Gateway, error) { gatewayClient := client.ArgoprojV1alpha1().Gateways(gw.ObjectMeta.Namespace) @@ -23,7 +23,7 @@ func PersistUpdates(client gwclient.Interface, gw *v1alpha1.Gateway, log *zerolo return oldgw, err } log.Info().Msg("re-applying updates on latest version and retrying update") - err = ReapplyUpdate(client, gw) + err = ReapplyUpdates(client, gw) if err != nil { log.Error().Err(err).Msg("failed to re-apply update") return oldgw, err @@ -33,8 +33,8 @@ func PersistUpdates(client gwclient.Interface, gw *v1alpha1.Gateway, log *zerolo return gw, nil } -// reapply the updates to gateway resource -func ReapplyUpdate(client gwclient.Interface, gw *v1alpha1.Gateway) error { +// ReapplyUpdates to gateway resource +func ReapplyUpdates(client gwclient.Interface, gw *v1alpha1.Gateway) error { return wait.ExponentialBackoff(common.DefaultRetry, func() (bool, error) { gatewayClient := client.ArgoprojV1alpha1().Gateways(gw.Namespace) g, err := gatewayClient.Update(gw) diff --git a/gateways/common/doc.go b/gateways/common/doc.go index 3e9999cea6..f333b2d6dd 100644 --- a/gateways/common/doc.go +++ b/gateways/common/doc.go @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package contains structs and methods that are shared across different gateways. +// Package common contains structs and methods that are shared across different gateways. package common diff --git a/gateways/common/webhook.go b/gateways/common/webhook.go index 59b392497a..580cc6dbe9 100644 --- a/gateways/common/webhook.go +++ b/gateways/common/webhook.go @@ -42,9 +42,10 @@ type Webhook struct { ServerCertPath string `json:"serverCertPath,omitempty" protobuf:"bytes,4,opt,name=serverCertPath"` // ServerKeyPath refers the file that contains private key ServerKeyPath string `json:"serverKeyPath,omitempty" protobuf:"bytes,5,opt,name=serverKeyPath"` + // srv holds reference to http server - srv *http.Server `json:"srv,omitempty"` - mux *http.ServeMux `json:"mux,omitempty"` + srv *http.Server + mux *http.ServeMux } // WebhookHelper is a helper struct @@ -72,7 +73,7 @@ type activeServer struct { errChan chan error } -// RouteConfig contains configuration about a http route +// RouteConfig contains configuration about an http route type RouteConfig struct { Webhook *Webhook Configs map[string]interface{} diff --git a/gateways/community/aws-sns/config.go b/gateways/community/aws-sns/config.go index 805fef3ea6..64c2832336 100644 --- a/gateways/community/aws-sns/config.go +++ b/gateways/community/aws-sns/config.go @@ -17,9 +17,10 @@ limitations under the License. package aws_sns import ( + "time" + "github.com/argoproj/argo-events/gateways/common" "k8s.io/client-go/kubernetes" - "time" "github.com/ghodss/yaml" "github.com/rs/zerolog" @@ -27,8 +28,8 @@ import ( ) const ( - MESSAGE_TYPE_SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation" - MESSAGE_TYPE_NOTIFICATION = "Notification" + messageTypeSubscriptionConfirmation = "SubscriptionConfirmation" + messageTypeNotification = "Notification" ) var ( diff --git a/gateways/community/aws-sns/start.go b/gateways/community/aws-sns/start.go index bd0e49e091..6cc067b5d0 100644 --- a/gateways/community/aws-sns/start.go +++ b/gateways/community/aws-sns/start.go @@ -33,9 +33,9 @@ import ( ) const ( - LabelSNSConfig = "snsConfig" - LabelSNSSession = "snsSession" - LabelSubscriptionArn = "subscriptionArn" + labelSNSConfig = "snsConfig" + labelSNSSession = "snsSession" + labelSubscriptionArn = "subscriptionArn" ) var ( @@ -46,7 +46,7 @@ func init() { go gwcommon.InitRouteChannels(helper) } -// routeActiveHandler handles new route +// RouteActiveHandler handles new routes func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *gwcommon.RouteConfig) { var response string @@ -76,11 +76,11 @@ func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *g return } - sc := rc.Configs[LabelSNSConfig].(*snsConfig) + sc := rc.Configs[labelSNSConfig].(*snsConfig) switch snspayload.Type { - case MESSAGE_TYPE_SUBSCRIPTION_CONFIRMATION: - awsSession := rc.Configs[LabelSNSSession].(*snslib.SNS) + case messageTypeSubscriptionConfirmation: + awsSession := rc.Configs[labelSNSSession].(*snslib.SNS) out, err := awsSession.ConfirmSubscription(&snslib.ConfirmSubscriptionInput{ TopicArn: &sc.TopicArn, Token: &snspayload.Token, @@ -89,9 +89,9 @@ func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *g logger.Error().Err(err).Msg("failed to send confirmation response to amazon") return } - rc.Configs[LabelSubscriptionArn] = out.SubscriptionArn + rc.Configs[labelSubscriptionArn] = out.SubscriptionArn - case MESSAGE_TYPE_NOTIFICATION: + case messageTypeNotification: helper.ActiveEndpoints[rc.Webhook.Endpoint].DataCh <- body } @@ -100,11 +100,12 @@ func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *g common.SendSuccessResponse(writer, response) } +// PostActivate subscribes to the sns topic func (ese *SNSEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) error { logger := rc.Log.With().Str("event-source", rc.EventSource.Name).Str("endpoint", rc.Webhook.Endpoint). Str("port", rc.Webhook.Port).Logger() - sc := rc.Configs[LabelSNSConfig].(*snsConfig) + sc := rc.Configs[labelSNSConfig].(*snsConfig) // retrieve access key id and secret access key accessKey, err := store.GetSecrets(ese.Clientset, ese.Namespace, sc.AccessKey.Name, sc.AccessKey.Key) if err != nil { @@ -135,7 +136,7 @@ func (ese *SNSEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) error } snsSession := snslib.New(awsSession) - rc.Configs[LabelSNSSession] = snsSession + rc.Configs[labelSNSSession] = snsSession logger.Info().Msg("subscribing to snsConfig topic") if _, err := snsSession.Subscribe(&snslib.SubscribeInput{ @@ -150,11 +151,11 @@ func (ese *SNSEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) error return nil } -// PostStop unsubscribes the topic +// PostStop unsubscribes from the sns topic func PostStop(rc *gwcommon.RouteConfig) error { - awsSession := rc.Configs[LabelSNSSession].(*snslib.SNS) + awsSession := rc.Configs[labelSNSSession].(*snslib.SNS) if _, err := awsSession.Unsubscribe(&snslib.UnsubscribeInput{ - SubscriptionArn: rc.Configs[LabelSubscriptionArn].(*string), + SubscriptionArn: rc.Configs[labelSubscriptionArn].(*string), }); err != nil { rc.Log.Error().Err(err).Str("event-source-name", rc.EventSource.Name).Msg("failed to unsubscribe") return err @@ -162,7 +163,7 @@ func PostStop(rc *gwcommon.RouteConfig) error { return nil } -// StartConfig runs a configuration +// StartEventSource starts an SNS event source func (ese *SNSEventSourceExecutor) StartEventSource(eventSource *gateways.EventSource, eventStream gateways.Eventing_StartEventSourceServer) error { defer gateways.Recover(eventSource.Name) @@ -177,7 +178,7 @@ func (ese *SNSEventSourceExecutor) StartEventSource(eventSource *gateways.EventS return gwcommon.ProcessRoute(&gwcommon.RouteConfig{ Webhook: sc.Hook, Configs: map[string]interface{}{ - LabelSNSConfig: sc, + labelSNSConfig: sc, }, Log: ese.Log, EventSource: eventSource, diff --git a/gateways/community/gcp-pubsub/start.go b/gateways/community/gcp-pubsub/start.go index 33dab786b5..14f00aa9f6 100644 --- a/gateways/community/gcp-pubsub/start.go +++ b/gateways/community/gcp-pubsub/start.go @@ -17,17 +17,13 @@ limitations under the License. package pubsub import ( - "cloud.google.com/go/pubsub" "context" + + "cloud.google.com/go/pubsub" "github.com/argoproj/argo-events/gateways" "google.golang.org/api/option" ) -const ( - // LabelGcpPubSubConfig is the label name of the GCP PubSub Config - LabelGcpPubSubConfig = "pubSubConfig" -) - // StartEventSource starts the GCP PubSub Gateway func (ese *GcpPubSubEventSourceExecutor) StartEventSource(eventSource *gateways.EventSource, eventStream gateways.Eventing_StartEventSourceServer) error { defer gateways.Recover(eventSource.Name) diff --git a/gateways/community/github/start.go b/gateways/community/github/start.go index 809860f479..db73655829 100644 --- a/gateways/community/github/start.go +++ b/gateways/community/github/start.go @@ -37,15 +37,15 @@ import ( ) const ( - LabelGithubConfig = "config" - LabelGithubClient = "client" - LabelWebhook = "hook" + labelGithubConfig = "config" + labelGithubClient = "client" + labelWebhook = "hook" ) const ( - GithubSignatureHeader = "x-hub-signature" - GithubEventHeader = "x-github-event" - GithubDeliveryHeader = "x-github-delivery" + githubSignatureHeader = "x-hub-signature" + githubEventHeader = "x-github-event" + githubDeliveryHeader = "x-github-delivery" ) var ( @@ -68,7 +68,7 @@ func (ese *GithubEventSourceExecutor) getCredentials(gs *corev1.SecretKeySelecto } func (ese *GithubEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) error { - gc := rc.Configs[LabelGithubConfig].(*githubConfig) + gc := rc.Configs[labelGithubConfig].(*githubConfig) c, err := ese.getCredentials(gc.APIToken) if err != nil { @@ -109,26 +109,27 @@ func (ese *GithubEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) err } client := gh.NewClient(PATTransport.Client()) - rc.Configs[LabelGithubClient] = client - - ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) + rc.Configs[labelGithubClient] = client + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() hook, _, err := client.Repositories.CreateHook(ctx, gc.Owner, gc.Repository, hookSetup) if err != nil { return fmt.Errorf("failed to create webhook. err: %+v", err) } - rc.Configs[LabelWebhook] = hook + rc.Configs[labelWebhook] = hook ese.Log.Info().Str("event-source-name", rc.EventSource.Name).Interface("hook-id", *hook.ID).Msg("github hook created") return nil } func PostStop(rc *gwcommon.RouteConfig) error { - gc := rc.Configs[LabelGithubConfig].(*githubConfig) - client := rc.Configs[LabelGithubClient].(*gh.Client) - hook := rc.Configs[LabelWebhook].(*gh.Hook) + gc := rc.Configs[labelGithubConfig].(*githubConfig) + client := rc.Configs[labelGithubClient].(*gh.Client) + hook := rc.Configs[labelWebhook].(*gh.Hook) - ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() if _, err := client.Repositories.DeleteHook(ctx, gc.Owner, gc.Repository, *hook.ID); err != nil { rc.Log.Error().Err(err).Str("event-source-name", rc.EventSource.Name).Msg("failed to delete github hook") return err @@ -151,7 +152,7 @@ func (ese *GithubEventSourceExecutor) StartEventSource(eventSource *gateways.Eve return gwcommon.ProcessRoute(&gwcommon.RouteConfig{ Webhook: gc.Hook, Configs: map[string]interface{}{ - LabelGithubConfig: gc, + labelGithubConfig: gc, }, Log: ese.Log, EventSource: eventSource, @@ -183,16 +184,16 @@ func verifySignature(secret []byte, signature string, body []byte) bool { } func validatePayload(secret []byte, headers http.Header, body []byte) error { - signature := headers.Get(GithubSignatureHeader) + signature := headers.Get(githubSignatureHeader) if len(signature) == 0 { return errors.New("no x-hub-signature header found") } - if event := headers.Get(GithubEventHeader); len(event) == 0 { + if event := headers.Get(githubEventHeader); len(event) == 0 { return errors.New("no x-github-event header found") } - if id := headers.Get(GithubDeliveryHeader); len(id) == 0 { + if id := headers.Get(githubDeliveryHeader); len(id) == 0 { return errors.New("no x-github-delivery header found") } @@ -225,7 +226,7 @@ func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *g return } - hook := rc.Configs[LabelWebhook].(*gh.Hook) + hook := rc.Configs[labelWebhook].(*gh.Hook) if secret, ok := hook.Config["secret"]; ok { if err := validatePayload([]byte(secret.(string)), request.Header, body); err != nil { logger.Error().Err(err).Msg("request is not valid event notification") diff --git a/gateways/community/gitlab/start.go b/gateways/community/gitlab/start.go index 78e397ac77..f771806620 100644 --- a/gateways/community/gitlab/start.go +++ b/gateways/community/gitlab/start.go @@ -30,9 +30,9 @@ import ( ) const ( - LabelGitlabConfig = "config" - LabelGitlabClient = "client" - LabelWebhook = "hook" + labelGitlabConfig = "config" + labelGitlabClient = "client" + labelWebhook = "hook" ) var ( @@ -55,7 +55,7 @@ func (ese *GitlabEventSourceExecutor) getCredentials(gs *GitlabSecret) (*cred, e } func (ese *GitlabEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) error { - gl := rc.Configs[LabelGitlabConfig].(*glab) + gl := rc.Configs[labelGitlabConfig].(*glab) c, err := ese.getCredentials(gl.AccessToken) if err != nil { @@ -67,7 +67,7 @@ func (ese *GitlabEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) err return fmt.Errorf("failed to set gitlab base url, err: %+v", err) } - rc.Configs[LabelGitlabClient] = client + rc.Configs[labelGitlabClient] = client formattedUrl := gwcommon.GenerateFormattedURL(gl.Hook) @@ -90,16 +90,16 @@ func (ese *GitlabEventSourceExecutor) PostActivate(rc *gwcommon.RouteConfig) err if err != nil { return fmt.Errorf("failed to add project hook. err: %+v", err) } - rc.Configs[LabelWebhook] = hook + rc.Configs[labelWebhook] = hook rc.Log.Info().Str("event-source-name", rc.EventSource.Name).Interface("hook-id", hook.ID).Msg("gitlab hook created") return nil } func PostStop(rc *gwcommon.RouteConfig) error { - gl := rc.Configs[LabelGitlabConfig].(*glab) - client := rc.Configs[LabelGitlabClient].(*gitlab.Client) - hook := rc.Configs[LabelWebhook].(*gitlab.ProjectHook) + gl := rc.Configs[labelGitlabConfig].(*glab) + client := rc.Configs[labelGitlabClient].(*gitlab.Client) + hook := rc.Configs[labelWebhook].(*gitlab.ProjectHook) if _, err := client.Projects.DeleteProjectHook(gl.ProjectId, hook.ID); err != nil { rc.Log.Error().Err(err).Str("event-source-name", rc.EventSource.Name).Interface("hook-id", hook.ID).Msg("failed to delete gitlab hook") @@ -153,7 +153,7 @@ func (ese *GitlabEventSourceExecutor) StartEventSource(eventSource *gateways.Eve return gwcommon.ProcessRoute(&gwcommon.RouteConfig{ Webhook: gl.Hook, Configs: map[string]interface{}{ - LabelGitlabConfig: gl, + labelGitlabConfig: gl, }, Log: ese.Log, EventSource: eventSource, diff --git a/gateways/community/slack/start.go b/gateways/community/slack/start.go index 954623a0b4..af614a726d 100644 --- a/gateways/community/slack/start.go +++ b/gateways/community/slack/start.go @@ -30,7 +30,7 @@ import ( ) const ( - LabelSlackToken = "slackToken" + labelSlackToken = "slackToken" ) var ( @@ -41,7 +41,7 @@ func init() { go gwcommon.InitRouteChannels(helper) } -// routeActiveHandler handles new route +// RouteActiveHandler handles new route func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *gwcommon.RouteConfig) { var response string @@ -65,7 +65,7 @@ func RouteActiveHandler(writer http.ResponseWriter, request *http.Request, rc *g } body := buf.String() - token := rc.Configs[LabelSlackToken] + token := rc.Configs[labelSlackToken] eventsAPIEvent, e := slackevents.ParseEvent(json.RawMessage(body), slackevents.OptionVerifyToken(&slackevents.TokenComparator{VerificationToken: token.(string)})) if e != nil { writer.WriteHeader(http.StatusInternalServerError) @@ -118,7 +118,7 @@ func (ese *SlackEventSourceExecutor) StartEventSource(eventSource *gateways.Even return gwcommon.ProcessRoute(&gwcommon.RouteConfig{ Webhook: sc.Hook, Configs: map[string]interface{}{ - LabelSlackToken: token, + labelSlackToken: token, }, Log: ese.Log, EventSource: eventSource, diff --git a/gateways/community/storagegrid/config.go b/gateways/community/storagegrid/config.go index caa08b6366..1fa565cce8 100644 --- a/gateways/community/storagegrid/config.go +++ b/gateways/community/storagegrid/config.go @@ -17,10 +17,11 @@ limitations under the License. package storagegrid import ( - "github.com/argoproj/argo-events/gateways/common" "net/http" "time" + "github.com/argoproj/argo-events/gateways/common" + "github.com/ghodss/yaml" "github.com/rs/zerolog" ) @@ -34,15 +35,18 @@ type StorageGridEventSourceExecutor struct { type storageGrid struct { // Webhook Hook *common.Webhook `json:"hook"` + // Events are s3 bucket notification events. // For more information on s3 notifications, follow https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations // Note that storage grid notifications do not contain `s3:` Events []string `json:"events,omitempty"` + // Filter on object key which caused the notification. Filter *Filter `json:"filter,omitempty"` + // srv holds reference to http server - srv *http.Server `json:"srv,omitempty"` - mux *http.ServeMux `json:"mux,omitempty"` + srv *http.Server + mux *http.ServeMux } // Filter represents filters to apply to bucket notifications for specifying constraints on objects diff --git a/gateways/event-sources.go b/gateways/event-sources.go index 282dee6dbe..2bdfd388e5 100644 --- a/gateways/event-sources.go +++ b/gateways/event-sources.go @@ -19,10 +19,11 @@ package gateways import ( "context" "fmt" - "github.com/argoproj/argo-events/pkg/apis/gateway" "io" "time" + "github.com/argoproj/argo-events/pkg/apis/gateway" + "github.com/argoproj/argo-events/common" "github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1" "google.golang.org/grpc" @@ -41,10 +42,14 @@ func (gc *GatewayConfig) createInternalEventSources(cm *corev1.ConfigMap) (map[s // create a connection to gateway server ctx, cancel := context.WithCancel(context.Background()) - timeoutCtx, _ := context.WithTimeout(context.Background(), common.ServerConnTimeout*time.Second) - conn, err := grpc.DialContext(timeoutCtx, fmt.Sprintf("localhost:%s", gc.serverPort), grpc.WithBlock(), grpc.WithInsecure()) + conn, err := grpc.Dial( + fmt.Sprintf("localhost:%s", gc.serverPort), + grpc.WithBlock(), + grpc.WithInsecure(), + grpc.WithTimeout(common.ServerConnTimeout*time.Second)) if err != nil { gc.Log.Panic().Err(err).Str("conn-state", conn.GetState().String()).Msg("failed to connect to gateway server") + cancel() return nil, err } gc.Log.Info().Str("state", conn.GetState().String()).Msg("state of the connection") diff --git a/gateways/watcher.go b/gateways/watcher.go index 6552fda1f2..159d4d40c2 100644 --- a/gateways/watcher.go +++ b/gateways/watcher.go @@ -19,6 +19,7 @@ package gateways import ( "context" "fmt" + "github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -86,7 +87,7 @@ func (gc *GatewayConfig) newConfigMapWatch(name string) *cache.ListWatch { return &cache.ListWatch{ListFunc: listFunc, WatchFunc: watchFunc} } -// WatchGatewayEventSources watches change in the gateway resource +// WatchGateway watches for changes in the gateway resource // This will act as replacement for old gateway-transformer-configmap. Changes to watchers, event version and event type will be reflected. func (gc *GatewayConfig) WatchGateway(ctx context.Context) (cache.Controller, error) { source := gc.newGatewayWatch(gc.Name) diff --git a/pkg/apis/common/s3.go b/pkg/apis/common/s3.go index f7428b27ea..085fd44288 100644 --- a/pkg/apis/common/s3.go +++ b/pkg/apis/common/s3.go @@ -33,7 +33,7 @@ type S3Artifact struct { Filter *S3Filter `json:"filter,omitempty" protobuf:"bytes,8,opt,name=filter"` } -// Name contains information for an S3 Name +// S3Bucket contains information to describe an S3 Bucket type S3Bucket struct { Key string `json:"key,omitempty" protobuf:"bytes,1,opt,name=key"` Name string `json:"name" protobuf:"bytes,2,opt,name=name"` diff --git a/pkg/apis/gateway/v1alpha1/doc.go b/pkg/apis/gateway/v1alpha1/doc.go index d80e42b8cf..3556a921ff 100644 --- a/pkg/apis/gateway/v1alpha1/doc.go +++ b/pkg/apis/gateway/v1alpha1/doc.go @@ -1,8 +1,3 @@ -// Package v1alpha1 is the v1alpha1 version of the API. -// +groupName=argoproj.io -// +k8s:deepcopy-gen=package,register -// +k8s:openapi-gen=true - /* Copyright 2018 BlackRock, Inc. @@ -18,4 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + +// Package v1alpha1 is the v1alpha1 version of the API. +// +groupName=argoproj.io +// +k8s:deepcopy-gen=package,register +// +k8s:openapi-gen=true package v1alpha1 diff --git a/pkg/apis/sensor/v1alpha1/doc.go b/pkg/apis/sensor/v1alpha1/doc.go index d80e42b8cf..3556a921ff 100644 --- a/pkg/apis/sensor/v1alpha1/doc.go +++ b/pkg/apis/sensor/v1alpha1/doc.go @@ -1,8 +1,3 @@ -// Package v1alpha1 is the v1alpha1 version of the API. -// +groupName=argoproj.io -// +k8s:deepcopy-gen=package,register -// +k8s:openapi-gen=true - /* Copyright 2018 BlackRock, Inc. @@ -18,4 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + +// Package v1alpha1 is the v1alpha1 version of the API. +// +groupName=argoproj.io +// +k8s:deepcopy-gen=package,register +// +k8s:openapi-gen=true package v1alpha1 diff --git a/pkg/apis/sensor/v1alpha1/types.go b/pkg/apis/sensor/v1alpha1/types.go index 6d92044de2..71554287c9 100644 --- a/pkg/apis/sensor/v1alpha1/types.go +++ b/pkg/apis/sensor/v1alpha1/types.go @@ -27,20 +27,25 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// NotificationType represent a type of notifications that are handled by a sensor type NotificationType string const ( - EventNotification NotificationType = "Event" + // EventNotification is a notification for an event dependency (from a Gateway) + EventNotification NotificationType = "Event" + // ResourceUpdateNotification is a notification that an associated resource was updated ResourceUpdateNotification NotificationType = "ResourceUpdate" ) // NodeType is the type of a node type NodeType string -// possible node types const ( + // NodeTypeEventDependency is a node that represents a single event dependency NodeTypeEventDependency NodeType = "EventDependency" - NodeTypeTrigger NodeType = "Trigger" + // NodeTypeTrigger is a node that represents a single trigger + NodeTypeTrigger NodeType = "Trigger" + // NodeTypeDependencyGroup is a node that represents a group of event dependencies NodeTypeDependencyGroup NodeType = "DependencyGroup" ) @@ -186,7 +191,7 @@ type DataFilter struct { Type JSONType `json:"type" protobuf:"bytes,2,opt,name=type"` // Value is the allowed string values for this key - // Booleans are pased using strconv.ParseBool() + // Booleans are passed using strconv.ParseBool() // Numbers are parsed using as float64 using strconv.ParseFloat() // Strings are taken as is // Nils this value is ignored @@ -385,12 +390,13 @@ type GitArtifact struct { // Tag to use to pull trigger resource // +optional Tag string `json:"tag,omitempty" protobuf:"bytes,8,opt,name=tag"` - // Git remote to manage set of tracked repositories. Defaults to "origin". + // Remote to manage set of tracked repositories. Defaults to "origin". // Refer https://git-scm.com/docs/git-remote // +optional Remote *GitRemoteConfig `json:"remote" protobuf:"bytes,9,opt,name=remote"` } +// GitRemoteConfig contains the configuration of a Git remote type GitRemoteConfig struct { // Name of the remote to fetch from. Name string `json:"name" protobuf:"bytes,1,name=name"` diff --git a/sensors/trigger.go b/sensors/trigger.go index c31f64300f..760e219970 100644 --- a/sensors/trigger.go +++ b/sensors/trigger.go @@ -18,6 +18,7 @@ package sensors import ( "fmt" + "github.com/Knetic/govaluate" "github.com/argoproj/argo-events/common" @@ -215,12 +216,12 @@ func (sec *sensorExecutionCtx) createResourceObject(resource *v1alpha1.ResourceO gvk := obj.GroupVersionKind() client, err := sec.clientPool.ClientForGroupVersionKind(gvk) if err != nil { - return fmt.Errorf("failed to get client for given group verison and kind. err: %+v", err) + return fmt.Errorf("failed to get client for given group version and kind. err: %+v", err) } apiResource, err := common.ServerResourceForGroupVersionKind(sec.discoveryClient, gvk) if err != nil { - return fmt.Errorf("failed to get server resource for given group verison and kind. err: %+v", err) + return fmt.Errorf("failed to get server resource for given group version and kind. err: %+v", err) } sec.log.Info().Str("api", apiResource.Name).Str("group-version", gvk.Version).Msg("created api resource") diff --git a/version.go b/version.go index 44b8f8277f..88e55ec3ac 100644 --- a/version.go +++ b/version.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package argo_events +package argoevents import ( "fmt" @@ -43,6 +43,7 @@ type Version struct { Platform string } +// String outputs the version as a string func (v Version) String() string { return v.Version }