Skip to content

Commit

Permalink
feat(sdl): implement service image credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed May 10, 2024
1 parent a7eb767 commit 06a73e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/sdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
v2ServiceParams,
v3DeploymentGroup,
v3ManifestServiceParams,
v2StorageAttributes
v2StorageAttributes,
v2ServiceImageCredentials
} from "./types";
import { convertCpuResourceString, convertResourceString } from "./sizes";
import { default as stableStringify } from "json-stable-stringify";
Expand Down Expand Up @@ -168,6 +169,7 @@ export class SDL {
Object.keys(this.data.services).forEach(serviceName => {
this.validateDeploymentWithRelations(serviceName);
this.validateLeaseIP(serviceName);
this.validateCredentials(serviceName);
});

this.validateDenom();
Expand Down Expand Up @@ -196,6 +198,17 @@ export class SDL {
});
}

private validateCredentials(serviceName: string) {
const { credentials } = this.data.services[serviceName];

if (credentials) {
const credentialsKeys: (keyof v2ServiceImageCredentials)[] = ["host", "username", "password"];
credentialsKeys.forEach(key => {
CustomValidationError.assert(credentials[key]?.trim().length, `service "${serviceName}" credentials missing "${key}"`);
});
}
}

private validateDeploymentWithRelations(serviceName: string) {
const deployment = this.data.deployment[serviceName];
CustomValidationError.assert(deployment, `Service "${serviceName}" is not defined in the "deployment" section.`);
Expand Down Expand Up @@ -658,7 +671,7 @@ export class SDL {
count: deployment[placement].count,
expose: this.v3ManifestExpose(service),
params: this.v3ManifestServiceParams(service.params),
credentials: null
credentials: service.credentials || null
};
}

Expand Down

0 comments on commit 06a73e8

Please sign in to comment.