fix(mosaic): preserve v1 agent name semantics
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
This commit is contained in:
@@ -386,7 +386,7 @@ export async function previewV1ToV2Migration(
|
||||
|
||||
for (let index = 0; index < rawAgents.length; index += 1) {
|
||||
const rawAgent = record(rawAgents[index]);
|
||||
const name = stringValue(rawAgent.name);
|
||||
const name = exactStringValue(rawAgent.name);
|
||||
const path = `agents[${index}]`;
|
||||
if (!name) {
|
||||
blockers.push(blocker('invalid-agent-name', `${path}.name`, 'Agent name is required.'));
|
||||
@@ -538,7 +538,7 @@ export async function previewV1ToV2Migration(
|
||||
rawAgents
|
||||
.map((candidate) => record(candidate))
|
||||
.filter((candidate) => classifyAgentLocality(candidate, decisions.fleetHost) !== 'remote')
|
||||
.map((candidate) => stringValue(candidate.name))
|
||||
.map((candidate) => exactStringValue(candidate.name))
|
||||
.filter((name): name is string => name !== undefined),
|
||||
);
|
||||
for (const decisionName of Object.keys(decisions.agents)) {
|
||||
@@ -936,7 +936,7 @@ function validateV1FieldCatalog(raw: Record<string, unknown>, blockers: Migratio
|
||||
path,
|
||||
blockers,
|
||||
);
|
||||
const name = stringValue(agent.name);
|
||||
const name = exactStringValue(agent.name);
|
||||
if (!name || !AGENT_NAME_PATTERN.test(name)) {
|
||||
blockers.push(
|
||||
blocker('invalid-v1-field-type', `${path}.name`, 'A valid agent name is required.'),
|
||||
@@ -1420,6 +1420,10 @@ function record(value: unknown): Record<string, unknown> {
|
||||
: {};
|
||||
}
|
||||
|
||||
function exactStringValue(value: unknown): string | undefined {
|
||||
return typeof value === 'string' ? value : undefined;
|
||||
}
|
||||
|
||||
function trimmedString(value: unknown): string | undefined {
|
||||
return typeof value === 'string' ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user