Skip to content

Add Typed Deploy section #201

@aus-design-web-mobile

Description

@aus-design-web-mobile

As with the others, focused on both Typing and backwards compat:
#199

Before (MapBuilder API)

.WithDeploy(deploy => deploy
.WithReplicas(2)
.WithUpdateConfig(c => c.WithProperty("delay", "30s"))
.WithRestartPolicy(c => c
.WithProperty("delay", "30s")
.WithProperty("max_attempts", 10)
.WithProperty("window", "120s")
)
.WithPlacement(c => c
.WithProperty("constraints", new[] { "node.role == worker" })
.WithProperty("preferences", new[] { new PlacementPreferences { Spread = "node.labels.zone" } })
)
.WithResources(c => c.WithProperty("limits", new Dictionary<string, string>
{
["memory"] = "1600m",
}))
)

After (Typed API)

.WithDeploy(deploy => deploy
.WithReplicas(2)
.WithUpdateConfig(c => c.WithDelay("30s"))
.WithRestartPolicy(c => c
.WithDelay("30s")
.WithMaxAttempts(10)
.WithWindow("120s")
)
.WithPlacement(c => c
.WithConstraints("node.role == worker")
.WithPreference("node.labels.zone")
)
.WithResources(c => c.WithLimits(l => l.WithMemory("1600m")))
)

Benefits

  • IntelliSense/autocomplete - Discover available options without docs
  • Compile-time safety - Typos like "max_attempt" caught at build time
  • Enum support - WithCondition(ERestartCondition.OnFailure) instead of magic strings
  • Cleaner syntax - No WithProperty() or new Dictionary<> boilerplate

Both produce identical YAML output, and the old API still works for backwards compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions