From 3eee3c96a09ae85fcd1e4ad7f2dd0624ec354f41 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Wed, 27 Feb 2019 18:09:46 -0500 Subject: [PATCH] Fix resource gateway (#185) * chore(): adding gateway examples * fix(): updating resource gateway. renew watch. * fix(): adding informer factory to watch updates * fix(): adding informer factory to watch updates * fix(): renewing watch in resource gateway * fix(): update example * fix(): update makefile * fix(): fix calendar gateway bug --- Gopkg.lock | 1157 +++++++++++++++++ Makefile | 2 +- .../gateways/aws-sns-gateway-configmap.yaml | 17 + examples/gateways/aws-sns.yaml | 35 + .../gateways/resource-gateway-configmap.yaml | 5 +- examples/sensors/resource.yaml | 2 +- examples/sensors/webhook-http-boolean.yaml | 85 ++ gateways/community/aws-sns/Dockerfile | 4 +- gateways/core/calendar/start.go | 3 +- gateways/core/resource/Dockerfile | 2 +- gateways/core/resource/start.go | 196 +-- 11 files changed, 1425 insertions(+), 83 deletions(-) create mode 100644 Gopkg.lock create mode 100644 examples/gateways/aws-sns-gateway-configmap.yaml create mode 100644 examples/gateways/aws-sns.yaml create mode 100644 examples/sensors/webhook-http-boolean.yaml diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000000..c65ddbde52 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,1157 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + name = "cloud.google.com/go" + packages = [ + "compute/metadata", + "iam", + "internal/optional", + "internal/version", + "pubsub", + "pubsub/apiv1", + "pubsub/internal/distribution" + ] + revision = "e2c125ceac8b663cfcf4610477d4d67827377cb7" + +[[projects]] + name = "github.com/DataDog/zstd" + packages = ["."] + revision = "c7161f8c63c045cbc7ca051dcc969dd0e4054de2" + version = "v1.3.5" + +[[projects]] + branch = "master" + name = "github.com/Knetic/govaluate" + packages = ["."] + revision = "9aa49832a739dcd78a5542ff189fb82c3e423116" + +[[projects]] + name = "github.com/PuerkitoBio/purell" + packages = ["."] + revision = "44968752391892e1b0d0b821ee79e9a85fa13049" + version = "v1.1.1" + +[[projects]] + branch = "master" + name = "github.com/PuerkitoBio/urlesc" + packages = ["."] + revision = "de5bf2ad457846296e2031421a34e2568e304e35" + +[[projects]] + name = "github.com/Shopify/sarama" + packages = ["."] + revision = "4602b5a8c6e826f9e0737865818dd43b2339a092" + version = "v1.21.0" + +[[projects]] + name = "github.com/argoproj/argo" + packages = [ + "pkg/apis/workflow", + "pkg/apis/workflow/v1alpha1" + ] + revision = "0a928e93dac6d8522682931a0a68c52add310cdb" + version = "v2.2.1" + +[[projects]] + branch = "master" + name = "github.com/aws/aws-sdk-go" + packages = [ + "aws", + "aws/awserr", + "aws/awsutil", + "aws/client", + "aws/client/metadata", + "aws/corehandlers", + "aws/credentials", + "aws/credentials/ec2rolecreds", + "aws/credentials/endpointcreds", + "aws/credentials/processcreds", + "aws/credentials/stscreds", + "aws/csm", + "aws/defaults", + "aws/ec2metadata", + "aws/endpoints", + "aws/request", + "aws/session", + "aws/signer/v4", + "internal/ini", + "internal/sdkio", + "internal/sdkrand", + "internal/sdkuri", + "internal/shareddefaults", + "private/protocol", + "private/protocol/query", + "private/protocol/query/queryutil", + "private/protocol/rest", + "private/protocol/xml/xmlutil", + "service/sns", + "service/sts" + ] + revision = "b9fa1724922ca124b6492e9db0c977f0ca8f7455" + +[[projects]] + name = "github.com/davecgh/go-spew" + packages = ["spew"] + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" + +[[projects]] + name = "github.com/dustin/go-humanize" + packages = ["."] + revision = "9f541cc9db5d55bce703bd99987c9d5cb8eea45e" + version = "v1.0.0" + +[[projects]] + name = "github.com/eapache/go-resiliency" + packages = ["breaker"] + revision = "ea41b0fad31007accc7f806884dcdf3da98b79ce" + version = "v1.1.0" + +[[projects]] + branch = "master" + name = "github.com/eapache/go-xerial-snappy" + packages = ["."] + revision = "776d5712da21bc4762676d614db1d8a64f4238b0" + +[[projects]] + name = "github.com/eapache/queue" + packages = ["."] + revision = "44cc805cf13205b55f69e14bcb69867d1ae92f98" + version = "v1.1.0" + +[[projects]] + name = "github.com/eclipse/paho.mqtt.golang" + packages = [ + ".", + "packets" + ] + revision = "36d01c2b4cbeb3d2a12063e4880ce30800af9560" + version = "v1.1.1" + +[[projects]] + name = "github.com/emicklei/go-restful" + packages = [ + ".", + "log" + ] + revision = "85d198d05a92d31823b852b4a5928114912e8949" + version = "v2.9.0" + +[[projects]] + name = "github.com/emirpasic/gods" + packages = [ + "containers", + "lists", + "lists/arraylist", + "trees", + "trees/binaryheap", + "utils" + ] + revision = "1615341f118ae12f353cc8a983f35b584342c9b3" + version = "v1.12.0" + +[[projects]] + branch = "master" + name = "github.com/fsnotify/fsnotify" + packages = ["."] + revision = "ccc981bf80385c528a65fbfdd49bf2d8da22aa23" + +[[projects]] + branch = "master" + name = "github.com/ghodss/yaml" + packages = ["."] + revision = "25d852aebe32c875e9c044af3eef9c7dc6bc777f" + +[[projects]] + name = "github.com/go-openapi/jsonpointer" + packages = ["."] + revision = "ef5f0afec364d3b9396b7b77b43dbe26bf1f8004" + version = "v0.18.0" + +[[projects]] + name = "github.com/go-openapi/jsonreference" + packages = ["."] + revision = "8483a886a90412cd6858df4ea3483dce9c8e35a3" + version = "v0.18.0" + +[[projects]] + name = "github.com/go-openapi/spec" + packages = ["."] + revision = "5b6cdde3200976e3ecceb2868706ee39b6aff3e4" + version = "v0.18.0" + +[[projects]] + name = "github.com/go-openapi/swag" + packages = ["."] + revision = "1d29f06aebd59ccdf11ae04aa0334ded96e2d909" + version = "v0.18.0" + +[[projects]] + name = "github.com/gogo/protobuf" + packages = [ + "gogoproto", + "plugin/compare", + "plugin/defaultcheck", + "plugin/description", + "plugin/embedcheck", + "plugin/enumstringer", + "plugin/equal", + "plugin/face", + "plugin/gostring", + "plugin/marshalto", + "plugin/oneofcheck", + "plugin/populate", + "plugin/size", + "plugin/stringer", + "plugin/testgen", + "plugin/union", + "plugin/unmarshal", + "proto", + "protoc-gen-gofast", + "protoc-gen-gogo/descriptor", + "protoc-gen-gogo/generator", + "protoc-gen-gogo/generator/internal/remap", + "protoc-gen-gogo/grpc", + "protoc-gen-gogo/plugin", + "protoc-gen-gogofast", + "sortkeys", + "vanity", + "vanity/command" + ] + revision = "ba06b47c162d49f2af050fb4c75bcbc86a159d5c" + version = "v1.2.1" + +[[projects]] + branch = "master" + name = "github.com/golang/glog" + packages = ["."] + revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" + +[[projects]] + branch = "master" + name = "github.com/golang/protobuf" + packages = [ + "proto", + "protoc-gen-go", + "protoc-gen-go/descriptor", + "protoc-gen-go/generator", + "protoc-gen-go/generator/internal/remap", + "protoc-gen-go/grpc", + "protoc-gen-go/plugin", + "ptypes", + "ptypes/any", + "ptypes/duration", + "ptypes/empty", + "ptypes/timestamp" + ] + revision = "c823c79ea1570fb5ff454033735a8e68575d1d0f" + +[[projects]] + name = "github.com/golang/snappy" + packages = ["."] + revision = "2a8bb927dd31d8daada140a5d09578521ce5c36a" + version = "v0.0.1" + +[[projects]] + name = "github.com/google/go-github" + packages = ["github"] + revision = "56cb1dd99043eba2e21c91aa8417d3ba2329259a" + version = "v21.0.1" + +[[projects]] + name = "github.com/google/go-querystring" + packages = ["query"] + revision = "44c6ddd0a2342c386950e880b658017258da92fc" + version = "v1.0.0" + +[[projects]] + branch = "master" + name = "github.com/google/gofuzz" + packages = ["."] + revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" + +[[projects]] + name = "github.com/googleapis/gax-go" + packages = ["v2"] + revision = "c8a15bac9b9fe955bd9f900272f9a306465d28cf" + version = "v2.0.3" + +[[projects]] + name = "github.com/googleapis/gnostic" + packages = [ + "OpenAPIv2", + "compiler", + "extensions" + ] + revision = "7c663266750e7d82587642f65e60bc4083f1f84e" + version = "v0.2.0" + +[[projects]] + branch = "master" + name = "github.com/gopherjs/gopherjs" + packages = ["js"] + revision = "d547d1d9531ed93dbdebcbff7f83e7c876a1e0ee" + +[[projects]] + name = "github.com/gorilla/websocket" + packages = ["."] + revision = "66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d" + version = "v1.4.0" + +[[projects]] + name = "github.com/hashicorp/golang-lru" + packages = [ + ".", + "simplelru" + ] + revision = "20f1fb78b0740ba8c3cb143a61e86ba5c8669768" + version = "v0.5.0" + +[[projects]] + branch = "master" + name = "github.com/howeyc/gopass" + packages = ["."] + revision = "bf9dde6d0d2c004a008c27aaee91170c786f6db8" + +[[projects]] + name = "github.com/imdario/mergo" + packages = ["."] + revision = "7c29201646fa3de8506f701213473dd407f19646" + version = "v0.3.7" + +[[projects]] + branch = "master" + name = "github.com/jbenet/go-context" + packages = ["io"] + revision = "d14ea06fba99483203c19d92cfcd13ebe73135f4" + +[[projects]] + name = "github.com/jmespath/go-jmespath" + packages = ["."] + revision = "c2b33e84" + +[[projects]] + branch = "master" + name = "github.com/joncalhoun/qson" + packages = ["."] + revision = "8a9cab3a62b1b693e7dfa590a215dc6217552803" + +[[projects]] + name = "github.com/json-iterator/go" + packages = ["."] + revision = "1624edc4454b8682399def8740d46db5e4362ba4" + version = "v1.1.5" + +[[projects]] + name = "github.com/jtolds/gls" + packages = ["."] + revision = "b4936e06046bbecbb94cae9c18127ebe510a2cb9" + version = "v4.20" + +[[projects]] + name = "github.com/kevinburke/ssh_config" + packages = ["."] + revision = "81db2a75821ed34e682567d48be488a1c3121088" + version = "0.5" + +[[projects]] + name = "github.com/konsorten/go-windows-terminal-sequences" + packages = ["."] + revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242" + version = "v1.0.1" + +[[projects]] + branch = "master" + name = "github.com/mailru/easyjson" + packages = [ + "buffer", + "jlexer", + "jwriter" + ] + revision = "6243d8e04c3f819e79757e8bc3faa15c3cb27003" + +[[projects]] + name = "github.com/minio/minio-go" + packages = [ + ".", + "pkg/credentials", + "pkg/encrypt", + "pkg/s3signer", + "pkg/s3utils", + "pkg/set" + ] + revision = "008c7aa71fc17e11bf980c209a4f8c4d687fc884" + version = "v6.0.18" + +[[projects]] + name = "github.com/mitchellh/go-homedir" + packages = ["."] + revision = "af06845cf3004701891bf4fdb884bfe4920b3727" + version = "v1.1.0" + +[[projects]] + name = "github.com/modern-go/concurrent" + packages = ["."] + revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" + version = "1.0.3" + +[[projects]] + name = "github.com/modern-go/reflect2" + packages = ["."] + revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" + version = "1.0.1" + +[[projects]] + name = "github.com/nats-io/go-nats" + packages = [ + ".", + "encoders/builtin", + "util" + ] + revision = "70fe06cee50d4b6f98248d9675fb55f2a3aa7228" + version = "v1.7.2" + +[[projects]] + branch = "master" + name = "github.com/nats-io/go-nats-streaming" + packages = [ + ".", + "pb" + ] + revision = "a0e3aee6fce1a77efe4024df3280416e9d99bb98" + +[[projects]] + name = "github.com/nats-io/nkeys" + packages = ["."] + revision = "1546a3320a8f195a5b5c84aef8309377c2e411d5" + version = "v0.0.2" + +[[projects]] + name = "github.com/nats-io/nuid" + packages = ["."] + revision = "289cccf02c178dc782430d534e3c1f5b72af807f" + version = "v1.0.0" + +[[projects]] + branch = "master" + name = "github.com/nlopes/slack" + packages = [ + ".", + "slackevents", + "slackutilsx" + ] + revision = "0bc5d873f8a59fa3ec3aee907b833e25e44c52c6" + +[[projects]] + name = "github.com/pelletier/go-buffruneio" + packages = ["."] + revision = "c37440a7cf42ac63b919c752ca73a85067e05992" + version = "v0.2.0" + +[[projects]] + name = "github.com/pierrec/lz4" + packages = [ + ".", + "internal/xxh32" + ] + revision = "062282ea0dcff40c9fb8525789eef9644b1fbd6e" + version = "v2.1.0" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4" + version = "v0.8.1" + +[[projects]] + name = "github.com/pmezard/go-difflib" + packages = ["difflib"] + revision = "792786c7400a136282c1664665ae0a8db921c6c2" + version = "v1.0.0" + +[[projects]] + branch = "master" + name = "github.com/rcrowley/go-metrics" + packages = ["."] + revision = "3113b8401b8a98917cde58f8bbd42a1b1c03b1fd" + +[[projects]] + name = "github.com/robfig/cron" + packages = ["."] + revision = "b41be1df696709bb6395fe435af20370037c0b4c" + version = "v1.1" + +[[projects]] + name = "github.com/rs/zerolog" + packages = [ + ".", + "internal/cbor", + "internal/json" + ] + revision = "8747b7b3a51b5d08ee7ac50eaf4869edaf9f714a" + version = "v1.11.0" + +[[projects]] + name = "github.com/satori/go.uuid" + packages = ["."] + revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" + version = "v1.2.0" + +[[projects]] + name = "github.com/sergi/go-diff" + packages = ["diffmatchpatch"] + revision = "1744e2970ca51c86172c8190fadad617561ed6e7" + version = "v1.0.0" + +[[projects]] + name = "github.com/sirupsen/logrus" + packages = ["."] + revision = "e1e72e9de974bd926e5c56f83753fba2df402ce5" + version = "v1.3.0" + +[[projects]] + name = "github.com/smartystreets/assertions" + packages = [ + ".", + "internal/go-render/render", + "internal/oglematchers" + ] + revision = "7678a5452ebea5b7090a6b163f844c133f523da2" + version = "1.8.3" + +[[projects]] + name = "github.com/smartystreets/goconvey" + packages = [ + "convey", + "convey/gotest", + "convey/reporting" + ] + revision = "9e8dc3f972df6c8fcc0375ef492c24d0bb204857" + version = "1.6.3" + +[[projects]] + name = "github.com/spf13/pflag" + packages = ["."] + revision = "298182f68c66c05229eb03ac171abe6e309ee79a" + version = "v1.0.3" + +[[projects]] + name = "github.com/src-d/gcfg" + packages = [ + ".", + "scanner", + "token", + "types" + ] + revision = "1ac3a1ac202429a54835fe8408a92880156b489d" + version = "v1.4.0" + +[[projects]] + branch = "master" + name = "github.com/streadway/amqp" + packages = ["."] + revision = "30f8ed68076eedf14990dafc696f469f58fc1342" + +[[projects]] + name = "github.com/stretchr/testify" + packages = ["assert"] + revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" + version = "v1.3.0" + +[[projects]] + name = "github.com/tidwall/gjson" + packages = ["."] + revision = "eee0b6226f0d1db2675a176fdfaa8419bcad4ca8" + version = "v1.2.1" + +[[projects]] + name = "github.com/tidwall/match" + packages = ["."] + revision = "33827db735fff6510490d69a8622612558a557ed" + version = "v1.0.1" + +[[projects]] + branch = "master" + name = "github.com/tidwall/pretty" + packages = ["."] + revision = "65a9db5fad5105a89e17f38adcc9878685be6d78" + +[[projects]] + name = "github.com/tidwall/sjson" + packages = ["."] + revision = "c943cc8c8d751d9b33444adf78ae04c2fc8be754" + version = "v1.0.3" + +[[projects]] + name = "github.com/xanzy/go-gitlab" + packages = ["."] + revision = "8e525d783950ddfc35d109e48af26f4cb70dde4a" + version = "v0.15.0" + +[[projects]] + name = "github.com/xanzy/ssh-agent" + packages = ["."] + revision = "6a3e2ff9e7c564f36873c2e36413f634534f1c44" + version = "v0.2.1" + +[[projects]] + name = "go.opencensus.io" + packages = [ + ".", + "exemplar", + "internal", + "internal/tagencoding", + "plugin/ocgrpc", + "plugin/ochttp", + "plugin/ochttp/propagation/b3", + "stats", + "stats/internal", + "stats/view", + "tag", + "trace", + "trace/internal", + "trace/propagation", + "trace/tracestate" + ] + revision = "2b5032d79456124f42db6b7eb19ac6c155449dc2" + version = "v0.19.0" + +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = [ + "argon2", + "blake2b", + "cast5", + "curve25519", + "ed25519", + "ed25519/internal/edwards25519", + "internal/chacha20", + "internal/subtle", + "openpgp", + "openpgp/armor", + "openpgp/elgamal", + "openpgp/errors", + "openpgp/packet", + "openpgp/s2k", + "poly1305", + "ssh", + "ssh/agent", + "ssh/knownhosts", + "ssh/terminal" + ] + revision = "7f87c0fbb88b590338857bcb720678c2583d4dea" + +[[projects]] + branch = "master" + name = "golang.org/x/net" + packages = [ + "context", + "context/ctxhttp", + "http/httpguts", + "http2", + "http2/hpack", + "idna", + "internal/socks", + "internal/timeseries", + "proxy", + "publicsuffix", + "trace", + "websocket" + ] + revision = "66a96c8a540e84140eaf74e38bb3a0a2ff5e5c53" + +[[projects]] + branch = "master" + name = "golang.org/x/oauth2" + packages = [ + ".", + "google", + "internal", + "jws", + "jwt" + ] + revision = "529b322ea34655aa15fb32e063f3d4d3cf803cac" + +[[projects]] + branch = "master" + name = "golang.org/x/sync" + packages = [ + "errgroup", + "semaphore" + ] + revision = "37e7f081c4d4c64e13b10787722085407fe5d15f" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = [ + "cpu", + "unix", + "windows" + ] + revision = "cc5685c2db1239775905f3911f0067c0fa74762f" + +[[projects]] + name = "golang.org/x/text" + packages = [ + "collate", + "collate/build", + "internal/colltab", + "internal/gen", + "internal/tag", + "internal/triegen", + "internal/ucd", + "language", + "secure/bidirule", + "transform", + "unicode/bidi", + "unicode/cldr", + "unicode/norm", + "unicode/rangetable", + "width" + ] + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + branch = "master" + name = "golang.org/x/time" + packages = ["rate"] + revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd" + +[[projects]] + branch = "master" + name = "golang.org/x/tools" + packages = [ + "go/ast/astutil", + "go/gcexportdata", + "go/internal/cgo", + "go/internal/gcimporter", + "go/internal/packagesdriver", + "go/packages", + "go/types/typeutil", + "imports", + "internal/fastwalk", + "internal/gopathwalk", + "internal/module", + "internal/semver" + ] + revision = "f727befe758c04ce68d52abc6e69ad111e2c6797" + +[[projects]] + name = "google.golang.org/api" + packages = [ + "googleapi/transport", + "internal", + "iterator", + "option", + "support/bundler", + "transport", + "transport/grpc", + "transport/http", + "transport/http/internal/propagation" + ] + revision = "19e022d8cf43ce81f046bae8cc18c5397cc7732f" + version = "v0.1.0" + +[[projects]] + name = "google.golang.org/appengine" + packages = [ + ".", + "internal", + "internal/app_identity", + "internal/base", + "internal/datastore", + "internal/log", + "internal/modules", + "internal/remote_api", + "internal/socket", + "internal/urlfetch", + "socket", + "urlfetch" + ] + revision = "e9657d882bb81064595ca3b56cbe2546bbabf7b1" + version = "v1.4.0" + +[[projects]] + branch = "master" + name = "google.golang.org/genproto" + packages = [ + "googleapis/api/annotations", + "googleapis/iam/v1", + "googleapis/pubsub/v1", + "googleapis/rpc/status", + "protobuf/field_mask" + ] + revision = "fc2db5cae922db113989ef87b5b859cc8a179f59" + +[[projects]] + name = "google.golang.org/grpc" + packages = [ + ".", + "balancer", + "balancer/base", + "balancer/roundrobin", + "binarylog/grpc_binarylog_v1", + "codes", + "connectivity", + "credentials", + "credentials/internal", + "credentials/oauth", + "encoding", + "encoding/proto", + "grpclog", + "internal", + "internal/backoff", + "internal/binarylog", + "internal/channelz", + "internal/envconfig", + "internal/grpcrand", + "internal/grpcsync", + "internal/syscall", + "internal/transport", + "keepalive", + "metadata", + "naming", + "peer", + "resolver", + "resolver/dns", + "resolver/passthrough", + "stats", + "status", + "tap" + ] + revision = "2fdaae294f38ed9a121193c51ec99fecd3b13eb7" + version = "v1.19.0" + +[[projects]] + name = "gopkg.in/inf.v0" + packages = ["."] + revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" + version = "v0.9.1" + +[[projects]] + name = "gopkg.in/ini.v1" + packages = ["."] + revision = "c85607071cf08ca1adaf48319cd1aa322e81d8c1" + version = "v1.42.0" + +[[projects]] + name = "gopkg.in/src-d/go-billy.v4" + packages = [ + ".", + "helper/chroot", + "helper/polyfill", + "osfs", + "util" + ] + revision = "982626487c60a5252e7d0b695ca23fb0fa2fd670" + version = "v4.3.0" + +[[projects]] + name = "gopkg.in/src-d/go-git.v4" + packages = [ + ".", + "config", + "internal/revision", + "internal/url", + "plumbing", + "plumbing/cache", + "plumbing/filemode", + "plumbing/format/config", + "plumbing/format/diff", + "plumbing/format/gitignore", + "plumbing/format/idxfile", + "plumbing/format/index", + "plumbing/format/objfile", + "plumbing/format/packfile", + "plumbing/format/pktline", + "plumbing/object", + "plumbing/protocol/packp", + "plumbing/protocol/packp/capability", + "plumbing/protocol/packp/sideband", + "plumbing/revlist", + "plumbing/storer", + "plumbing/transport", + "plumbing/transport/client", + "plumbing/transport/file", + "plumbing/transport/git", + "plumbing/transport/http", + "plumbing/transport/internal/common", + "plumbing/transport/server", + "plumbing/transport/ssh", + "storage", + "storage/filesystem", + "storage/filesystem/dotgit", + "storage/memory", + "utils/binary", + "utils/diff", + "utils/ioutil", + "utils/merkletrie", + "utils/merkletrie/filesystem", + "utils/merkletrie/index", + "utils/merkletrie/internal/frame", + "utils/merkletrie/noder" + ] + revision = "db6c41c156481962abf9a55a324858674c25ab08" + version = "v4.10.0" + +[[projects]] + name = "gopkg.in/warnings.v0" + packages = ["."] + revision = "ec4a0fea49c7b46c2aeb0b51aac55779c607e52b" + version = "v0.1.2" + +[[projects]] + name = "gopkg.in/yaml.v2" + packages = ["."] + revision = "51d6538a90f86fe93ac480b35f37b2be17fef232" + version = "v2.2.2" + +[[projects]] + branch = "release-1.10" + name = "k8s.io/api" + packages = [ + "admissionregistration/v1alpha1", + "admissionregistration/v1beta1", + "apps/v1", + "apps/v1beta1", + "apps/v1beta2", + "authentication/v1", + "authentication/v1beta1", + "authorization/v1", + "authorization/v1beta1", + "autoscaling/v1", + "autoscaling/v2beta1", + "batch/v1", + "batch/v1beta1", + "batch/v2alpha1", + "certificates/v1beta1", + "core/v1", + "events/v1beta1", + "extensions/v1beta1", + "networking/v1", + "policy/v1beta1", + "rbac/v1", + "rbac/v1alpha1", + "rbac/v1beta1", + "scheduling/v1alpha1", + "settings/v1alpha1", + "storage/v1", + "storage/v1alpha1", + "storage/v1beta1" + ] + revision = "c89978d5f86d7427bef2fc7752732c8c60b1d188" + +[[projects]] + branch = "release-1.10" + name = "k8s.io/apimachinery" + packages = [ + "pkg/api/errors", + "pkg/api/meta", + "pkg/api/resource", + "pkg/apis/meta/internalversion", + "pkg/apis/meta/v1", + "pkg/apis/meta/v1/unstructured", + "pkg/apis/meta/v1beta1", + "pkg/conversion", + "pkg/conversion/queryparams", + "pkg/fields", + "pkg/labels", + "pkg/runtime", + "pkg/runtime/schema", + "pkg/runtime/serializer", + "pkg/runtime/serializer/json", + "pkg/runtime/serializer/protobuf", + "pkg/runtime/serializer/recognizer", + "pkg/runtime/serializer/streaming", + "pkg/runtime/serializer/versioning", + "pkg/selection", + "pkg/types", + "pkg/util/cache", + "pkg/util/clock", + "pkg/util/diff", + "pkg/util/errors", + "pkg/util/framer", + "pkg/util/intstr", + "pkg/util/json", + "pkg/util/net", + "pkg/util/runtime", + "pkg/util/sets", + "pkg/util/validation", + "pkg/util/validation/field", + "pkg/util/wait", + "pkg/util/yaml", + "pkg/version", + "pkg/watch", + "third_party/forked/golang/reflect" + ] + revision = "d49e237a2683fa6dc43a86c7b1b766e0219fb6e7" + +[[projects]] + branch = "release-7.0" + name = "k8s.io/client-go" + packages = [ + "discovery", + "discovery/fake", + "dynamic", + "kubernetes", + "kubernetes/fake", + "kubernetes/scheme", + "kubernetes/typed/admissionregistration/v1alpha1", + "kubernetes/typed/admissionregistration/v1alpha1/fake", + "kubernetes/typed/admissionregistration/v1beta1", + "kubernetes/typed/admissionregistration/v1beta1/fake", + "kubernetes/typed/apps/v1", + "kubernetes/typed/apps/v1/fake", + "kubernetes/typed/apps/v1beta1", + "kubernetes/typed/apps/v1beta1/fake", + "kubernetes/typed/apps/v1beta2", + "kubernetes/typed/apps/v1beta2/fake", + "kubernetes/typed/authentication/v1", + "kubernetes/typed/authentication/v1/fake", + "kubernetes/typed/authentication/v1beta1", + "kubernetes/typed/authentication/v1beta1/fake", + "kubernetes/typed/authorization/v1", + "kubernetes/typed/authorization/v1/fake", + "kubernetes/typed/authorization/v1beta1", + "kubernetes/typed/authorization/v1beta1/fake", + "kubernetes/typed/autoscaling/v1", + "kubernetes/typed/autoscaling/v1/fake", + "kubernetes/typed/autoscaling/v2beta1", + "kubernetes/typed/autoscaling/v2beta1/fake", + "kubernetes/typed/batch/v1", + "kubernetes/typed/batch/v1/fake", + "kubernetes/typed/batch/v1beta1", + "kubernetes/typed/batch/v1beta1/fake", + "kubernetes/typed/batch/v2alpha1", + "kubernetes/typed/batch/v2alpha1/fake", + "kubernetes/typed/certificates/v1beta1", + "kubernetes/typed/certificates/v1beta1/fake", + "kubernetes/typed/core/v1", + "kubernetes/typed/core/v1/fake", + "kubernetes/typed/events/v1beta1", + "kubernetes/typed/events/v1beta1/fake", + "kubernetes/typed/extensions/v1beta1", + "kubernetes/typed/extensions/v1beta1/fake", + "kubernetes/typed/networking/v1", + "kubernetes/typed/networking/v1/fake", + "kubernetes/typed/policy/v1beta1", + "kubernetes/typed/policy/v1beta1/fake", + "kubernetes/typed/rbac/v1", + "kubernetes/typed/rbac/v1/fake", + "kubernetes/typed/rbac/v1alpha1", + "kubernetes/typed/rbac/v1alpha1/fake", + "kubernetes/typed/rbac/v1beta1", + "kubernetes/typed/rbac/v1beta1/fake", + "kubernetes/typed/scheduling/v1alpha1", + "kubernetes/typed/scheduling/v1alpha1/fake", + "kubernetes/typed/settings/v1alpha1", + "kubernetes/typed/settings/v1alpha1/fake", + "kubernetes/typed/storage/v1", + "kubernetes/typed/storage/v1/fake", + "kubernetes/typed/storage/v1alpha1", + "kubernetes/typed/storage/v1alpha1/fake", + "kubernetes/typed/storage/v1beta1", + "kubernetes/typed/storage/v1beta1/fake", + "pkg/apis/clientauthentication", + "pkg/apis/clientauthentication/v1alpha1", + "pkg/version", + "plugin/pkg/client/auth/exec", + "rest", + "rest/watch", + "testing", + "tools/auth", + "tools/cache", + "tools/clientcmd", + "tools/clientcmd/api", + "tools/clientcmd/api/latest", + "tools/clientcmd/api/v1", + "tools/metrics", + "tools/pager", + "tools/reference", + "transport", + "util/buffer", + "util/cert", + "util/flowcontrol", + "util/homedir", + "util/integer", + "util/retry", + "util/workqueue" + ] + revision = "36368dede29baa5ecd253416d70ddc0c76bde69b" + +[[projects]] + branch = "release-1.10" + name = "k8s.io/code-generator" + packages = [ + "cmd/client-gen", + "cmd/client-gen/args", + "cmd/client-gen/generators", + "cmd/client-gen/generators/fake", + "cmd/client-gen/generators/scheme", + "cmd/client-gen/generators/util", + "cmd/client-gen/path", + "cmd/client-gen/types", + "cmd/deepcopy-gen", + "cmd/deepcopy-gen/args", + "cmd/defaulter-gen", + "cmd/defaulter-gen/args", + "cmd/go-to-protobuf", + "cmd/go-to-protobuf/protobuf", + "cmd/go-to-protobuf/protoc-gen-gogo", + "cmd/informer-gen", + "cmd/informer-gen/args", + "cmd/informer-gen/generators", + "cmd/lister-gen", + "cmd/lister-gen/args", + "cmd/lister-gen/generators", + "cmd/openapi-gen", + "cmd/openapi-gen/args", + "pkg/util", + "third_party/forked/golang/reflect" + ] + revision = "edc41f23fa918716df540b1486477d62237010e4" + +[[projects]] + branch = "master" + name = "k8s.io/gengo" + packages = [ + "args", + "examples/deepcopy-gen/generators", + "examples/defaulter-gen/generators", + "examples/set-gen/sets", + "generator", + "namer", + "parser", + "types" + ] + revision = "0689ccc1d7d65d9dd1bedcc3b0b1ed7df91ba266" + +[[projects]] + name = "k8s.io/klog" + packages = ["."] + revision = "71442cd4037d612096940ceb0f3fec3f7fff66e0" + version = "v0.2.0" + +[[projects]] + branch = "master" + name = "k8s.io/kube-openapi" + packages = [ + "cmd/openapi-gen/args", + "pkg/common", + "pkg/generators", + "pkg/generators/rules", + "pkg/util/sets" + ] + revision = "d50a959ae76a85c7c262a9767ef29f37093c2b8a" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "5e915519f3d58e29852c3895beca1281785e78e2d1b7075cb9675c779269a352" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Makefile b/Makefile index c411d6f0f6..60da9f6d63 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ override LDFLAGS += \ # docker image publishing options DOCKER_PUSH?=true IMAGE_NAMESPACE?=argoproj -IMAGE_TAG?=v0.7 +IMAGE_TAG?=v0.8 ifeq (${DOCKER_PUSH},true) ifndef IMAGE_NAMESPACE diff --git a/examples/gateways/aws-sns-gateway-configmap.yaml b/examples/gateways/aws-sns-gateway-configmap.yaml new file mode 100644 index 0000000000..7c71730a80 --- /dev/null +++ b/examples/gateways/aws-sns-gateway-configmap.yaml @@ -0,0 +1,17 @@ +# For more information, https://github.com/argoproj/argo-events/blob/e0242e7b00f7edc7e0cff314abd3a728ddf3c62b/gateways/community/aws-sns/config.go#L68 +apiVersion: v1 +kind: ConfigMap +metadata: + name: aws-sns-gateway-configmap +data: + notification_1: |- + topicArn: "topic-arn" + endpoint: "/" + port: "9600" + accessKey: + name: aws-secret + key: access + secretKey: + name aws-secret + key: secret + region: "us-east-1" diff --git a/examples/gateways/aws-sns.yaml b/examples/gateways/aws-sns.yaml new file mode 100644 index 0000000000..b986291f08 --- /dev/null +++ b/examples/gateways/aws-sns.yaml @@ -0,0 +1,35 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Gateway +metadata: + name: aws-sns-gateway + labels: + gateways.argoproj.io/gateway-controller-instanceid: argo-events + gateway-name: "aws-sns-gateway" +spec: + processorPort: "9330" + eventProtocol: + type: "HTTP" + http: + port: "9300" + deploySpec: + metadata: + name: "aws-sns-gateway" + labels: + gateway-name: "aws-sns-gateway" + spec: + containers: + - name: "gateway-client" + image: "argoproj/gateway-client" + imagePullPolicy: "Always" + command: ["/bin/gateway-client"] + - name: "aws-sns-events" + image: "argoproj/aws-sns-gateway" + imagePullPolicy: "Always" + command: ["/bin/aws-sns-gateway"] + serviceAccountName: "argo-events-sa" + configMap: "aws-sns-gateway-configmap" + eventVersion: "1.0" + type: "aws-sns" + watchers: + sensors: + - name: "aws-sns-sensor" diff --git a/examples/gateways/resource-gateway-configmap.yaml b/examples/gateways/resource-gateway-configmap.yaml index 10276dcf46..7fb8964a27 100644 --- a/examples/gateways/resource-gateway-configmap.yaml +++ b/examples/gateways/resource-gateway-configmap.yaml @@ -1,9 +1,10 @@ +# For more information, https://github.com/argoproj/argo-events/blob/e0242e7b00f7edc7e0cff314abd3a728ddf3c62b/gateways/core/resource/config.go#L34 apiVersion: v1 kind: ConfigMap metadata: name: resource-gateway-configmap data: - foo: |- + workflow-success: |- namespace: argo-events group: "argoproj.io" version: "v1alpha1" @@ -12,7 +13,7 @@ data: labels: workflows.argoproj.io/phase: Succeeded name: "my-workflow" - bar: |- + namespace: |- namespace: argo-events group: "k8s.io" version: "v1" diff --git a/examples/sensors/resource.yaml b/examples/sensors/resource.yaml index d19fdac33d..56948c7f36 100644 --- a/examples/sensors/resource.yaml +++ b/examples/sensors/resource.yaml @@ -16,7 +16,7 @@ spec: http: port: "9300" dependencies: - - name: "resource-gateway:foo" + - name: "resource-gateway:workflow-success" triggers: - name: argo-workflow resource: diff --git a/examples/sensors/webhook-http-boolean.yaml b/examples/sensors/webhook-http-boolean.yaml new file mode 100644 index 0000000000..32818cdaed --- /dev/null +++ b/examples/sensors/webhook-http-boolean.yaml @@ -0,0 +1,85 @@ +# The dependency grouping and selective workflow trigger execution is not supported in latest release +# This feature will be released in next release v0.8. +# You can try this example with sensor and sensor controller image v0.7.1 +apiVersion: argoproj.io/v1alpha1 +kind: Sensor +metadata: + name: webhook-sensor-http-boolean-op + labels: + sensors.argoproj.io/sensor-controller-instanceid: argo-events +spec: + deploySpec: + containers: + - name: "sensor" + image: "argoproj/sensor" + imagePullPolicy: Always + serviceAccountName: argo-events-sa + # defines list of all events sensor will accept + dependencies: + - name: "webhook-gateway-http:foo" + - name: "webhook-gateway-http:index" + # divides event dependencies into groups + dependencyGroups: + - name: "group_1" + dependencies: + - "webhook-gateway-http:foo" + - name: "group_2" + dependencies: + - "webhook-gateway-http:index" + # either "webhook-gateway-http:foo" or "webhook-gateway-http:index" happens + circuit: "group_1 || group_2" + eventProtocol: + type: "HTTP" + http: + port: "9300" + triggers: + - name: webhook-workflow-trigger + when: + all: + - "group_1" + resource: + namespace: argo-events + group: argoproj.io + version: v1alpha1 + kind: Workflow + source: + inline: | + apiVersion: argoproj.io/v1alpha1 + kind: Workflow + metadata: + generateName: hello-world- + spec: + entrypoint: whalesay + templates: + - name: whalesay + container: + args: + - "hello world" + command: + - cowsay + image: "docker/whalesay:latest" + - name: webhook-workflow-trigger-2 + when: + all: + - "group_2" + resource: + namespace: argo-events + group: argoproj.io + version: v1alpha1 + kind: Workflow + source: + inline: | + apiVersion: argoproj.io/v1alpha1 + kind: Workflow + metadata: + generateName: hello-world-2- + spec: + entrypoint: whalesay + templates: + - name: whalesay + container: + args: + - "hello world" + command: + - cowsay + image: "docker/whalesay:latest" diff --git a/gateways/community/aws-sns/Dockerfile b/gateways/community/aws-sns/Dockerfile index b6e15d1dfd..dbcfa27bbe 100644 --- a/gateways/community/aws-sns/Dockerfile +++ b/gateways/community/aws-sns/Dockerfile @@ -1,3 +1,3 @@ FROM scratch -COPY dist/sns-gateway /bin/ -ENTRYPOINT [ "/bin/sns-gateway" ] +COPY dist/aws-sns-gateway /bin/ +ENTRYPOINT [ "/bin/aws-sns-gateway" ] diff --git a/gateways/core/calendar/start.go b/gateways/core/calendar/start.go index b99346f706..fa9eb9bf3b 100644 --- a/gateways/core/calendar/start.go +++ b/gateways/core/calendar/start.go @@ -113,9 +113,10 @@ func (ese *CalendarEventSourceExecutor) listenEvents(cal *calSchedule, eventSour for { t := next(lastT) timer := time.After(time.Until(t)) - ese.Log.Info().Str("event-source-name", eventSource.Name).Str("time", t.String()).Msg("expected next calendar event") + ese.Log.Info().Str("event-source-name", eventSource.Name).Str("time", t.UTC().String()).Msg("expected next calendar event") select { case tx := <-timer: + lastT = tx response := &calResponse{ EventTime: tx, UserPayload: cal.UserPayload, diff --git a/gateways/core/resource/Dockerfile b/gateways/core/resource/Dockerfile index b293d6dd01..0012045346 100644 --- a/gateways/core/resource/Dockerfile +++ b/gateways/core/resource/Dockerfile @@ -1,3 +1,3 @@ -FROM centos:7 +FROM scratch COPY dist/resource-gateway /bin/ ENTRYPOINT [ "/bin/resource-gateway" ] \ No newline at end of file diff --git a/gateways/core/resource/start.go b/gateways/core/resource/start.go index 78eb1b051f..82a96501e9 100644 --- a/gateways/core/resource/start.go +++ b/gateways/core/resource/start.go @@ -17,6 +17,8 @@ limitations under the License. package resource import ( + "encoding/json" + "fmt" "strings" "github.com/argoproj/argo-events/gateways" @@ -52,11 +54,6 @@ func (ese *ResourceEventSourceExecutor) StartEventSource(eventSource *gateways.E func (ese *ResourceEventSourceExecutor) listenEvents(res *resource, eventSource *gateways.EventSource, dataCh chan []byte, errorCh chan error, doneCh chan struct{}) { defer gateways.Recover(eventSource.Name) - resources, err := ese.discoverResources(res) - if err != nil { - errorCh <- err - return - } options := metav1.ListOptions{Watch: true} if res.Filter != nil { options.LabelSelector = labels.Set(res.Filter.Labels).AsSelector().String() @@ -64,97 +61,146 @@ func (ese *ResourceEventSourceExecutor) listenEvents(res *resource, eventSource ese.Log.Info().Str("event-source-name", eventSource.Name).Msg("starting to watch to resource notifications") - // global quit channel - quitChan := make(chan struct{}) - // start up listeners - for i := 0; i < len(resources); i++ { - resource := resources[i] - w, err := resource.Watch(options) - if err != nil { - errorCh <- err - return - } + resourceList, err := ese.discoverResources(res) + if err != nil { + errorCh <- err + return + } + + apiResource, err := ese.serverResourceForGVK(resourceList, res.Kind) + if err != nil { + errorCh <- err + return + } + + if !ese.canWatchResource(apiResource) { + errorCh <- fmt.Errorf("watch functionality is not allowed on resource") + return + } + + dynClientPool := dynamic.NewDynamicClientPool(ese.K8RestConfig) + + gvk := schema.FromAPIVersionAndKind(resourceList.GroupVersion, apiResource.Kind) + client, err := dynClientPool.ClientForGroupVersionKind(gvk) + if err != nil { + errorCh <- err + return + } + + watcher, err := client.Resource(apiResource, res.Namespace).Watch(options) + if err != nil { + errorCh <- err + return + } + + watchCh := make(chan struct{}) + // key is group version kind name + resourceObjects := make(map[string]string) + + localDoneCh := doneCh + + go ese.watchObjectChannel(watcher, res, eventSource, resourceObjects, dataCh, errorCh, watchCh, localDoneCh) + + // renews watch + // Todo: we shouldn't keep on renewing watch by ourselves but rather use dynamicinformer NewFilteredDynamicSharedInformerFactory https://github.com/kubernetes/client-go/blob/master/dynamic/dynamicinformer/informer.go + // But this is available from go client release 1.10. It is not possible to upgrade without upgrading Argo, because it has dependency on release 1.9 + // Resolution- Create PR for Argo to upgrade go client version. - localQuitChan := quitChan - - go func() { - for { - select { - case item := <-w.ResultChan(): - if item.Object == nil { - ese.Log.Warn().Str("event-source-name", eventSource.Name).Msg("object to watch is nil") - // renew watch - newWatch, err := resource.Watch(options) - if err != nil { - continue - } - w = newWatch - } - itemObj := item.Object.(*unstructured.Unstructured) - b, err := itemObj.MarshalJSON() - if err != nil { - errorCh <- err - localQuitChan <- struct{}{} - return - } - if item.Type == watch.Error { - err = errors.FromObject(item.Object) - errorCh <- err - localQuitChan <- struct{}{} - return - } - if ese.passFilters(eventSource.Name, itemObj, res.Filter) { - dataCh <- b - } - - case <-localQuitChan: + go func() { + for { + select { + case <-watchCh: + watcher, err := client.Resource(apiResource, res.Namespace).Watch(options) + if err != nil { + errorCh <- err return } + go ese.watchObjectChannel(watcher, res, eventSource, resourceObjects, dataCh, errorCh, watchCh, localDoneCh) + case <-localDoneCh: + return } - }() - } + } + }() <-doneCh - close(quitChan) + close(doneCh) } -func (ese *ResourceEventSourceExecutor) discoverResources(obj *resource) ([]dynamic.ResourceInterface, error) { - dynClientPool := dynamic.NewDynamicClientPool(ese.K8RestConfig) - disco, err := discovery.NewDiscoveryClientForConfig(ese.K8RestConfig) - if err != nil { - return nil, err +func (ese *ResourceEventSourceExecutor) watchObjectChannel(watcher watch.Interface, res *resource, eventSource *gateways.EventSource, resourceObjects map[string]string, dataCh chan []byte, errorCh chan error, watchCh chan struct{}, doneCh chan struct{}) { + for { + select { + case item := <-watcher.ResultChan(): + if item.Object == nil { + ese.Log.Info().Str("event-source-name", eventSource.Name).Msg("watch ended, creating a new watch") + watchCh <- struct{}{} + return + } + itemObj, isUnst := item.Object.(*unstructured.Unstructured) + if !isUnst { + continue + } + b, err := itemObj.MarshalJSON() + if err != nil { + errorCh <- err + return + } + if item.Type == watch.Error { + err = errors.FromObject(item.Object) + errorCh <- err + return + } + + resourceKey := fmt.Sprintf("%s%s%s%s", res.GroupVersionKind.Group, res.GroupVersionKind.Version, res.GroupVersionKind.Kind, itemObj.GetName()) + + watchedObj, _ := json.Marshal((*itemObj).DeepCopyObject()) + + if obj, ok := resourceObjects[resourceKey]; ok { + if string(watchedObj) == obj { + ese.Log.Info().Str("event-source-name", eventSource.Name).Msg("update is already watched") + continue + } + } + resourceObjects[resourceKey] = string(watchedObj) + + if ese.passFilters(eventSource.Name, itemObj, res.Filter) { + dataCh <- b + } + + case <-doneCh: + return + } } +} - groupVersion := ese.resolveGroupVersion(obj) - resourceInterfaces, err := disco.ServerResourcesForGroupVersion(groupVersion) +func (ese *ResourceEventSourceExecutor) discoverResources(obj *resource) (*metav1.APIResourceList, error) { + disco, err := discovery.NewDiscoveryClientForConfig(ese.K8RestConfig) if err != nil { return nil, err } + groupVersion := ese.resolveGroupVersion(obj) + return disco.ServerResourcesForGroupVersion(groupVersion) +} - resources := make([]dynamic.ResourceInterface, 0) +func (ese *ResourceEventSourceExecutor) serverResourceForGVK(resourceInterfaces *metav1.APIResourceList, kind string) (*metav1.APIResource, error) { for i := range resourceInterfaces.APIResources { apiResource := resourceInterfaces.APIResources[i] gvk := schema.FromAPIVersionAndKind(resourceInterfaces.GroupVersion, apiResource.Kind) ese.Log.Info().Str("api-resource", gvk.String()) - if apiResource.Kind != obj.Kind { - continue - } - canWatch := false - for _, verb := range apiResource.Verbs { - if verb == "watch" { - canWatch = true - break - } + if apiResource.Kind == kind { + return &apiResource, nil } - if canWatch { - client, err := dynClientPool.ClientForGroupVersionKind(gvk) - if err != nil { - return nil, err - } - resources = append(resources, client.Resource(&apiResource, obj.Namespace)) + } + ese.Log.Warn().Str("kind", kind).Msg("no resource found") + return nil, fmt.Errorf("no resource found") +} + +func (ese *ResourceEventSourceExecutor) canWatchResource(apiResource *metav1.APIResource) bool { + for _, verb := range apiResource.Verbs { + if verb == "watch" { + return true } } - return resources, nil + return false } func (ese *ResourceEventSourceExecutor) resolveGroupVersion(obj *resource) string {