Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서승완
/
kappa
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Mitch Garnaat
2015-02-08 15:05:22 -0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
42319f50196bcd83d43a1c7247326757a9803a22
42319f50
1 parent
c4c560d6
Merging changes.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
4 deletions
bin/kappa
kappa/event_source.py
kappa/log.py
requirements.txt
setup.py
bin/kappa
View file @
42319f5
...
...
@@ -34,7 +34,7 @@ from kappa.context import Context
@click.argument
(
'command'
,
required
=
True
,
type
=
click
.
Choice
([
'deploy'
,
'test'
,
'tail'
,
'add-event-source'
,
'delete'
])
type
=
click
.
Choice
([
'deploy'
,
'test'
,
'tail'
,
'add-event-source
s
'
,
'delete'
])
)
def
main
(
config
=
None
,
debug
=
False
,
command
=
None
):
ctx
=
Context
(
config
,
debug
)
...
...
@@ -54,7 +54,7 @@ def main(config=None, debug=False, command=None):
click
.
echo
(
'Deleting ...'
)
ctx
.
delete
()
click
.
echo
(
'...done'
)
elif
command
==
'add-event-source'
:
elif
command
==
'add-event-source
s
'
:
click
.
echo
(
'Adding event sources ...'
)
ctx
.
add_event_sources
()
click
.
echo
(
'...done'
)
...
...
kappa/event_source.py
View file @
42319f5
...
...
@@ -100,6 +100,15 @@ class S3EventSource(EventSource):
LOG
.
exception
(
'Unable to add S3 event source'
)
def
remove
(
self
,
function
):
LOG
.
debug
(
'removing s3 notification'
)
response
=
self
.
_s3
.
get_bucket_notification
(
Bucket
=
self
.
_get_bucket_name
())
LOG
.
debug
(
response
)
if
'CloudFunctionConfiguration'
in
response
:
fn_arn
=
response
[
'CloudFunctionConfiguration'
][
'CloudFunction'
]
if
fn_arn
==
function
.
arn
:
del
response
[
'CloudFunctionConfiguration'
]
response
=
self
.
_s3
.
put_bucket_notification
(
Bucket
=
self
.
_get_bucket_name
(),
NotificationConfiguration
=
response
)
LOG
.
debug
(
response
)
...
...
kappa/log.py
View file @
42319f5
...
...
@@ -26,8 +26,18 @@ class Log(object):
aws
=
kappa
.
aws
.
get_aws
(
self
.
_context
)
self
.
_log_svc
=
aws
.
create_client
(
'logs'
)
def
_check_for_log_group
(
self
):
LOG
.
debug
(
'checking for log group'
)
response
=
self
.
_log_svc
.
describe_log_groups
()
log_group_names
=
[
lg
[
'logGroupName'
]
for
lg
in
response
[
'logGroups'
]]
return
self
.
log_group_name
in
log_group_names
def
streams
(
self
):
LOG
.
debug
(
'getting streams for log group:
%
s'
,
self
.
log_group_name
)
if
not
self
.
_check_for_log_group
():
LOG
.
info
(
'log group
%
s has not been created yet'
,
self
.
log_group_name
)
return
[]
response
=
self
.
_log_svc
.
describe_log_streams
(
logGroupName
=
self
.
log_group_name
)
LOG
.
debug
(
response
)
...
...
@@ -35,6 +45,10 @@ class Log(object):
def
tail
(
self
):
LOG
.
debug
(
'tailing log group:
%
s'
,
self
.
log_group_name
)
if
not
self
.
_check_for_log_group
():
LOG
.
info
(
'log group
%
s has not been created yet'
,
self
.
log_group_name
)
return
[]
latest_stream
=
None
streams
=
self
.
streams
()
for
stream
in
streams
:
...
...
requirements.txt
View file @
42319f5
botocore==0.8
0
.0
botocore==0.8
2
.0
click==3.3
PyYAML>=3.11
mock>=1.0.1
...
...
setup.py
View file @
42319f5
...
...
@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
import
os
requires
=
[
'botocore==0.8
0
.0'
,
'botocore==0.8
2
.0'
,
'click==3.3'
,
'PyYAML>=3.11'
]
...
...
Please
register
or
login
to post a comment