Skip to content

Commit

Permalink
Fix requirements-agent-release.txt updating (#2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Nov 20, 2018
1 parent a74d24e commit e02e63c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ python-binary-memcached==0.26.1; sys_platform != 'win32'
pyvmomi==v6.5.0.2017.5-1
pywin32==224; sys_platform == 'win32'
redis==2.10.5
requests==2.19.1
requests==2.20.0
requests-kerberos==0.12.0
requests_ntlm==1.1.0
scandir==1.8
Expand Down
41 changes: 25 additions & 16 deletions datadog_checks_dev/datadog_checks/dev/tooling/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,38 @@ def update_version_module(check_name, old_ver, new_ver):
write_file(version_file, contents)


def get_package_name(check_name):
if check_name == 'datadog_checks_base':
return check_name.replace('_', '-')

return 'datadog-{}'.format(check_name.replace('_', '-'))


def get_agent_requirement_line(check, version):
"""
Compose a text line to be used in a requirements.txt file to install a check
pinned to a specific version.
"""
# base check and siblings have no manifest
if check in ('datadog_checks_base', 'datadog_checks_tests_helper'):
return '{}=={}'.format(check.replace("_", "-"), version)
package_name = get_package_name(check)

# base check has no manifest
if check == 'datadog_checks_base':
return '{}=={}'.format(package_name, version)

m = load_manifest(check)
platforms = sorted(m.get('supported_os', []))

# all platforms
if platforms == ALL_PLATFORMS:
return 'datadog-{}=={}'.format(check.replace("_", "-"), version)
return '{}=={}'.format(package_name, version)
# one specific platform
elif len(platforms) == 1:
return "datadog-{}=={}; sys_platform == '{}'".format(
check.replace("_", "-"), version, PLATFORMS_TO_PY.get(platforms[0])
return "{}=={}; sys_platform == '{}'".format(
package_name, version, PLATFORMS_TO_PY.get(platforms[0])
)
# assuming linux+mac here for brevity
elif platforms and 'windows' not in platforms:
return "datadog-{}=={}; sys_platform != 'win32'".format(check.replace("_", "-"), version)
return "{}=={}; sys_platform != 'win32'".format(package_name, version)
else:
raise Exception("Can't parse the `supported_os` list for the check {}: {}".format(check, platforms))

Expand All @@ -67,14 +76,14 @@ def update_agent_requirements(req_file, check, newline):
"""
Replace the requirements line for the given check
"""
old_lines = read_file_lines(req_file)
new_lines = []
package_name = get_package_name(check)
lines = read_file_lines(req_file)

for i, line in enumerate(lines):
current_package_name = line.split('==')[0]

for line in old_lines:
check_name = line.split('==')[0]
if check_name == check:
new_lines.append('{}\n'.format(newline))
else:
new_lines.append(line)
if current_package_name == package_name:
lines[i] = '{}\n'.format(newline)
break

write_file_lines(req_file, new_lines)
write_file_lines(req_file, sorted(lines))
25 changes: 13 additions & 12 deletions requirements-agent-release.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
datadog-active-directory==1.2.0; sys_platform == 'win32'
datadog-activemq==1.1.0
datadog-activemq-xml==1.0.1
datadog-activemq==1.1.0
datadog-apache==1.3.1
datadog-aspdotnet==1.0.0; sys_platform == 'win32'
datadog-btrfs==1.3.0; sys_platform != 'win32'
datadog-cacti==1.1.2; sys_platform == 'linux2'
datadog-cassandra==1.3.0
datadog-cassandra-nodetool==1.0.0
datadog-cassandra==1.3.0
datadog-ceph==1.3.1; sys_platform != 'win32'
datadog-checks-base==4.3.0
datadog-cisco-aci==1.2.1
datadog-cockroachdb==1.0.0
datadog-consul==1.5.2
datadog-coredns==1.0.0; sys_platform == 'linux2'
datadog-couch==2.6.1
datadog-couchbase==1.5.1
datadog-couchbase==1.6.0
datadog-crio==1.0.0
datadog-datadog-checks-base==4.2.0
datadog-directory==1.3.1
datadog-disk==1.4.0
datadog-dns-check==1.1.2
datadog-dotnetclr==1.1.0; sys_platform == 'win32'
datadog-ecs-fargate==1.3.0
datadog-elastic==1.8.0
datadog-elastic==1.9.0
datadog-envoy==1.4.0
datadog-etcd==1.5.1
datadog-etcd==1.6.0
datadog-exchange-server==1.2.0; sys_platform == 'win32'
datadog-fluentd==1.0.1
datadog-gearmand==1.1.1; sys_platform != 'win32'
datadog-gitlab==2.0.0
datadog-gitlab-runner==2.0.0
datadog-go-metro==1.0.0; sys_platform == 'linux2'
datadog-gitlab==2.0.0
datadog-go-expvar==1.0.4
datadog-go-metro==1.0.0; sys_platform == 'linux2'
datadog-gunicorn==1.3.0; sys_platform != 'win32'
datadog-haproxy==1.3.1
datadog-hdfs-datanode==1.3.1; sys_platform != 'win32'
datadog-hdfs-datanode==1.5.0; sys_platform != 'win32'
datadog-hdfs-namenode==1.3.1; sys_platform != 'win32'
datadog-http-check==3.0.0
datadog-iis==2.2.0; sys_platform == 'win32'
datadog-istio==2.0.0
datadog-kafka==1.2.0
datadog-kafka-consumer==1.4.1; sys_platform != 'win32'
datadog-kafka==1.2.0
datadog-kong==1.2.1
datadog-kube-dns==2.0.1
datadog-kube-proxy==3.0.0
Expand All @@ -62,6 +62,7 @@ datadog-nfsstat==1.0.0; sys_platform == 'linux2'
datadog-nginx==3.0.0
datadog-openldap==1.0.0
datadog-openmetrics==1.0.0
datadog-openstack-controller==0.0.1
datadog-openstack==1.5.0
datadog-oracle==1.4.0
datadog-pdh-check==1.3.0; sys_platform == 'win32'
Expand All @@ -83,7 +84,7 @@ datadog-sqlserver==1.7.0; sys_platform == 'win32'
datadog-squid==1.0.2
datadog-ssh-check==1.3.1
datadog-statsd==1.1.1
datadog-supervisord==1.1.3
datadog-supervisord==1.1.4
datadog-system-core==1.1.0
datadog-system-swap==1.2.0
datadog-tcp-check==2.0.2
Expand All @@ -93,7 +94,7 @@ datadog-tomcat==1.2.0
datadog-twemproxy==1.2.1
datadog-varnish==1.2.1
datadog-vault==1.2.0
datadog-vsphere==3.3.1
datadog-vsphere==3.4.0
datadog-win32-event-log==1.3.0; sys_platform == 'win32'
datadog-windows-service==2.0.0; sys_platform == 'win32'
datadog-wmi-check==1.2.0; sys_platform == 'win32'
Expand Down

0 comments on commit e02e63c

Please sign in to comment.