Skip to content

Commit

Permalink
address comments (#4340)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-g-town authored Feb 28, 2024
1 parent e99eb1a commit 452783d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
11 changes: 8 additions & 3 deletions dashboard/src/lib/porter-apps/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,23 @@ export function defaultSerialized({
memoryThresholdPercent: 50,
};

const defaultHealthCheck: SerializedHealthcheck = {
const defaultWebHealthCheck: SerializedHealthcheck = {
enabled: false,
httpPath: "/healthz",
};

const defaultWorkerHealthCheck: SerializedHealthcheck = {
enabled: false,
command: "./healthz.sh",
};

return match(type)
.with("web", () => ({
...baseService,
config: {
type: "web" as const,
autoscaling: defaultAutoscaling,
healthCheck: defaultHealthCheck,
healthCheck: defaultWebHealthCheck,
domains: [],
private: false,
ingressAnnotations: {},
Expand All @@ -263,7 +268,7 @@ export function defaultSerialized({
config: {
type: "worker" as const,
autoscaling: defaultAutoscaling,
healthCheck: defaultHealthCheck,
healthCheck: defaultWorkerHealthCheck,
},
}))
.with("job", () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import { type PorterAppFormData } from "lib/porter-apps";

type HealthProps = {
index: number;
command?: boolean;
};

const Health: React.FC<HealthProps> = ({ index, command = false }) => {
const Health: React.FC<HealthProps> = ({ index }) => {
const { register, control, watch } = useFormContext<PorterAppFormData>();

const healthCheckEnabled = watch(
`app.services.${index}.config.healthCheck.enabled`
);

const serviceType = watch(`app.services.${index}.config.type`);

return (
<>
<Spacer y={1} />
Expand Down Expand Up @@ -60,29 +61,29 @@ const Health: React.FC<HealthProps> = ({ index, command = false }) => {
)}
/>
{healthCheckEnabled.value &&
(command ? (
(serviceType === "web" ? (
<>
<Spacer y={0.5} />
<Text>Health check command</Text>
<Text>Health check endpoint</Text>
<Spacer y={0.5} />
<ControlledInput
type="text"
placeholder="ex: ./healthz.sh"
placeholder="ex: /healthz"
{...register(
`app.services.${index}.config.healthCheck.command.value`
`app.services.${index}.config.healthCheck.httpPath.value`
)}
/>
</>
) : (
<>
<Spacer y={0.5} />
<Text>Health check endpoint</Text>
<Text>Health check command</Text>
<Spacer y={0.5} />
<ControlledInput
type="text"
placeholder="ex: /healthz"
placeholder="ex: ./healthz.sh"
{...register(
`app.services.${index}.config.healthCheck.httpPath.value`
`app.services.${index}.config.healthCheck.command.value`
)}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const WorkerTabs: React.FC<Props> = ({
))
.with("advanced", () => (
<>
<Health index={index} command={true} />
<Health index={index} />
<Spacer y={1} />
<Advanced index={index} />
</>
Expand Down
2 changes: 1 addition & 1 deletion internal/porter_app/v2/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ type Domains struct {
Name string `yaml:"name"`
}

// HealthCheck is the health check settings for a web service
// HealthCheck contains the health check settings
type HealthCheck struct {
Enabled bool `yaml:"enabled"`
HttpPath string `yaml:"httpPath"`
Expand Down

0 comments on commit 452783d

Please sign in to comment.