chore: migrating azure actions to use new format

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-06-03 10:58:36 +02:00
parent 8cda60e6d4
commit e89d7b664c
6 changed files with 116 additions and 102 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-azure': patch
---
Migrating `azure` actions to using the new `zod` schema format
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-node': patch
---
Use `LoggerService` instead of `Logger`. This is a non-breaking change, as the `LoggerService` is a subset of the `Logger` interface.
@@ -5,7 +5,6 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { JsonObject } from '@backstage/types';
import { ScmIntegrationRegistry } from '@backstage/integration';
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
@@ -20,16 +19,21 @@ export function createPublishAzureAction(options: {
}): TemplateAction<
{
repoUrl: string;
description?: string;
defaultBranch?: string;
sourcePath?: string;
token?: string;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
signCommit?: boolean;
description?: string | undefined;
defaultBranch?: string | undefined;
sourcePath?: string | undefined;
token?: string | undefined;
gitCommitMessage?: string | undefined;
gitAuthorName?: string | undefined;
gitAuthorEmail?: string | undefined;
signCommit?: boolean | undefined;
},
JsonObject,
'v1'
{
remoteUrl?: string | undefined;
repoContentsUrl?: string | undefined;
repositoryId?: string | undefined;
commitHash?: string | undefined;
},
'v2'
>;
```
@@ -45,92 +45,92 @@ export function createPublishAzureAction(options: {
}) {
const { integrations, config } = options;
return createTemplateAction<{
repoUrl: string;
description?: string;
defaultBranch?: string;
sourcePath?: string;
token?: string;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
signCommit?: boolean;
}>({
return createTemplateAction({
id: 'publish:azure',
examples,
description:
'Initializes a git repository of the content in the workspace, and publishes it to Azure.',
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: {
title: 'Repository Location',
type: 'string',
},
description: {
title: 'Repository Description',
type: 'string',
},
defaultBranch: {
title: 'Default Branch',
type: 'string',
description: `Sets the default branch on the repository. The default value is 'master'`,
},
gitCommitMessage: {
title: 'Git Commit Message',
type: 'string',
description: `Sets the commit message on the repository. The default value is 'initial commit'`,
},
gitAuthorName: {
title: 'Default Author Name',
type: 'string',
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,
},
gitAuthorEmail: {
title: 'Default Author Email',
type: 'string',
description: `Sets the default author email for the commit.`,
},
sourcePath: {
title: 'Source Path',
description:
'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',
type: 'string',
},
token: {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to Azure',
},
signCommit: {
title: 'Sign commit',
type: 'boolean',
description: 'Sign commit with configured PGP private key',
},
},
repoUrl: z =>
z.string({
description: 'Repository Location',
}),
description: z =>
z
.string({
description: 'Repository Description',
})
.optional(),
defaultBranch: z =>
z
.string({
description: `Sets the default branch on the repository. The default value is 'master'`,
})
.optional(),
sourcePath: z =>
z
.string({
description:
'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',
})
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to Azure',
})
.optional(),
gitCommitMessage: z =>
z
.string({
description: `Sets the commit message on the repository. The default value is 'initial commit'`,
})
.optional(),
gitAuthorName: z =>
z
.string({
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,
})
.optional(),
gitAuthorEmail: z =>
z
.string({
description: `Sets the default author email for the commit.`,
})
.optional(),
signCommit: z =>
z
.boolean({
description: 'Sign commit with configured PGP private key',
})
.optional(),
},
output: {
type: 'object',
properties: {
remoteUrl: {
title: 'A URL to the repository with the provider',
type: 'string',
},
repoContentsUrl: {
title: 'A URL to the root of the repository',
type: 'string',
},
repositoryId: {
title: 'The Id of the created repository',
type: 'string',
},
commitHash: {
title: 'The git commit hash of the initial commit',
type: 'string',
},
},
remoteUrl: z =>
z
.string({
description: 'A URL to the repository with the provider',
})
.optional(),
repoContentsUrl: z =>
z
.string({
description: 'A URL to the root of the repository',
})
.optional(),
repositoryId: z =>
z
.string({
description: 'The Id of the created repository',
})
.optional(),
commitHash: z =>
z
.string({
description: 'The git commit hash of the initial commit',
})
.optional(),
},
},
async handler(ctx) {
+6 -6
View File
@@ -95,7 +95,7 @@ export function addFiles(options: {
| {
token: string;
};
logger?: Logger | undefined;
logger?: LoggerService | undefined;
}): Promise<void>;
// @public (undocumented)
@@ -110,7 +110,7 @@ export function cloneRepo(options: {
| {
token: string;
};
logger?: Logger | undefined;
logger?: LoggerService | undefined;
ref?: string | undefined;
depth?: number | undefined;
noCheckout?: boolean | undefined;
@@ -127,7 +127,7 @@ export function commitAndPushBranch(options: {
| {
token: string;
};
logger?: Logger | undefined;
logger?: LoggerService | undefined;
commitMessage: string;
gitAuthorInfo?: {
name?: string;
@@ -152,7 +152,7 @@ export function commitAndPushRepo(input: {
| {
token: string;
};
logger: Logger;
logger: LoggerService;
commitMessage: string;
gitAuthorInfo?: {
name?: string;
@@ -177,7 +177,7 @@ export function createBranch(options: {
| {
token: string;
};
logger?: Logger | undefined;
logger?: LoggerService | undefined;
}): Promise<void>;
// @public @deprecated (undocumented)
@@ -304,7 +304,7 @@ export function initRepoAndPush(input: {
| {
token: string;
};
logger: Logger;
logger: LoggerService;
defaultBranch?: string;
commitMessage?: string;
gitAuthorInfo?: {
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { Logger } from 'winston';
import { Git } from '../scm';
import { LoggerService } from '@backstage/backend-plugin-api';
/**
* @public
@@ -27,7 +27,7 @@ export async function initRepoAndPush(input: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger: Logger;
logger: LoggerService;
defaultBranch?: string;
commitMessage?: string;
gitAuthorInfo?: { name?: string; email?: string };
@@ -87,7 +87,7 @@ export async function commitAndPushRepo(input: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger: Logger;
logger: LoggerService;
commitMessage: string;
gitAuthorInfo?: { name?: string; email?: string };
branch?: string;
@@ -147,7 +147,7 @@ export async function cloneRepo(options: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger?: Logger | undefined;
logger?: LoggerService | undefined;
ref?: string | undefined;
depth?: number | undefined;
noCheckout?: boolean | undefined;
@@ -172,7 +172,7 @@ export async function createBranch(options: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger?: Logger | undefined;
logger?: LoggerService | undefined;
}): Promise<void> {
const { dir, ref, auth, logger } = options;
const git = Git.fromAuth({
@@ -193,7 +193,7 @@ export async function addFiles(options: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger?: Logger | undefined;
logger?: LoggerService | undefined;
}): Promise<void> {
const { dir, filepath, auth, logger } = options;
const git = Git.fromAuth({
@@ -213,7 +213,7 @@ export async function commitAndPushBranch(options: {
// it has to be provided as password together with a username
// which may be a fixed value defined by the provider.
auth: { username: string; password: string } | { token: string };
logger?: Logger | undefined;
logger?: LoggerService | undefined;
commitMessage: string;
gitAuthorInfo?: { name?: string; email?: string };
branch?: string;