-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
passing entire s3 notification payload as event data (#78)
* adding s3 with param example * fixing tests and adding logging to s3 signal
- Loading branch information
Showing
8 changed files
with
237 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Sensor | ||
metadata: | ||
name: s3-example | ||
labels: | ||
sensors.argoproj.io/controller-instanceid: axis | ||
spec: | ||
signals: | ||
- name: minioS3 | ||
artifact: | ||
s3: | ||
bucket: hello | ||
event: s3:ObjectCreated:Put | ||
endpoint: artifacts-minio.default:9000 | ||
target: | ||
type: NATS | ||
url: nats://example-nats-cluster:4222 | ||
attributes: | ||
subject: hello | ||
triggers: | ||
- name: argo-workflow | ||
resource: | ||
namespace: default | ||
group: argoproj.io | ||
version: v1alpha1 | ||
kind: Workflow | ||
# The artifact key from the workflow are overridden by the s3 notification key | ||
parameters: | ||
- src: | ||
signal: minioS3 | ||
path: s3.object.key | ||
dest: spec.templates.0.inputs.artifacts.0.key | ||
source: | ||
inline: | | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: input-artifact-s3- | ||
spec: | ||
entrypoint: input-artifact-s3-example | ||
templates: | ||
- name: input-artifact-s3-example | ||
inputs: | ||
artifacts: | ||
- name: my-art | ||
path: /my-artifact | ||
s3: | ||
endpoint: artifacts-minio.default:9000 | ||
bucket: hello | ||
key: path/in/bucket | ||
accessKey: | ||
key: accesskey | ||
name: artifacts-minio | ||
secretKey: | ||
key: secretkey | ||
name: artifacts-minio | ||
container: | ||
image: debian:latest | ||
command: [sh, -c] | ||
args: ["ls -l /my-artifact"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package fake | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" | ||
"github.com/argoproj/argo-events/sdk" | ||
"github.com/micro/go-micro/client" | ||
) | ||
|
||
// SignalClient implements the sdk.SignalClient | ||
// also contains a Send() method which should be invoked via a separate go-routine | ||
// if your test is single-threaded to prevent blocking channels | ||
type SignalClient interface { | ||
sdk.SignalClient | ||
Generate(*v1alpha1.Event) | ||
} | ||
|
||
// implements sdk.SignalService_ListenService as a simple loop | ||
type simpleLoopListenService struct { | ||
events chan *v1alpha1.Event | ||
} | ||
|
||
func (*simpleLoopListenService) SendMsg(interface{}) error { | ||
return nil | ||
} | ||
|
||
func (*simpleLoopListenService) RecvMsg(interface{}) error { | ||
return nil | ||
} | ||
|
||
func (f *simpleLoopListenService) Close() error { | ||
close(f.events) | ||
return nil | ||
} | ||
|
||
func (*simpleLoopListenService) Send(*sdk.SignalContext) error { | ||
return nil | ||
} | ||
|
||
func (f *simpleLoopListenService) Recv() (*sdk.EventContext, error) { | ||
event, ok := <-f.events | ||
if !ok { | ||
return nil, io.EOF | ||
} | ||
return &sdk.EventContext{Event: event}, nil | ||
} | ||
|
||
type fakeSignalClient struct { | ||
loop *simpleLoopListenService | ||
} | ||
|
||
// NewClient returns a new fake signal client | ||
func NewClient() SignalClient { | ||
return &fakeSignalClient{ | ||
loop: &simpleLoopListenService{ | ||
events: make(chan *v1alpha1.Event), | ||
}, | ||
} | ||
} | ||
|
||
func (*fakeSignalClient) Ping(context.Context) error { | ||
return nil | ||
} | ||
|
||
func (f *fakeSignalClient) Listen(context.Context, *v1alpha1.Signal, ...client.CallOption) (sdk.SignalService_ListenService, error) { | ||
return f.loop, nil | ||
} | ||
|
||
func (*fakeSignalClient) Handshake(*v1alpha1.Signal, sdk.SignalService_ListenService) error { | ||
return nil | ||
} | ||
|
||
// Generate allows us to produce fake events for testing purposes | ||
func (f *fakeSignalClient) Generate(e *v1alpha1.Event) { | ||
go func() { f.loop.events <- e.DeepCopy() }() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.