Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Aug 20, 2018
1 parent 3ccdadc commit 33f0856
Show file tree
Hide file tree
Showing 23 changed files with 246 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ def display_path_tree(path_tree):
def create(ctx, name, integration_type, location, non_interactive, quiet, dry_run):
"""Create scaffolding for a new integration."""
repo_choice = ctx.obj['repo_choice']
integration_name = normalize_package_name(name)
root = resolve_path(location) if location else get_root()
path_sep = os.path.sep

integration_dir = os.path.join(root, integration_name)
integration_dir = os.path.join(root, normalize_package_name(name))
if os.path.exists(integration_dir):
abort('Path `{}` already exists!'.format(integration_dir))

Expand All @@ -116,7 +115,7 @@ def create(ctx, name, integration_type, location, non_interactive, quiet, dry_ru
template_fields['email_packages'] = template_fields['email']
click.echo()

config = construct_template_fields(integration_name, repo_choice, **template_fields)
config = construct_template_fields(name, repo_choice, **template_fields)

files = create_template_files(integration_type, root, config, read=not dry_run)
file_paths = [file.file_path.replace('{}{}'.format(root, path_sep), '', 1) for file in files]
Expand Down
16 changes: 13 additions & 3 deletions datadog_checks_dev/datadog_checks/dev/tooling/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
import re
from datetime import datetime
from uuid import uuid4

from .utils import normalize_package_name
from ..utils import (
create_file,
dir_exists,
Expand All @@ -18,14 +20,20 @@

TEMPLATES_DIR = path_join(os.path.dirname(os.path.abspath(__file__)), 'templates')
BINARY_EXTENSIONS = ('.png', )
SIMPLE_NAME = r'^\w+$'


def get_valid_templates():
return sorted(os.listdir(TEMPLATES_DIR))


def construct_template_fields(integration_name, repo_choice, **kwargs):
check_name_cap = integration_name if integration_name.count('_') else integration_name.capitalize()
normalized_integration_name = normalize_package_name(integration_name)
check_name_cap = (
integration_name.capitalize()
if re.match(SIMPLE_NAME, integration_name)
else integration_name
)

if repo_choice == 'core':
author = 'Datadog'
Expand Down Expand Up @@ -56,8 +64,10 @@ def construct_template_fields(integration_name, repo_choice, **kwargs):

config = {
'author': author,
'check_class': '{}Check'.format(''.join(part.capitalize() for part in integration_name.split('_'))),
'check_name': integration_name,
'check_class': '{}Check'.format(
''.join(part.capitalize() for part in normalized_integration_name.split('_'))
),
'check_name': normalized_integration_name,
'check_name_cap': check_name_cap,
'email': email,
'email_packages': email_packages,
Expand Down
2 changes: 2 additions & 0 deletions mycheck/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CHANGELOG - Mycheck

11 changes: 11 additions & 0 deletions mycheck/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
graft datadog_checks
graft tests

include MANIFEST.in
include README.md
include requirements.in
include requirements.txt
include requirements-dev.txt
include manifest.json

global-exclude *.py[cod] __pycache__
49 changes: 49 additions & 0 deletions mycheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Agent Check: Mycheck

## Overview

This check monitors [Mycheck][1].

## Setup

### Installation

The Mycheck check is included in the [Datadog Agent][2] package, so you do not
need to install anything else on your server.

### Configuration

1. Edit the `mycheck.d/conf.yaml` file, in the `conf.d/` folder at the root of your
Agent's configuration directory to start collecting your mycheck performance data.
See the [sample mycheck.d/conf.yaml][3] for all available configuration options.

2. [Restart the Agent][4]

### Validation

[Run the Agent's `status` subcommand][5] and look for `mycheck` under the Checks section.

## Data Collected

### Metrics

Mycheck does not include any metrics.

### Service Checks

Mycheck does not include any service checks.

### Events

Mycheck does not include any events.

## Troubleshooting

Need help? Contact [Datadog Support][6].

[1]: **LINK_TO_INTEGERATION_SITE**
[2]: https://app.datadoghq.com/account/settings#agent
[3]: https://github.com/DataDog/integrations-core/blob/master/mycheck/datadog_checks/mycheck/data/conf.yaml.example
[4]: https://docs.datadoghq.com/agent/faq/agent-commands/#start-stop-restart-the-agent
[5]: https://docs.datadoghq.com/agent/faq/agent-commands/#agent-status-and-information
[6]: https://docs.datadoghq.com/help/
4 changes: 4 additions & 0 deletions mycheck/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
4 changes: 4 additions & 0 deletions mycheck/datadog_checks/mycheck/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '0.0.1'
10 changes: 10 additions & 0 deletions mycheck/datadog_checks/mycheck/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .mycheck import MycheckCheck

__all__ = [
'__version__',
'MycheckCheck'
]
4 changes: 4 additions & 0 deletions mycheck/datadog_checks/mycheck/data/conf.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
init_config:

instances:
- {}
9 changes: 9 additions & 0 deletions mycheck/datadog_checks/mycheck/mycheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from datadog_checks.checks import AgentCheck


class MycheckCheck(AgentCheck):
def check(self, instance):
pass
Empty file added mycheck/logos/avatars-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions mycheck/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"display_name": "Mycheck",
"maintainer": "help@datadoghq.com",
"manifest_version": "1.0.0",
"name": "mycheck",
"metric_prefix": "mycheck.",
"metric_to_check": "",
"creates_events": false,
"short_description": "",
"guid": "9ea78f1c-c0dd-4dc0-8c49-13bd55e59057",
"support": "core",
"supported_os": [
"linux",
"mac_os",
"windows"
],
"public_title": "Datadog-Mycheck Integration",
"categories": [
""
],
"type": "check",
"is_public": true
}
1 change: 1 addition & 0 deletions mycheck/metadata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name
1 change: 1 addition & 0 deletions mycheck/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
datadog-checks-dev
Empty file added mycheck/requirements.in
Empty file.
Empty file added mycheck/requirements.txt
Empty file.
62 changes: 62 additions & 0 deletions mycheck/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from codecs import open # To use a consistent encoding
from os import path

from setuptools import setup

HERE = path.dirname(path.abspath(__file__))

# Get version info
ABOUT = {}
with open(path.join(HERE, 'datadog_checks', 'mycheck', '__about__.py')) as f:
exec(f.read(), ABOUT)

# Get the long description from the README file
with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
long_description = f.read()


CHECKS_BASE_REQ = 'datadog-checks-base'


setup(
name='datadog-mycheck',
version=ABOUT['__version__'],
description='The Mycheck check',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='datadog agent mycheck check',

# The project's main homepage.
url='https://github.com/DataDog/integrations-core',

# Author details
author='Datadog',
author_email='packages@datadoghq.com',

# License
license='BSD-3-Clause',

# See https://pypi.org/classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Topic :: System :: Monitoring',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],

# The package we're going to ship
packages=['datadog_checks', 'datadog_checks.mycheck'],

# Run-time dependencies
install_requires=[CHECKS_BASE_REQ],

# Extra files to ship with the wheel package
include_package_data=True,
)
3 changes: 3 additions & 0 deletions mycheck/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
9 changes: 9 additions & 0 deletions mycheck/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import pytest


@pytest.fixture
def instance():
return {}
11 changes: 11 additions & 0 deletions mycheck/tests/test_mycheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from datadog_checks.mycheck import MycheckCheck


def test_check(aggregator, instance):
check = MycheckCheck('mycheck', {}, {})
check.check(instance)

aggregator.assert_all_metrics_covered()
28 changes: 28 additions & 0 deletions mycheck/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tox]
minversion = 2.0
skip_missing_interpreters = true
basepython = py27
envlist =
{py27,py36}-mycheck
flake8

[testenv]
platform = linux|darwin|win32
deps =
../datadog_checks_base[deps]
-rrequirements-dev.txt
passenv =
DOCKER*
COMPOSE*
commands =
pip install --require-hashes -r requirements.txt
pytest -v

[testenv:flake8]
skip_install = true
deps = flake8
commands = flake8 .

[flake8]
exclude = .eggs,.tox,build
max-line-length = 120

0 comments on commit 33f0856

Please sign in to comment.