Skip to content

Commit

Permalink
Remove repeated defaults for ProducerApp
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Dec 5, 2024
1 parent 519d700 commit d10502a
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 68 deletions.
85 changes: 65 additions & 20 deletions docs/docs/schema/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,10 +1169,17 @@
"type": "object"
},
"backoffLimit": {
"default": 6,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of times to restart an unsuccessful job.",
"title": "Backofflimit",
"type": "integer"
"title": "Backofflimit"
},
"commandLine": {
"additionalProperties": {
Expand Down Expand Up @@ -1206,10 +1213,17 @@
"title": "Configurationenvprefix"
},
"deployment": {
"default": false,
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Deploy the producer as a Kubernetes Deployment (thereby ignoring Job-related configurations)",
"title": "Deployment",
"type": "boolean"
"title": "Deployment"
},
"env": {
"additionalProperties": {
Expand All @@ -1220,10 +1234,17 @@
"type": "object"
},
"failedJobsHistoryLimit": {
"default": 1,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of unsuccessful jobs to retain.",
"title": "Failedjobshistorylimit",
"type": "integer"
"title": "Failedjobshistorylimit"
},
"files": {
"description": "Map of files to mount for the app. File will be mounted as $value.mountPath/$key. $value.content denotes file content (recommended to be used with --set-file).",
Expand Down Expand Up @@ -1353,12 +1374,15 @@
"description": "See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
},
"restartPolicy": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/RestartPolicy"
},
{
"type": "null"
}
],
"default": "OnFailure",
"default": null,
"description": "See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy"
},
"schedule": {
Expand Down Expand Up @@ -1408,16 +1432,30 @@
"description": ""
},
"successfulJobsHistoryLimit": {
"default": 1,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of successful jobs to retain.",
"title": "Successfuljobshistorylimit",
"type": "integer"
"title": "Successfuljobshistorylimit"
},
"suspend": {
"default": false,
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Whether to suspend the execution of the cron job.",
"title": "Suspend",
"type": "boolean"
"title": "Suspend"
},
"tolerations": {
"description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.",
Expand All @@ -1428,10 +1466,17 @@
"type": "array"
},
"ttlSecondsAfterFinished": {
"default": 100,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "See https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/#ttl-after-finished-controller",
"title": "Ttlsecondsafterfinished",
"type": "integer"
"title": "Ttlsecondsafterfinished"
}
},
"required": [
Expand Down
85 changes: 65 additions & 20 deletions docs/docs/schema/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,17 @@
"type": "object"
},
"backoffLimit": {
"default": 6,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of times to restart an unsuccessful job.",
"title": "Backofflimit",
"type": "integer"
"title": "Backofflimit"
},
"commandLine": {
"additionalProperties": {
Expand Down Expand Up @@ -866,10 +873,17 @@
"title": "Configurationenvprefix"
},
"deployment": {
"default": false,
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Deploy the producer as a Kubernetes Deployment (thereby ignoring Job-related configurations)",
"title": "Deployment",
"type": "boolean"
"title": "Deployment"
},
"env": {
"additionalProperties": {
Expand All @@ -880,10 +894,17 @@
"type": "object"
},
"failedJobsHistoryLimit": {
"default": 1,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of unsuccessful jobs to retain.",
"title": "Failedjobshistorylimit",
"type": "integer"
"title": "Failedjobshistorylimit"
},
"files": {
"description": "Map of files to mount for the app. File will be mounted as $value.mountPath/$key. $value.content denotes file content (recommended to be used with --set-file).",
Expand Down Expand Up @@ -1013,12 +1034,15 @@
"description": "See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
},
"restartPolicy": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/RestartPolicy"
},
{
"type": "null"
}
],
"default": "OnFailure",
"default": null,
"description": "See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy"
},
"schedule": {
Expand Down Expand Up @@ -1068,16 +1092,30 @@
"description": ""
},
"successfulJobsHistoryLimit": {
"default": 1,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The number of successful jobs to retain.",
"title": "Successfuljobshistorylimit",
"type": "integer"
"title": "Successfuljobshistorylimit"
},
"suspend": {
"default": false,
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Whether to suspend the execution of the cron job.",
"title": "Suspend",
"type": "boolean"
"title": "Suspend"
},
"tolerations": {
"description": "Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling.",
Expand All @@ -1088,10 +1126,17 @@
"type": "array"
},
"ttlSecondsAfterFinished": {
"default": 100,
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "See https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/#ttl-after-finished-controller",
"title": "Ttlsecondsafterfinished",
"type": "integer"
"title": "Ttlsecondsafterfinished"
}
},
"required": [
Expand Down
31 changes: 17 additions & 14 deletions kpops/components/streams_bootstrap/producer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,45 @@ class ProducerAppValues(StreamsBootstrapValues):

kafka: ProducerConfig = Field(description=describe_attr("kafka", __doc__))

deployment: bool = Field(
default=False, description=describe_attr("deployment", __doc__)
deployment: bool | None = Field(
default=None, description=describe_attr("deployment", __doc__)
)

restart_policy: RestartPolicy = Field(
default=RestartPolicy.ON_FAILURE,
restart_policy: RestartPolicy | None = Field(
default=None,
description=describe_attr("restart_policy", __doc__),
)

schedule: str | None = Field(
default=None, description=describe_attr("schedule", __doc__)
)

suspend: bool = Field(default=False, description=describe_attr("suspend", __doc__))
suspend: bool | None = Field(
default=None, description=describe_attr("suspend", __doc__)
)

successful_jobs_history_limit: int = Field(
default=1, description=describe_attr("successful_jobs_history_limit", __doc__)
successful_jobs_history_limit: int | None = Field(
default=None,
description=describe_attr("successful_jobs_history_limit", __doc__),
)

failed_jobs_history_limit: int = Field(
default=1, description=describe_attr("failed_jobs_history_limit", __doc__)
failed_jobs_history_limit: int | None = Field(
default=None, description=describe_attr("failed_jobs_history_limit", __doc__)
)

backoff_limit: int = Field(
default=6, description=describe_attr("backoff_limit", __doc__)
backoff_limit: int | None = Field(
default=None, description=describe_attr("backoff_limit", __doc__)
)

ttl_seconds_after_finished: int = Field(
default=100, description=describe_attr("ttl_seconds_after_finished", __doc__)
ttl_seconds_after_finished: int | None = Field(
default=None, description=describe_attr("ttl_seconds_after_finished", __doc__)
)

model_config = ConfigDict(extra="allow")

@field_validator("schedule")
@classmethod
def schedule_cron_validator(cls, schedule: str) -> str:
def schedule_cron_validator(cls, schedule: str | None) -> str | None:
"""Ensure that the defined schedule value is valid."""
if schedule and not croniter.is_valid(schedule):
msg = f"The schedule field '{schedule}' must be a valid cron expression."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
type: producer-app-cleaner
values:
affinity: {}
backoffLimit: 6
commandLine:
FAKE_ARG: fake-arg-value
deployment: false
env: {}
failedJobsHistoryLimit: 1
files:
log4j2.xml:
content: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Configuration>\n\
Expand All @@ -41,15 +38,11 @@
podLabels: {}
ports: []
readinessProbe: {}
restartPolicy: OnFailure
schedule: 30 3/8 * * *
secretFilesRefs: []
secretRefs: {}
secrets: {}
successfulJobsHistoryLimit: 1
suspend: false
tolerations: []
ttlSecondsAfterFinished: 100
version: 3.0.3
name: my-producer-app
namespace: example-namespace
Expand All @@ -71,12 +64,9 @@
type: my-producer-app
values:
affinity: {}
backoffLimit: 6
commandLine:
FAKE_ARG: fake-arg-value
deployment: false
env: {}
failedJobsHistoryLimit: 1
files:
log4j2.xml:
content: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Configuration>\n \
Expand All @@ -101,15 +91,11 @@
podLabels: {}
ports: []
readinessProbe: {}
restartPolicy: OnFailure
schedule: 30 3/8 * * *
secretFilesRefs: []
secretRefs: {}
secrets: {}
successfulJobsHistoryLimit: 1
suspend: false
tolerations: []
ttlSecondsAfterFinished: 100
version: 3.0.3
- _cleaner:
name: my-streams-app
Expand Down

0 comments on commit d10502a

Please sign in to comment.