Skip to content

Commit

Permalink
Add doc files to the sources field
Browse files Browse the repository at this point in the history
  • Loading branch information
alonsodomin committed May 31, 2022
1 parent d92df04 commit 9fbd2df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 56 deletions.
44 changes: 6 additions & 38 deletions src/python/pants/backend/helm/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Dependencies,
FieldSet,
MultipleSourcesField,
OptionalSingleSourceField,
SingleSourceField,
StringField,
StringSequenceField,
Expand Down Expand Up @@ -108,48 +107,25 @@ class HelmChartMetaSourceField(SingleSourceField):

class HelmChartSourcesField(MultipleSourcesField):
default = (
".helmignore",
"README.md",
"LICENSE",
"values.yaml",
"values.yml",
"values.schema.json",
"templates/*.yaml",
"templates/*.yml",
"templates/*.tpl",
"templates/NOTES.txt",
"crds/*.yaml",
"crds/*.yml",
)
expected_file_extensions = (".yaml", ".yml", ".tpl")
expected_file_extensions = (".helmignore", ".yaml", ".yml", ".tpl", ".json", ".md", ".txt", "")
help = generate_multiple_sources_field_help_message(
"Example: `sources=['values.yaml', 'templates/*.yaml', '!values_ignore.yaml']`"
)


class HelmChartReadmeField(OptionalSingleSourceField):
alias = "readme"
default = "README.md"
help = "Main documentation for the Helm chart"
expected_file_extensions = (".md",)


class HelmChartLicenseField(OptionalSingleSourceField):
alias = "license"
default = "LICENSE"
help = "A plain text file containing the license for the chart"
expected_file_extensions = ("",)


class HelmChartSchemaField(OptionalSingleSourceField):
alias = "schema"
default = "values.schema.json"
help = "A JSON Schema for imposing a structure on the `values.yaml` file"
expected_file_extensions = (".json",)


class HelmChartNotesField(OptionalSingleSourceField):
alias = "notes"
default = "templates/NOTES.txt"
help = "A plain text file containing short usage notes"
expected_file_extensions = (".txt",)


class HelmChartDependenciesField(Dependencies):
pass

Expand Down Expand Up @@ -205,10 +181,6 @@ class HelmChartTarget(Target):
HelmChartOutputPathField,
HelmChartLintStrictField,
HelmChartRepositoryField,
HelmChartReadmeField,
HelmChartLicenseField,
HelmChartSchemaField,
HelmChartNotesField,
HelmRegistriesField,
HelmSkipPushField,
HelmSkipLintField,
Expand All @@ -226,10 +198,6 @@ class HelmChartFieldSet(FieldSet):
chart: HelmChartMetaSourceField
sources: HelmChartSourcesField
dependencies: HelmChartDependenciesField
readme: HelmChartReadmeField
license: HelmChartLicenseField
schema: HelmChartSchemaField
notes: HelmChartNotesField


class AllHelmChartTargets(Targets):
Expand Down
20 changes: 2 additions & 18 deletions src/python/pants/backend/helm/util_rules/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

from pants.backend.helm.target_types import (
HelmChartFieldSet,
HelmChartLicenseField,
HelmChartMetaSourceField,
HelmChartNotesField,
HelmChartReadmeField,
HelmChartSchemaField,
HelmChartSourcesField,
)
from pants.core.target_types import FileSourceField, ResourceSourceField
Expand Down Expand Up @@ -63,26 +59,14 @@ def for_field_set(

@property
def sources_fields(self) -> tuple[SourcesField, ...]:
fields: list[SourcesField] = [
self.field_set.sources,
self.field_set.readme,
self.field_set.license,
self.field_set.schema,
self.field_set.notes,
]
fields: list[SourcesField] = [self.field_set.sources]
if self.include_metadata:
fields.append(self.field_set.chart)
return tuple(fields)

@property
def valid_sources_types(self) -> tuple[type[SourcesField], ...]:
types: list[type[SourcesField]] = [
HelmChartSourcesField,
HelmChartReadmeField,
HelmChartSchemaField,
HelmChartLicenseField,
HelmChartNotesField,
]
types: list[type[SourcesField]] = [HelmChartSourcesField]
if self.include_metadata:
types.append(HelmChartMetaSourceField)
if self.include_resources:
Expand Down

0 comments on commit 9fbd2df

Please sign in to comment.