Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
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
4 changes: 4 additions & 0 deletions src/models/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export interface ServerlessCommand {
commands?: ServerlessCommandMap;
}

export interface ServerlessHookMap {
[eventName: string]: Promise<any>;
}

export interface ServerlessCommandMap {
[command: string]: ServerlessCommand;
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/apim/azureApimFunctionPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ApimService } from "../../services/apimService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureApimFunctionPlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/apim/azureApimServicePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ApimService } from "../../services/apimService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureApimServicePlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/azureBasePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Guard } from "../shared/guard";
import Serverless from "serverless";
import { Utils } from "../shared/utils";
import { ServerlessCommandMap, ServerlessHookMap } from "../models/serverless";

export abstract class AzureBasePlugin<TOptions=Serverless.Options> {

public hooks: ServerlessHookMap
protected commands: ServerlessCommandMap;

public constructor(
protected serverless: Serverless,
protected options: TOptions,
Expand Down
27 changes: 26 additions & 1 deletion src/plugins/deploy/azureDeployPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ResourceService } from "../../services/resourceService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureDeployPlugin extends AzureBasePlugin<AzureLoginOptions> {
public hooks: { [eventName: string]: Promise<any> };
public commands: any;

public constructor(serverless: Serverless, options: AzureLoginOptions) {
Expand All @@ -25,13 +24,39 @@ export class AzureDeployPlugin extends AzureBasePlugin<AzureLoginOptions> {
lifecycleEvents: [
"list"
]
},
options: {
resourceGroup: {
usage: "Resource group for the service",
shortcut: "g",
},
stage: {
usage: "Stage of service",
shortcut: "s"
},
region: {
usage: "Region of service",
shortcut: "r"
},
subscriptionId: {
usage: "Sets the Azure subscription ID",
shortcut: "i",
},
}
},
options: {
resourceGroup: {
usage: "Resource group for the service",
shortcut: "g",
},
stage: {
usage: "Stage of service",
shortcut: "s"
},
region: {
usage: "Region of service",
shortcut: "r"
},
subscriptionId: {
usage: "Sets the Azure subscription ID",
shortcut: "i",
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/func/azureFuncPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { FuncService } from "../../services/funcService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureFuncPlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };
public commands: any;
private service: FuncService;

public constructor(serverless: Serverless, options: Serverless.Options) {
Expand Down
23 changes: 19 additions & 4 deletions src/plugins/invoke/azureInvokePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import fs from "fs";
import { isAbsolute, join } from "path";
import Serverless from "serverless";
import { InvokeService } from "../../services/invokeService";
import fs from "fs";
import { ServerlessCommandMap } from "../../models/serverless";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureInvokePlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };
private commands: ServerlessCommandMap;

private invokeService: InvokeService;

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);
const path = this.options["path"];
Expand All @@ -31,6 +30,22 @@ export class AzureInvokePlugin extends AzureBasePlugin {
usage: "Invoke command",
lifecycleEvents: ["invoke"],
options: {
resourceGroup: {
usage: "Resource group for the service",
shortcut: "g",
},
stage: {
usage: "Stage of service",
shortcut: "s"
},
region: {
usage: "Region of service",
shortcut: "r"
},
subscriptionId: {
usage: "Sets the Azure subscription ID",
shortcut: "i",
},
function: {
usage: "Function to call",
shortcut: "f",
Expand Down
1 change: 0 additions & 1 deletion src/plugins/login/azureLoginPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { AzureBasePlugin } from "../azureBasePlugin";
import { loginHooks } from "./loginHooks";

export class AzureLoginPlugin extends AzureBasePlugin<AzureLoginOptions> {
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: AzureLoginOptions) {
super(serverless, options);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/logs/azureLogsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import AzureProvider from "../../provider/azureProvider";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureLogsPlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };

private provider: AzureProvider;

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/offline/azureOfflinePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { OfflineService } from "../../services/offlineService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureOfflinePlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };
public commands: any;
private offlineService: OfflineService;

public constructor(serverless: Serverless, options: Serverless.Options) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/package/azurePackagePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class AzurePackagePlugin extends AzureBasePlugin {
private bindingsCreated: boolean = false;
private packageService: PackageService;
public provider: AzureProvider;
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);
Expand Down
29 changes: 28 additions & 1 deletion src/plugins/remove/azureRemovePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,37 @@ import { ResourceService } from "../../services/resourceService";
import { AzureBasePlugin } from "../azureBasePlugin";

export class AzureRemovePlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);

this.commands = {
remove: {
usage: "Remove service resource group (USE WITH CAUTION)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eeep, is there a way to enforce confirmation with this command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently, no

lifecycleEvents: [
"remove"
],
options: {
resourceGroup: {
usage: "Resource group for the service",
shortcut: "g",
},
stage: {
usage: "Stage of service",
shortcut: "s"
},
region: {
usage: "Region of service",
shortcut: "r"
},
subscriptionId: {
usage: "Sets the Azure subscription ID",
shortcut: "i",
},
}
}
}

this.hooks = {
"remove:remove": this.remove.bind(this)
};
Expand Down
33 changes: 32 additions & 1 deletion src/plugins/rollback/azureRollbackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,41 @@ import { AzureBasePlugin } from "../azureBasePlugin";
* Plugin for rolling back Function App Service to previous deployment
*/
export class AzureRollbackPlugin extends AzureBasePlugin {
public hooks: { [eventName: string]: Promise<any> };

public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);

this.commands = {
rollback: {
usage: "Rollback command",
lifecycleEvents: [
"rollback"
],
options: {
timestamp: {
usage: "Timestamp of previous deployment",
shortcut: "t",
},
resourceGroup: {
usage: "Resource group for the service",
shortcut: "g",
},
stage: {
usage: "Stage of service",
shortcut: "s"
},
region: {
usage: "Region of service",
shortcut: "r"
},
subscriptionId: {
usage: "Sets the Azure subscription ID",
shortcut: "i",
},
}
}
}

this.hooks = {
"rollback:rollback": this.rollback.bind(this)
};
Expand Down