Skip to content

Commit

Permalink
add option to skip manifest checks
Browse files Browse the repository at this point in the history
  • Loading branch information
james-eichelbaum committed Sep 23, 2024
1 parent e469a2a commit 6914a34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
22 changes: 12 additions & 10 deletions datadog_checks_dev/datadog_checks/dev/tooling/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def _valid_template_description():
@click.option('--non-interactive', '-ni', is_flag=True, help='Disable prompting for fields')
@click.option('--quiet', '-q', is_flag=True, help='Show less output')
@click.option('--dry-run', '-n', is_flag=True, help='Only show what would be created')
@click.option('--skip-manifest', is_flag=True, help='Prevents validating the manfiest for check_only')
@click.pass_context
def create(ctx, name, integration_type, location, non_interactive, quiet, dry_run):
def create(ctx, name, integration_type, location, non_interactive, quiet, dry_run, skip_manifest):
"""
Create scaffolding for a new integration.
Expand All @@ -180,15 +181,16 @@ def create(ctx, name, integration_type, location, non_interactive, quiet, dry_ru
manifest = {}
# check_only is designed to already have content in it
if integration_type == 'check_only':
if not os.path.exists(os.path.join(integration_dir, "manifest.json")):
abort(f"Expected {integration_dir}/manifest.json to exist")
# The existing integration folder already includes the author name, strip it out
with open(f"{integration_dir_name}/manifest.json", "r") as manifest:
manifest = json.loads(manifest.read())
author = manifest.get("author", {}).get("name")
if author is None:
abort("Unable to determine author from manifest")
integration_dir_name = integration_dir_name.removeprefix(f"{author}_")
if not skip_manifest:
if not os.path.exists(os.path.join(integration_dir, "manifest.json")):
abort(f"Expected {integration_dir}/manifest.json to exist")
# The existing integration folder already includes the author name, strip it out
with open(f"{integration_dir_name}/manifest.json", "r") as manifest:
manifest = json.loads(manifest.read())
author = manifest.get("author", {}).get("name")
if author is None:
abort("Unable to determine author from manifest")
integration_dir_name = integration_dir_name.removeprefix(f"{author}_")
else:
if os.path.exists(integration_dir):
abort(f'Path `{integration_dir}` already exists!')
Expand Down
16 changes: 10 additions & 6 deletions datadog_checks_dev/datadog_checks/dev/tooling/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ def get_valid_templates():

def prefill_template_fields_for_check_only(manifest: dict, normalized_integration_name: str) -> dict:
author = manifest.get("author", {}).get("name")
check_name = normalize_package_name(f"{author}_{normalized_integration_name}")
check_name = normalize_package_name(f"{author}_{normalized_integration_name}") if author is not None else None
return {
'author_name': author,
'check_name': check_name,
'email': manifest.get("author", {}).get("support_email"),
'homepage': manifest.get("author", {}).get("homepage"),
'sales_email': manifest.get("author", {}).get("sales_email"),
k: v
for k, v in {
'author_name': author,
'check_name': check_name,
'email': manifest.get("author", {}).get("support_email"),
'homepage': manifest.get("author", {}).get("homepage"),
'sales_email': manifest.get("author", {}).get("sales_email"),
}.items()
if v is not None
}


Expand Down

0 comments on commit 6914a34

Please sign in to comment.