Fix fleet package generation (#1296)
* Fix fleet package generation * Add .lstrip() * Lint fix * Add newline
This commit is contained in:
@@ -471,9 +471,9 @@ class Package(object):
|
||||
manifest_file = package_dir / 'manifest.yml'
|
||||
readme_file = docs_dir / 'README.md'
|
||||
notice_file = package_dir / 'NOTICE.txt'
|
||||
logo_file = package_dir / 'img' / 'security-logo-color-64px.png'
|
||||
logo_file = package_dir / 'img' / 'security-logo-color-64px.svg'
|
||||
|
||||
manifest_file.write_text(yaml.safe_dump(manifest.asdict()))
|
||||
manifest_file.write_text(yaml.safe_dump(manifest.to_dict()))
|
||||
|
||||
logo_file.parent.mkdir(parents=True)
|
||||
shutil.copyfile(FLEET_PKG_LOGO, logo_file)
|
||||
@@ -485,7 +485,7 @@ class Package(object):
|
||||
|
||||
notice_contents = Path(NOTICE_FILE).read_text()
|
||||
readme_text = textwrap.dedent("""
|
||||
# Detection rules
|
||||
# Prebuilt Security Detection Rules
|
||||
|
||||
The detection rules package stores the prebuilt security rules for the Elastic Security [detection engine](https://www.elastic.co/guide/en/security/7.13/detection-engine-overview.html).
|
||||
|
||||
@@ -495,7 +495,7 @@ class Package(object):
|
||||
|
||||
## License Notice
|
||||
|
||||
""") + textwrap.indent(notice_contents, prefix=" ") # noqa: E501
|
||||
""").lstrip() + textwrap.indent(notice_contents, prefix=" ") # noqa: E501
|
||||
|
||||
readme_file.write_text(readme_text)
|
||||
notice_file.write_text(notice_contents)
|
||||
|
||||
@@ -5,17 +5,15 @@
|
||||
|
||||
"""Definitions for packages destined for the registry."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Type
|
||||
|
||||
from marshmallow import Schema
|
||||
from marshmallow_dataclass import class_schema
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from .definitions import ConditionSemVer, SemVer
|
||||
from ..mixins import MarshmallowDataclassMixin
|
||||
|
||||
|
||||
@dataclass
|
||||
class RegistryPackageManifest:
|
||||
class RegistryPackageManifest(MarshmallowDataclassMixin):
|
||||
"""Base class for registry packages."""
|
||||
|
||||
categories: List[str]
|
||||
@@ -32,16 +30,5 @@ class RegistryPackageManifest:
|
||||
version: SemVer
|
||||
|
||||
internal: Optional[bool] = None
|
||||
policy_templates: list = field(default_factory=list)
|
||||
screenshots: list = field(default_factory=list)
|
||||
|
||||
@classmethod
|
||||
def get_schema(cls) -> Type[Schema]:
|
||||
return class_schema(cls)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> 'RegistryPackageManifest':
|
||||
return cls.get_schema()().load(obj)
|
||||
|
||||
def asdict(self) -> dict:
|
||||
return self.get_schema()().dump(self)
|
||||
policy_templates: Optional[list] = None
|
||||
screenshots: Optional[list] = None
|
||||
|
||||
Reference in New Issue
Block a user