Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
fix: Fix appServicePlan name and functionApp name (#293)
Browse files Browse the repository at this point in the history
Resolves #292
  • Loading branch information
stelone authored and tbarlow12 committed Sep 13, 2019
1 parent c7995a4 commit f7684f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/armTemplates/resources/appServicePlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AzureNamingService } from "../../services/namingService";

export class AppServicePlanResource implements ArmResourceTemplateGenerator {
public static getResourceName(config: ServerlessAzureConfig) {
return AzureNamingService.getResourceName(config, config.provider.appInsights, "asp");
return AzureNamingService.getResourceName(config, config.provider.appServicePlan, "asp");
}

public getTemplate(): ArmResourceTemplate {
Expand Down
20 changes: 10 additions & 10 deletions src/armTemplates/resources/functionApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class FunctionAppResource implements ArmResourceTemplateGenerator {
public static getResourceName(config: ServerlessAzureConfig) {
const safeServiceName = config.service.replace(/\s/g, "-");

return AzureNamingService.getResourceName(config, config.provider.appInsights, safeServiceName);
return AzureNamingService.getResourceName(config, config.provider.functionApp, safeServiceName);
}

public getTemplate(): ArmResourceTemplate {
Expand Down Expand Up @@ -123,26 +123,26 @@ export class FunctionAppResource implements ArmResourceTemplateGenerator {
};
}

private getRuntimeVersion(runtime: string): string{
if(!runtime) {
private getRuntimeVersion(runtime: string): string {
if (!runtime) {
throw new Error("Runtime version not specified in serverless.yml");
}
const extractedVersion = runtime.split("nodejs")[1];
const runtimeVersionsList = runtimeVersionsJson["nodejs"];

//Searches for a specific version. For example nodejs10.6.0.
if(!extractedVersion.endsWith(".x")) {
if (!extractedVersion.endsWith(".x")) {
let retrivedVersion: string;
for(const version of runtimeVersionsList){
retrivedVersion = version["version"];
if(extractedVersion === retrivedVersion && semver.valid(retrivedVersion)){
return retrivedVersion;
for (const version of runtimeVersionsList) {
retrivedVersion = version["version"];
if (extractedVersion === retrivedVersion && semver.valid(retrivedVersion)) {
return retrivedVersion;
}
}
}
else {
// User specified something like nodejs10.14.x
const extractedVersionNumber = extractedVersion.replace(/[^0-9\.]/g,"");
const extractedVersionNumber = extractedVersion.replace(/[^0-9\.]/g, "");

const selectedVersions = runtimeVersionsList.filter(({ version }) => {
return version.startsWith(extractedVersionNumber) && semver.valid(version)
Expand All @@ -154,5 +154,5 @@ export class FunctionAppResource implements ArmResourceTemplateGenerator {
return selectedVersions.sort(semver.rcompare)[0]
}
throw new Error(`Could not find runtime version matching ${runtime}`)
}
}
}

0 comments on commit f7684f4

Please sign in to comment.