diff --git a/api/event-source.html b/api/event-source.html index 8d6ef3ba65..bf30584654 100644 --- a/api/event-source.html +++ b/api/event-source.html @@ -2488,6 +2488,65 @@

StorageGridEventSource

Filter on object key which caused the notification.

+ + +topicArn
+ +string + + + +

TopicArn

+ + + + +bucket
+ +string + + + +

Name of the bucket to register notifications for.

+ + + + +region
+ +string + + + +(Optional) +

S3 region. +Defaults to us-east-1

+ + + + +authToken
+ + +Kubernetes core/v1.SecretKeySelector + + + + +

Auth token for storagegrid api

+ + + + +apiURL
+ +string + + + +

ApiURL is the url of the storagegrid api.

+ +

StorageGridFilter diff --git a/api/event-source.md b/api/event-source.md index 789792cee6..e6177428bc 100644 --- a/api/event-source.md +++ b/api/event-source.md @@ -4904,6 +4904,110 @@ Filter on object key which caused the notification. + + + + +topicArn
string + + + + + +

+ +TopicArn + +

+ + + + + + + + + +bucket
string + + + + + +

+ +Name of the bucket to register notifications for. + +

+ + + + + + + + + +region
string + + + + + +(Optional) + +

+ +S3 region. Defaults to us-east-1 + +

+ + + + + + + + + +authToken
+ +Kubernetes core/v1.SecretKeySelector + + + + + +

+ +Auth token for storagegrid api + +

+ + + + + + + + + +apiURL
string + + + + + +

+ +ApiURL is the url of the storagegrid api. + +

+ + + + + diff --git a/examples/event-sources/storage-grid.yaml b/examples/event-sources/storage-grid.yaml index dd276ac8f3..38c893d2b9 100644 --- a/examples/event-sources/storage-grid.yaml +++ b/examples/event-sources/storage-grid.yaml @@ -3,9 +3,9 @@ kind: EventSource metadata: name: storage-grid-event-source spec: - type: storage-grid + type: storagegrid storageGrid: - example-insecure: + example: # hook contains configuration for the HTTP server running in the gateway. # StorageGrid will send events to following port and endpoint webhook: @@ -15,24 +15,18 @@ spec: method: POST # endpoint to listen events on endpoint: "/" + # url for StorageGrid to send notifications to. Make sure that this URL is reachable from StorageGrid + url: gateway-url # List of supported events can be derived from AWS S3 events https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types - # Remove S3 prefix from event type to make it a StorageGrid event. events: - - ObjectCreated:Put - -# example-secure: -# webhook: -# # port to run HTTP server on -# port: "8090" -# # HTTP request method to allow. In this case, only POST requests are accepted -# method: POST -# # endpoint to listen events on -# endpoint: "/" -# # path to file that is mounted in gateway pod which contains certs -# serverCertPath: "some path in pod" -# # path to file that is mounted in gateway pod which contains private key -# serverKeyPath: "some path in pod" -# # for events object PUT, POST, COPY and object removal -# events: -# - ObjectCreated:* -# - ObjectRemoved:Delete + - s3:ObjectCreated:* + # More info available at https://docs.netapp.com/sgws-110/index.jsp?topic=%2Fcom.netapp.doc.sg-tenant-admin%2FGUID-7D83D20B-F061-40ED-8C7C-F3395047B8C5.html + topicArn: topic arn + # Name of the bucket to listen notifications for + bucket: name of the bucket + # This is the URL of your StorageGrid API Portal + apiURL: storagegrid api url + # Auth Token to authenticate against StorageGrid API + authToken: + name: name of k8s secret that holds storagegrid auth token + key: key within secret that holds the token value diff --git a/examples/gateways/storage-grid.yaml b/examples/gateways/storage-grid.yaml index cfb939c823..d5eaf0ace4 100644 --- a/examples/gateways/storage-grid.yaml +++ b/examples/gateways/storage-grid.yaml @@ -3,7 +3,7 @@ kind: Gateway metadata: name: storage-grid spec: - type: storage-grid + type: storagegrid eventSourceRef: name: storage-grid-event-source template: @@ -14,4 +14,4 @@ spec: targetPort: 8080 subscribers: http: - - "http://storage-grid-watcher-sensor.argo-events.svc:9300/" + - "http://storage-grid-sensor.argo-events.svc:9300/" diff --git a/examples/sensors/storage-grid.yaml b/examples/sensors/storage-grid.yaml index 592ebdd5b3..3919d86151 100644 --- a/examples/sensors/storage-grid.yaml +++ b/examples/sensors/storage-grid.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Sensor metadata: - name: storage-grid-watcher + name: storage-grid spec: template: serviceAccountName: argo-events-sa diff --git a/gateways/server/cmd/main.go b/gateways/server/cmd/main.go index 45fd4ba932..f3739aaad8 100644 --- a/gateways/server/cmd/main.go +++ b/gateways/server/cmd/main.go @@ -99,7 +99,7 @@ func getEventingServer(eventType apicommon.EventSourceType, restConfig *rest.Con case apicommon.SlackEvent: return &slack.EventListener{Logger: log, K8sClient: clientset, Namespace: namespace}, nil case apicommon.StorageGridEvent: - return &storagegrid.EventListener{Logger: log}, nil + return &storagegrid.EventListener{Logger: log, K8sClient: clientset, Namespace: namespace}, nil case apicommon.StripeEvent: return &stripe.EventListener{Logger: log, K8sClient: clientset, Namespace: namespace}, nil case apicommon.WebhookEvent: diff --git a/gateways/server/storagegrid/start.go b/gateways/server/storagegrid/start.go index 5925889188..5d6e3b40ba 100644 --- a/gateways/server/storagegrid/start.go +++ b/gateways/server/storagegrid/start.go @@ -18,6 +18,7 @@ package storagegrid import ( "encoding/json" + "fmt" "io/ioutil" "net/http" "net/url" @@ -29,6 +30,7 @@ import ( "github.com/argoproj/argo-events/gateways/server/common/webhook" "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" "github.com/ghodss/yaml" + "github.com/go-resty/resty/v2" "github.com/google/uuid" "github.com/joncalhoun/qson" ) @@ -48,6 +50,16 @@ var ( ` + generateUUID().String() + ` ` + "\n" + + notificationBodyTemplate = ` + + + %s + %s + %s + + +` + "\n" ) // set up the activation and inactivation channels to control the state of routes. @@ -60,19 +72,6 @@ func generateUUID() uuid.UUID { return uuid.New() } -// filterEvent filters notification based on event filter in a gateway configuration -func filterEvent(notification *storageGridNotification, eventSource *v1alpha1.StorageGridEventSource) bool { - if eventSource.Events == nil { - return true - } - for _, filterEvent := range eventSource.Events { - if notification.Message.Records[0].EventName == filterEvent { - return true - } - } - return false -} - // filterName filters object key based on configured prefix and/or suffix func filterName(notification *storageGridNotification, eventSource *v1alpha1.StorageGridEventSource) bool { if eventSource.Filter == nil { @@ -160,7 +159,7 @@ func (router *Router) HandleRoute(writer http.ResponseWriter, request *http.Requ return } - if filterEvent(notification, router.storageGridEventSource) && filterName(notification, router.storageGridEventSource) { + if filterName(notification, router.storageGridEventSource) { logger.WithError(err).Errorln("new event received, dispatching event on route's data channel") route.DataCh <- b return @@ -171,6 +170,127 @@ func (router *Router) HandleRoute(writer http.ResponseWriter, request *http.Requ // PostActivate performs operations once the route is activated and ready to consume requests func (router *Router) PostActivate() error { + eventSource := router.storageGridEventSource + route := router.route + + authToken, err := common.GetSecretValue(router.k8sClient, router.namespace, eventSource.AuthToken) + if err != nil { + return err + } + + registrationURL := common.FormattedURL(eventSource.Webhook.URL, eventSource.Webhook.Endpoint) + + client := resty.New() + + logger := route.Logger.WithFields( + map[string]interface{}{ + common.LabelEventSource: route.EventSource.Name, + "registration-url": registrationURL, + "bucket": eventSource.Bucket, + "auth-secret-name": eventSource.AuthToken.Name, + "api-url": eventSource.ApiURL, + }) + + logger.Infoln("checking if the endpoint already exists...") + + response, err := client.R(). + SetHeader("Content-Type", common.MediaTypeJSON). + SetAuthToken(authToken). + SetResult(&getEndpointResponse{}). + SetError(&genericResponse{}). + Get(common.FormattedURL(eventSource.ApiURL, "/org/endpoints")) + if err != nil { + return err + } + + if !response.IsSuccess() { + errObj := response.Error().(*genericResponse) + return fmt.Errorf("failed to list existing endpoints. reason: %s", errObj.Message.Text) + } + + endpointResponse := response.Result().(*getEndpointResponse) + + isURNExists := false + + for _, endpoint := range endpointResponse.Data { + if endpoint.EndpointURN == eventSource.TopicArn { + logger.Infoln("endpoint with topic urn already exists, won't register duplicate endpoint") + isURNExists = true + break + } + } + + if !isURNExists { + logger.Infoln("endpoint urn does not exist, registering a new endpoint") + newEndpoint := createEndpointRequest{ + DisplayName: router.route.EventSource.Name, + EndpointURI: common.FormattedURL(eventSource.Webhook.URL, eventSource.Webhook.Endpoint), + EndpointURN: eventSource.TopicArn, + AuthType: "anonymous", + InsecureTLS: true, + } + + newEndpointBody, err := json.Marshal(&newEndpoint) + if err != nil { + return err + } + + response, err := client.R(). + SetHeader("Content-Type", common.MediaTypeJSON). + SetAuthToken(authToken). + SetBody(string(newEndpointBody)). + SetResult(&genericResponse{}). + SetError(&genericResponse{}). + Post(common.FormattedURL(eventSource.ApiURL, "/org/endpoints")) + if err != nil { + return err + } + + if !response.IsSuccess() { + errObj := response.Error().(*genericResponse) + return fmt.Errorf("failed to register the endpoint. reason: %s", errObj.Message.Text) + } + + logger.Infoln("successfully registered the endpoint") + } + + logger.Infoln("registering notification configuration on storagegrid...") + + var events []string + for _, event := range eventSource.Events { + events = append(events, fmt.Sprintf("%s", event)) + } + + eventXML := strings.Join(events, "\n") + + notificationBody := fmt.Sprintf(notificationBodyTemplate, route.EventSource.Name, eventSource.TopicArn, eventXML) + + notification := &storageGridNotificationRequest{ + Notification: notificationBody, + } + + notificationRequestBody, err := json.Marshal(notification) + if err != nil { + return err + } + + response, err = client.R(). + SetHeader("Content-Type", common.MediaTypeJSON). + SetAuthToken(authToken). + SetBody(string(notificationRequestBody)). + SetResult(®isterNotificationResponse{}). + SetError(&genericResponse{}). + Put(common.FormattedURL(eventSource.ApiURL, fmt.Sprintf("/org/containers/%s/notification", eventSource.Bucket))) + if err != nil { + return err + } + + if !response.IsSuccess() { + errObj := response.Error().(*genericResponse) + return fmt.Errorf("failed to configure notification. reason %s\n", errObj.Message.Text) + } + + logger.Infoln("successfully registered notification configuration on storagegrid") return nil } @@ -198,5 +318,7 @@ func (listener *EventListener) StartEventSource(eventSource *gateways.EventSourc return webhook.ManageRoute(&Router{ route: route, storageGridEventSource: storagegridEventSource, + k8sClient: listener.K8sClient, + namespace: listener.Namespace, }, controller, eventStream) } diff --git a/gateways/server/storagegrid/start_test.go b/gateways/server/storagegrid/start_test.go index 4d3e1393ec..0267199338 100644 --- a/gateways/server/storagegrid/start_test.go +++ b/gateways/server/storagegrid/start_test.go @@ -131,32 +131,6 @@ func TestGenerateUUID(t *testing.T) { }) } -func TestFilterEvent(t *testing.T) { - convey.Convey("Given a storage grid event, test whether it passes the filter", t, func() { - storageGridEventSource := &v1alpha1.StorageGridEventSource{ - Webhook: &webhook.Context{ - Endpoint: "/", - URL: "testurl", - Port: "8080", - }, - Events: []string{ - "ObjectCreated:Put", - }, - Filter: &v1alpha1.StorageGridFilter{ - Prefix: "hello-", - Suffix: ".txt", - }, - } - var gridNotification *storageGridNotification - err := json.Unmarshal([]byte(notification), &gridNotification) - convey.So(err, convey.ShouldBeNil) - convey.So(gridNotification, convey.ShouldNotBeNil) - - ok := filterEvent(gridNotification, storageGridEventSource) - convey.So(ok, convey.ShouldEqual, true) - }) -} - func TestFilterName(t *testing.T) { convey.Convey("Given a storage grid event, test whether the object key passes the filter", t, func() { storageGridEventSource := &v1alpha1.StorageGridEventSource{ diff --git a/gateways/server/storagegrid/types.go b/gateways/server/storagegrid/types.go index 10cf42b6aa..bc51fc6695 100644 --- a/gateways/server/storagegrid/types.go +++ b/gateways/server/storagegrid/types.go @@ -17,17 +17,21 @@ limitations under the License. package storagegrid import ( - "github.com/argoproj/argo-events/gateways/server/common/webhook" "time" + "github.com/argoproj/argo-events/gateways/server/common/webhook" "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" "github.com/sirupsen/logrus" + "k8s.io/client-go/kubernetes" ) // EventListener implements Eventing for storage grid events type EventListener struct { // Logger logs stuff Logger *logrus.Logger + // k8sClient is Kubernetes client + K8sClient kubernetes.Interface + Namespace string } // Router manages route @@ -36,6 +40,13 @@ type Router struct { route *webhook.Route // storageGridEventSource refers to event source which contains configuration to consume events from storage grid storageGridEventSource *v1alpha1.StorageGridEventSource + // k8sClient is Kubernetes client + k8sClient kubernetes.Interface + namespace string +} + +type storageGridNotificationRequest struct { + Notification string `json:"notification"` } // storageGridNotification is the bucket notification received from storage grid @@ -78,3 +89,102 @@ type storageGridNotification struct { TopicArn string `json:"TopicArn"` Version string `json:"Version"` } + +type registerNotificationResponse struct { + ResponseTime time.Time `json:“responseTime”` + Status string `json:“status”` + APIVersion string `json:“apiVersion”` + Deprecated bool `json:“deprecated”` + Code int `json:“code”` + Message struct { + Text string `json:“text”` + Key string `json:“key”` + Context string `json:“context”` + DeveloperMessage string `json:“developerMessage”` + } `json:“message”` + Errors []struct { + Text string `json:“text”` + Key string `json:“key”` + Context string `json:“context”` + DeveloperMessage string `json:“developerMessage”` + } `json:“errors”` +} + +type getEndpointRequest struct { + DisplayName string `json:"displayName"` + EndpointURI string `json:"endpointURI"` + EndpointURN string `json:"endpointURN"` + AuthType string `json:"authType"` + CaCert string `json:"caCert"` + InsecureTLS bool `json:"insecureTLS"` + Credentials struct { + AccessKeyID string `json:"accessKeyId"` + SecretAccessKey string `json:"secretAccessKey"` + } `json:"credentials"` + BasicHTTPCredentials struct { + Username string `json:"username"` + Password string `json:"password"` + } `json:"basicHttpCredentials"` + Error struct { + Text string `json:"text"` + Time time.Time `json:"time"` + Key string `json:"key"` + } `json:"error"` +} + +type getEndpointResponse struct { + ResponseTime time.Time `json:"responseTime"` + Status string `json:"status"` + APIVersion string `json:"apiVersion"` + Deprecated bool `json:"deprecated"` + Data []struct { + DisplayName string `json:"displayName"` + EndpointURI string `json:"endpointURI"` + EndpointURN string `json:"endpointURN"` + AuthType string `json:"authType"` + CaCert string `json:"caCert"` + InsecureTLS bool `json:"insecureTLS"` + Credentials struct { + AccessKeyID string `json:"accessKeyId"` + SecretAccessKey string `json:"secretAccessKey"` + } `json:"credentials"` + BasicHTTPCredentials struct { + Username string `json:"username"` + Password string `json:"password"` + } `json:"basicHttpCredentials"` + Error struct { + Text string `json:"text"` + Time time.Time `json:"time"` + Key string `json:"key"` + } `json:"error"` + ID string `json:"id"` + } `json:"data"` +} + +type createEndpointRequest struct { + DisplayName string `json:"displayName"` + EndpointURI string `json:"endpointURI"` + EndpointURN string `json:"endpointURN"` + AuthType string `json:"authType"` + InsecureTLS bool `json:"insecureTLS"` +} + +type genericResponse struct { + ResponseTime time.Time `json:"responseTime"` + Status string `json:"status"` + APIVersion string `json:"apiVersion"` + Deprecated bool `json:"deprecated"` + Code int `json:"code"` + Message struct { + Text string `json:"text"` + Key string `json:"key"` + Context string `json:"context"` + DeveloperMessage string `json:"developerMessage"` + } `json:"message"` + Errors []struct { + Text string `json:"text"` + Key string `json:"key"` + Context string `json:"context"` + DeveloperMessage string `json:"developerMessage"` + } `json:"errors"` +} diff --git a/gateways/server/storagegrid/validate.go b/gateways/server/storagegrid/validate.go index 4fd203df06..2737648ef4 100644 --- a/gateways/server/storagegrid/validate.go +++ b/gateways/server/storagegrid/validate.go @@ -18,6 +18,7 @@ package storagegrid import ( "context" + "fmt" "github.com/argoproj/argo-events/common" "github.com/argoproj/argo-events/gateways" @@ -62,5 +63,20 @@ func validate(eventSource *v1alpha1.StorageGridEventSource) error { if eventSource == nil { return common.ErrNilEventSource } + if eventSource.TopicArn == "" { + return fmt.Errorf("topic arn must be provided") + } + if eventSource.ApiURL == "" { + return fmt.Errorf("api url must be provided") + } + if eventSource.AuthToken == nil { + return fmt.Errorf("api auth token must be provided") + } + if eventSource.Bucket == "" { + return fmt.Errorf("bucket name must be provided") + } + if eventSource.Events == nil { + return fmt.Errorf("event types must be provided") + } return webhook.ValidateWebhookContext(eventSource.Webhook) } diff --git a/go.mod b/go.mod index ed71955193..ad4ad44349 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/go-openapi/spec v0.19.7 github.com/go-openapi/swag v0.19.8 // indirect github.com/go-redis/redis v6.15.7+incompatible + github.com/go-resty/resty/v2 v2.3.0 github.com/gobwas/glob v0.2.4-0.20181002190808-e7a84e9525fe github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.3.5 @@ -89,7 +90,6 @@ require ( github.com/yudai/pp v2.0.1+incompatible // indirect go.uber.org/zap v1.14.1 golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 - golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa // indirect google.golang.org/api v0.21.0 google.golang.org/grpc v1.28.1 diff --git a/go.sum b/go.sum index 4514d58d32..acc5cdd247 100644 --- a/go.sum +++ b/go.sum @@ -350,6 +350,8 @@ github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85n github.com/go-ozzo/ozzo-validation v3.5.0+incompatible/go.mod h1:gsEKFIVnabGBt6mXmxK0MoFy+cZoTJY6mu5Ll3LVLBU= github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= +github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= @@ -995,8 +997,8 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/pkg/apis/eventsource/v1alpha1/openapi_generated.go b/pkg/apis/eventsource/v1alpha1/openapi_generated.go index 3d6e4becce..c1a60032ee 100644 --- a/pkg/apis/eventsource/v1alpha1/openapi_generated.go +++ b/pkg/apis/eventsource/v1alpha1/openapi_generated.go @@ -1867,12 +1867,46 @@ func schema_pkg_apis_eventsource_v1alpha1_StorageGridEventSource(ref common.Refe Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1.StorageGridFilter"), }, }, + "topicArn": { + SchemaProps: spec.SchemaProps{ + Description: "TopicArn", + Type: []string{"string"}, + Format: "", + }, + }, + "bucket": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the bucket to register notifications for.", + Type: []string{"string"}, + Format: "", + }, + }, + "region": { + SchemaProps: spec.SchemaProps{ + Description: "S3 region. Defaults to us-east-1", + Type: []string{"string"}, + Format: "", + }, + }, + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "Auth token for storagegrid api", + Ref: ref("k8s.io/api/core/v1.SecretKeySelector"), + }, + }, + "apiURL": { + SchemaProps: spec.SchemaProps{ + Description: "ApiURL is the url of the storagegrid api.", + Type: []string{"string"}, + Format: "", + }, + }, }, - Required: []string{"webhook"}, + Required: []string{"webhook", "topicArn", "bucket", "authToken", "apiURL"}, }, }, Dependencies: []string{ - "github.com/argoproj/argo-events/gateways/server/common/webhook.Context", "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1.StorageGridFilter"}, + "github.com/argoproj/argo-events/gateways/server/common/webhook.Context", "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1.StorageGridFilter", "k8s.io/api/core/v1.SecretKeySelector"}, } } diff --git a/pkg/apis/eventsource/v1alpha1/types.go b/pkg/apis/eventsource/v1alpha1/types.go index 77ca350997..dc17a20481 100644 --- a/pkg/apis/eventsource/v1alpha1/types.go +++ b/pkg/apis/eventsource/v1alpha1/types.go @@ -461,6 +461,18 @@ type StorageGridEventSource struct { Events []string `json:"events,omitempty" protobuf:"bytes,2,opt,name=events"` // Filter on object key which caused the notification. Filter *StorageGridFilter `json:"filter,omitempty" protobuf:"bytes,3,opt,name=filter"` + // TopicArn + TopicArn string `json:"topicArn" protobuf:"bytes,4,name=topicArn"` + // Name of the bucket to register notifications for. + Bucket string `json:"bucket" protobuf:"bytes,5,name=bucket"` + // S3 region. + // Defaults to us-east-1 + // +optional + Region string `json:"region,omitempty" protobuf:"bytes,6,opt,name=region"` + // Auth token for storagegrid api + AuthToken *corev1.SecretKeySelector `json:"authToken" protobuf:"bytes,7,name=authToken"` + // ApiURL is the url of the storagegrid api. + ApiURL string `json:"apiURL" protobuf:"bytes,8,name=apiURL"` } // Filter represents filters to apply to bucket notifications for specifying constraints on objects diff --git a/pkg/apis/eventsource/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/eventsource/v1alpha1/zz_generated.deepcopy.go index 9e09443fff..ff4b89b0e9 100644 --- a/pkg/apis/eventsource/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/eventsource/v1alpha1/zz_generated.deepcopy.go @@ -866,6 +866,11 @@ func (in *StorageGridEventSource) DeepCopyInto(out *StorageGridEventSource) { *out = new(StorageGridFilter) **out = **in } + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(v1.SecretKeySelector) + (*in).DeepCopyInto(*out) + } return }