Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions eng/tools/spec-gen-sdk-runner/src/command-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,16 @@ export function generateArtifact(
if (!fs.existsSync(specGenSdkArtifactAbsoluteFolder)) {
fs.mkdirSync(specGenSdkArtifactAbsoluteFolder, { recursive: true });
}
const isSpecGenSdkCheckRequired = getRequiredSettingValue(
hasManagementPlaneSpecs,
commandInput.sdkLanguage as SdkName,
);
// Write artifact
const artifactInfo: SpecGenSdkArtifactInfo = {
language: commandInput.sdkLanguage,
result,
labelAction: hasBreakingChange,
isSpecGenSdkCheckRequired:
hasManagementPlaneSpecs && SpecGenSdkRequiredSettings[commandInput.sdkLanguage as SdkName],
isSpecGenSdkCheckRequired,
apiViewRequestData: apiViewRequestData,
};
fs.writeFileSync(
Expand Down Expand Up @@ -348,3 +351,20 @@ export function getServiceFolderPath(specConfigPath: string): string {
}
return specConfigPath;
}

/**
* Get the required setting value for the SDK check based on the spec PR types.
* @param hasManagementPlaneSpecs - A flag indicating whether there are management plane specs.
* @param sdkName - The SDK name.
* @returns boolean indicating whether the SDK check is required.
*/
export function getRequiredSettingValue(
hasManagementPlaneSpecs: boolean,
sdkName: SdkName,
): boolean {
if (hasManagementPlaneSpecs) {
return SpecGenSdkRequiredSettings[sdkName].managementPlane;
} else {
return SpecGenSdkRequiredSettings[sdkName].dataPlane;
}
}
44 changes: 37 additions & 7 deletions eng/tools/spec-gen-sdk-runner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface SpecGenSdkArtifactInfo {
result: string;
labelAction?: boolean;
isSpecGenSdkCheckRequired: boolean;
apiViewRequestData: APIViewRequestData [];
apiViewRequestData: APIViewRequestData[];
}

/**
Expand All @@ -59,13 +59,43 @@ export type SdkName =
| "azure-sdk-for-net"
| "azure-sdk-for-python";

/**
* Represents the plane types for SDK generation settings
*/
export interface PlaneTypeSettings {
/**
* Whether spec-gen-sdk check is required for data plane
*/
dataPlane: boolean;

/**
* Whether spec-gen-sdk check is required for management plane
*/
managementPlane: boolean;
}

/**
* Required check settings for all languages.
*/
export const SpecGenSdkRequiredSettings: Record<SdkName, boolean> = {
"azure-sdk-for-go": true,
"azure-sdk-for-java": true,
"azure-sdk-for-js": false,
"azure-sdk-for-net": false,
"azure-sdk-for-python": true,
export const SpecGenSdkRequiredSettings: Record<SdkName, PlaneTypeSettings> = {
"azure-sdk-for-go": {
dataPlane: true,
managementPlane: true,
},
"azure-sdk-for-java": {
dataPlane: false,
managementPlane: true,
},
"azure-sdk-for-js": {
dataPlane: false,
managementPlane: false,
},
"azure-sdk-for-net": {
dataPlane: false,
managementPlane: false,
},
"azure-sdk-for-python": {
dataPlane: true,
managementPlane: true,
},
};
Loading
Loading