@pagopa/dx-cli 0.16.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/azure/__tests__/cloud-account-service.test.js +35 -0
- package/dist/adapters/azure/cloud-account-service.d.ts +2 -1
- package/dist/adapters/azure/cloud-account-service.js +74 -14
- package/dist/adapters/commander/commands/add.d.ts +11 -0
- package/dist/adapters/commander/commands/add.js +27 -0
- package/dist/adapters/commander/commands/init.d.ts +2 -0
- package/dist/adapters/commander/commands/init.js +1 -1
- package/dist/adapters/commander/index.js +2 -0
- package/dist/adapters/octokit/__tests__/index.test.js +218 -1
- package/dist/adapters/octokit/index.d.ts +4 -1
- package/dist/adapters/octokit/index.js +65 -1
- package/dist/adapters/pagopa-technology/__tests__/authorization.test.d.ts +4 -0
- package/dist/adapters/pagopa-technology/__tests__/authorization.test.js +170 -0
- package/dist/adapters/pagopa-technology/authorization.d.ts +11 -0
- package/dist/adapters/pagopa-technology/authorization.js +104 -0
- package/dist/adapters/plop/actions/__tests__/init-cloud-accounts.test.js +35 -3
- package/dist/adapters/plop/actions/__tests__/provision-terraform-backend.test.js +15 -0
- package/dist/adapters/plop/actions/init-cloud-accounts.js +5 -2
- package/dist/adapters/plop/generators/environment/__tests__/actions.test.js +5 -0
- package/dist/adapters/plop/generators/environment/prompts.d.ts +14 -0
- package/dist/adapters/plop/generators/environment/prompts.js +67 -31
- package/dist/adapters/plop/index.d.ts +18 -2
- package/dist/adapters/plop/index.js +16 -0
- package/dist/domain/__tests__/data.d.ts +2 -0
- package/dist/domain/__tests__/data.js +1 -0
- package/dist/domain/authorization.d.ts +49 -0
- package/dist/domain/authorization.js +73 -0
- package/dist/domain/cloud-account.d.ts +2 -1
- package/dist/domain/dependencies.d.ts +2 -0
- package/dist/domain/github.d.ts +51 -0
- package/dist/domain/github.js +12 -0
- package/dist/index.js +5 -0
- package/dist/use-cases/__tests__/request-authorization.test.d.ts +4 -0
- package/dist/use-cases/__tests__/request-authorization.test.js +40 -0
- package/dist/use-cases/request-authorization.d.ts +15 -0
- package/dist/use-cases/request-authorization.js +13 -0
- package/package.json +3 -1
- package/templates/environment/bootstrapper/{{env.name}}/main.tf.hbs +2 -0
- package/templates/environment/bootstrapper/{{env.name}}/providers.tf.hbs +9 -0
- package/templates/environment/core/{{env.name}}/imports.tf.hbs +34 -0
- package/templates/environment/core/{{env.name}}/providers.tf.hbs +4 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Octokit } from "octokit";
|
|
2
2
|
import { DeepMockProxy, MockProxy } from "vitest-mock-extended";
|
|
3
3
|
import { Config } from "../../config.js";
|
|
4
|
+
import { AuthorizationService } from "../authorization.js";
|
|
4
5
|
import { GitHubService } from "../github.js";
|
|
5
6
|
import { PackageJson, PackageJsonReader } from "../package-json.js";
|
|
6
7
|
import { RepositoryReader } from "../repository.js";
|
|
7
8
|
import { ValidationReporter } from "../validation.js";
|
|
8
9
|
export declare const makeMockPackageJson: (overrides?: Partial<PackageJson>) => PackageJson;
|
|
9
10
|
export declare const makeMockDependencies: () => {
|
|
11
|
+
authorizationService: MockProxy<AuthorizationService>;
|
|
10
12
|
gitHubService: MockProxy<GitHubService>;
|
|
11
13
|
octokit: DeepMockProxy<Octokit>;
|
|
12
14
|
packageJsonReader: MockProxy<PackageJsonReader>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization Domain
|
|
3
|
+
*
|
|
4
|
+
* Provides types and interfaces for requesting cloud authorization.
|
|
5
|
+
* This module is technology-agnostic: it does not depend on any specific
|
|
6
|
+
* cloud provider or version-control platform.
|
|
7
|
+
*/
|
|
8
|
+
import { ResultAsync } from "neverthrow";
|
|
9
|
+
import { z } from "zod/v4";
|
|
10
|
+
/**
|
|
11
|
+
* Input validation schema for the request authorization use case.
|
|
12
|
+
*/
|
|
13
|
+
export declare const requestAuthorizationInputSchema: z.ZodObject<{
|
|
14
|
+
bootstrapIdentityId: z.core.$ZodBranded<z.ZodString, "BootstrapIdentityId">;
|
|
15
|
+
subscriptionName: z.core.$ZodBranded<z.ZodString, "SubscriptionName">;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
/**
|
|
18
|
+
* Service interface for requesting cloud authorization.
|
|
19
|
+
* Implementations handle the platform-specific details of granting access.
|
|
20
|
+
*/
|
|
21
|
+
export interface AuthorizationService {
|
|
22
|
+
requestAuthorization(input: RequestAuthorizationInput): ResultAsync<AuthorizationResult, AuthorizationError>;
|
|
23
|
+
}
|
|
24
|
+
export type RequestAuthorizationInput = z.infer<typeof requestAuthorizationInputSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Base error class for authorization-related errors.
|
|
27
|
+
*/
|
|
28
|
+
export declare class AuthorizationError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result returned by a successful authorization request.
|
|
33
|
+
*/
|
|
34
|
+
export declare class AuthorizationResult {
|
|
35
|
+
readonly url: string;
|
|
36
|
+
constructor(url: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when attempting to add an identity that already exists.
|
|
40
|
+
*/
|
|
41
|
+
export declare class IdentityAlreadyExistsError extends AuthorizationError {
|
|
42
|
+
constructor(identityId: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when the authorization configuration format is invalid or cannot be parsed.
|
|
46
|
+
*/
|
|
47
|
+
export declare class InvalidAuthorizationFileFormatError extends AuthorizationError {
|
|
48
|
+
constructor(details: string);
|
|
49
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization Domain
|
|
3
|
+
*
|
|
4
|
+
* Provides types and interfaces for requesting cloud authorization.
|
|
5
|
+
* This module is technology-agnostic: it does not depend on any specific
|
|
6
|
+
* cloud provider or version-control platform.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod/v4";
|
|
9
|
+
/**
|
|
10
|
+
* Branded type for subscription name.
|
|
11
|
+
* Validates that the name contains only letters, numbers, and hyphens to prevent path traversal attacks.
|
|
12
|
+
*/
|
|
13
|
+
const SubscriptionName = z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.regex(/^[A-Za-z0-9-]+$/, {
|
|
17
|
+
message: "Subscription name may contain only letters, numbers, and hyphens",
|
|
18
|
+
})
|
|
19
|
+
.brand();
|
|
20
|
+
/**
|
|
21
|
+
* Branded type for bootstrap identity ID.
|
|
22
|
+
* Validates that the ID contains only lowercase letters, numbers, and hyphens to prevent injection attacks.
|
|
23
|
+
*/
|
|
24
|
+
const BootstrapIdentityId = z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.regex(/^[a-z0-9-]+$/, {
|
|
28
|
+
message: "Bootstrap identity ID may contain only lowercase letters, numbers, and hyphens",
|
|
29
|
+
})
|
|
30
|
+
.brand();
|
|
31
|
+
/**
|
|
32
|
+
* Input validation schema for the request authorization use case.
|
|
33
|
+
*/
|
|
34
|
+
export const requestAuthorizationInputSchema = z.object({
|
|
35
|
+
bootstrapIdentityId: BootstrapIdentityId,
|
|
36
|
+
subscriptionName: SubscriptionName,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Base error class for authorization-related errors.
|
|
40
|
+
*/
|
|
41
|
+
export class AuthorizationError extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "AuthorizationError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Result returned by a successful authorization request.
|
|
49
|
+
*/
|
|
50
|
+
export class AuthorizationResult {
|
|
51
|
+
url;
|
|
52
|
+
constructor(url) {
|
|
53
|
+
this.url = url;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Error thrown when attempting to add an identity that already exists.
|
|
58
|
+
*/
|
|
59
|
+
export class IdentityAlreadyExistsError extends AuthorizationError {
|
|
60
|
+
constructor(identityId) {
|
|
61
|
+
super(`Identity "${identityId}" already exists`);
|
|
62
|
+
this.name = "IdentityAlreadyExistsError";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Error thrown when the authorization configuration format is invalid or cannot be parsed.
|
|
67
|
+
*/
|
|
68
|
+
export class InvalidAuthorizationFileFormatError extends AuthorizationError {
|
|
69
|
+
constructor(details) {
|
|
70
|
+
super(`Invalid authorization file format: ${details}`);
|
|
71
|
+
this.name = "InvalidAuthorizationFileFormatError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
2
|
import { type EnvironmentId } from "./environment.js";
|
|
3
|
+
import { type GitHubAppCredentials } from "./github.js";
|
|
3
4
|
import { TerraformBackend } from "./remote-backend.js";
|
|
4
5
|
export declare const cloudAccountSchema: z.ZodObject<{
|
|
5
6
|
csp: z.ZodDefault<z.ZodEnum<{
|
|
@@ -16,7 +17,7 @@ export type CloudAccountRepository = {
|
|
|
16
17
|
export type CloudAccountService = {
|
|
17
18
|
getTerraformBackend(cloudAccountId: CloudAccount["id"], environment: EnvironmentId): Promise<TerraformBackend | undefined>;
|
|
18
19
|
hasUserPermissionToInitialize(cloudAccountId: CloudAccount["id"]): Promise<boolean>;
|
|
19
|
-
initialize(cloudAccount: CloudAccount, environment: EnvironmentId, tags?: Record<string, string>): Promise<void>;
|
|
20
|
+
initialize(cloudAccount: CloudAccount, environment: EnvironmentId, runnerAppCredentials: GitHubAppCredentials, tags?: Record<string, string>): Promise<void>;
|
|
20
21
|
isInitialized(cloudAccountId: CloudAccount["id"], environment: EnvironmentId): Promise<boolean>;
|
|
21
22
|
provisionTerraformBackend(cloudAccount: CloudAccount, environment: EnvironmentId, tags?: Record<string, string>): Promise<TerraformBackend>;
|
|
22
23
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AuthorizationService } from "./authorization.js";
|
|
1
2
|
import { GitHubService } from "./github.js";
|
|
2
3
|
import { PackageJsonReader } from "./package-json.js";
|
|
3
4
|
import { RepositoryReader } from "./repository.js";
|
|
4
5
|
import { ValidationReporter } from "./validation.js";
|
|
5
6
|
export type Dependencies = {
|
|
7
|
+
authorizationService: AuthorizationService;
|
|
6
8
|
gitHubService: GitHubService;
|
|
7
9
|
packageJsonReader: PackageJsonReader;
|
|
8
10
|
repositoryReader: RepositoryReader;
|
package/dist/domain/github.d.ts
CHANGED
|
@@ -1,16 +1,58 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export type CreateBranchParams = {
|
|
3
|
+
branchName: string;
|
|
4
|
+
fromRef: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
};
|
|
8
|
+
export type FileContent = {
|
|
9
|
+
content: string;
|
|
10
|
+
sha: string;
|
|
11
|
+
};
|
|
12
|
+
export type GetFileContentParams = {
|
|
13
|
+
owner: string;
|
|
14
|
+
path: string;
|
|
15
|
+
ref?: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
};
|
|
1
18
|
export interface GitHubService {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new branch from an existing reference.
|
|
21
|
+
* @throws Error if branch creation fails
|
|
22
|
+
*/
|
|
23
|
+
createBranch(params: CreateBranchParams): Promise<void>;
|
|
2
24
|
/**
|
|
3
25
|
* Creates a pull request in a GitHub repository.
|
|
4
26
|
* @throws Error if pull request creation fails
|
|
5
27
|
*/
|
|
6
28
|
createPullRequest(params: PullRequestBody): Promise<PullRequest>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the content of a file from a GitHub repository.
|
|
31
|
+
* @throws FileNotFoundError if file doesn't exist (404)
|
|
32
|
+
* @throws Error for other failures
|
|
33
|
+
*/
|
|
34
|
+
getFileContent(params: GetFileContentParams): Promise<FileContent>;
|
|
7
35
|
/**
|
|
8
36
|
* Gets a GitHub repository by owner and name.
|
|
9
37
|
* @throws RepositoryNotFoundError if repository doesn't exist (404)
|
|
10
38
|
* @throws Error for other failures
|
|
11
39
|
*/
|
|
12
40
|
getRepository(owner: string, name: string): Promise<Repository>;
|
|
41
|
+
/**
|
|
42
|
+
* Updates a file in a GitHub repository.
|
|
43
|
+
* @throws Error if file update fails
|
|
44
|
+
*/
|
|
45
|
+
updateFile(params: UpdateFileParams): Promise<void>;
|
|
13
46
|
}
|
|
47
|
+
export type UpdateFileParams = {
|
|
48
|
+
branch: string;
|
|
49
|
+
content: string;
|
|
50
|
+
message: string;
|
|
51
|
+
owner: string;
|
|
52
|
+
path: string;
|
|
53
|
+
repo: string;
|
|
54
|
+
sha: string;
|
|
55
|
+
};
|
|
14
56
|
type PullRequestBody = {
|
|
15
57
|
base: string;
|
|
16
58
|
body: string;
|
|
@@ -19,6 +61,9 @@ type PullRequestBody = {
|
|
|
19
61
|
repo: string;
|
|
20
62
|
title: string;
|
|
21
63
|
};
|
|
64
|
+
export declare class FileNotFoundError extends Error {
|
|
65
|
+
constructor(path: string);
|
|
66
|
+
}
|
|
22
67
|
export declare class PullRequest {
|
|
23
68
|
readonly url: string;
|
|
24
69
|
constructor(url: string);
|
|
@@ -35,4 +80,10 @@ export declare class Repository {
|
|
|
35
80
|
export declare class RepositoryNotFoundError extends Error {
|
|
36
81
|
constructor(owner: string, name: string);
|
|
37
82
|
}
|
|
83
|
+
export declare const githubAppCredentialsSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
installationId: z.ZodString;
|
|
86
|
+
key: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type GitHubAppCredentials = z.infer<typeof githubAppCredentialsSchema>;
|
|
38
89
|
export {};
|
package/dist/domain/github.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export class FileNotFoundError extends Error {
|
|
3
|
+
constructor(path) {
|
|
4
|
+
super(`File not found: ${path}`);
|
|
5
|
+
this.name = "FileNotFoundError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
1
8
|
export class PullRequest {
|
|
2
9
|
url;
|
|
3
10
|
constructor(url) {
|
|
@@ -30,3 +37,8 @@ export class RepositoryNotFoundError extends Error {
|
|
|
30
37
|
this.name = "RepositoryNotFoundError";
|
|
31
38
|
}
|
|
32
39
|
}
|
|
40
|
+
export const githubAppCredentialsSchema = z.object({
|
|
41
|
+
id: z.string().nonempty(),
|
|
42
|
+
installationId: z.string().nonempty(),
|
|
43
|
+
key: z.string().nonempty(),
|
|
44
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,12 @@ import { makeValidationReporter } from "./adapters/logtape/validation-reporter.j
|
|
|
7
7
|
import { makePackageJsonReader } from "./adapters/node/package-json.js";
|
|
8
8
|
import { makeRepositoryReader } from "./adapters/node/repository.js";
|
|
9
9
|
import { getGitHubPAT, OctokitGitHubService, } from "./adapters/octokit/index.js";
|
|
10
|
+
import { makeAuthorizationService } from "./adapters/pagopa-technology/authorization.js";
|
|
10
11
|
import { getConfig } from "./config.js";
|
|
11
12
|
import { getInfo } from "./domain/info.js";
|
|
12
13
|
import { applyCodemodById } from "./use-cases/apply-codemod.js";
|
|
13
14
|
import { listCodemods } from "./use-cases/list-codemods.js";
|
|
15
|
+
import { requestAuthorization } from "./use-cases/request-authorization.js";
|
|
14
16
|
export const runCli = async (version) => {
|
|
15
17
|
// Creating the adapters
|
|
16
18
|
const repositoryReader = makeRepositoryReader();
|
|
@@ -22,7 +24,9 @@ export const runCli = async (version) => {
|
|
|
22
24
|
auth,
|
|
23
25
|
});
|
|
24
26
|
const gitHubService = new OctokitGitHubService(octokit);
|
|
27
|
+
const authorizationService = makeAuthorizationService(gitHubService);
|
|
25
28
|
const deps = {
|
|
29
|
+
authorizationService,
|
|
26
30
|
gitHubService,
|
|
27
31
|
packageJsonReader,
|
|
28
32
|
repositoryReader,
|
|
@@ -32,6 +36,7 @@ export const runCli = async (version) => {
|
|
|
32
36
|
const useCases = {
|
|
33
37
|
applyCodemodById: applyCodemodById(codemodRegistry, getInfo(deps)),
|
|
34
38
|
listCodemods: listCodemods(codemodRegistry),
|
|
39
|
+
requestAuthorization: requestAuthorization(authorizationService),
|
|
35
40
|
};
|
|
36
41
|
const program = makeCli(deps, config, useCases, version);
|
|
37
42
|
program.parse();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the requestAuthorization use case.
|
|
3
|
+
*/
|
|
4
|
+
import { errAsync, okAsync } from "neverthrow";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { mock } from "vitest-mock-extended";
|
|
7
|
+
import { AuthorizationError, AuthorizationResult, IdentityAlreadyExistsError, requestAuthorizationInputSchema, } from "../../domain/authorization.js";
|
|
8
|
+
import { requestAuthorization } from "../request-authorization.js";
|
|
9
|
+
const makeSampleInput = () => requestAuthorizationInputSchema.parse({
|
|
10
|
+
bootstrapIdentityId: "test-bootstrap-identity-id",
|
|
11
|
+
subscriptionName: "test-subscription",
|
|
12
|
+
});
|
|
13
|
+
describe("requestAuthorization", () => {
|
|
14
|
+
it("should return the authorization result on success", async () => {
|
|
15
|
+
const authorizationService = mock();
|
|
16
|
+
const input = makeSampleInput();
|
|
17
|
+
const expectedResult = new AuthorizationResult("https://github.com/pagopa/eng-azure-authorization/pull/42");
|
|
18
|
+
authorizationService.requestAuthorization.mockReturnValue(okAsync(expectedResult));
|
|
19
|
+
const result = await requestAuthorization(authorizationService)(input);
|
|
20
|
+
expect(result.isOk()).toBe(true);
|
|
21
|
+
expect(result._unsafeUnwrap().url).toBe("https://github.com/pagopa/eng-azure-authorization/pull/42");
|
|
22
|
+
expect(authorizationService.requestAuthorization).toHaveBeenCalledWith(input);
|
|
23
|
+
});
|
|
24
|
+
it("should propagate errors from the authorization service", async () => {
|
|
25
|
+
const authorizationService = mock();
|
|
26
|
+
const input = makeSampleInput();
|
|
27
|
+
authorizationService.requestAuthorization.mockReturnValue(errAsync(new IdentityAlreadyExistsError("test-bootstrap-identity-id")));
|
|
28
|
+
const result = await requestAuthorization(authorizationService)(input);
|
|
29
|
+
expect(result.isErr()).toBe(true);
|
|
30
|
+
expect(result._unsafeUnwrapErr()).toBeInstanceOf(IdentityAlreadyExistsError);
|
|
31
|
+
});
|
|
32
|
+
it("should propagate generic authorization errors", async () => {
|
|
33
|
+
const authorizationService = mock();
|
|
34
|
+
const input = makeSampleInput();
|
|
35
|
+
authorizationService.requestAuthorization.mockReturnValue(errAsync(new AuthorizationError("Something went wrong")));
|
|
36
|
+
const result = await requestAuthorization(authorizationService)(input);
|
|
37
|
+
expect(result.isErr()).toBe(true);
|
|
38
|
+
expect(result._unsafeUnwrapErr()).toBeInstanceOf(AuthorizationError);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Authorization Use Case
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates an authorization request by delegating to the
|
|
5
|
+
* technology-agnostic AuthorizationService.
|
|
6
|
+
*/
|
|
7
|
+
import { ResultAsync } from "neverthrow";
|
|
8
|
+
import { AuthorizationError, AuthorizationResult, AuthorizationService, RequestAuthorizationInput } from "../domain/authorization.js";
|
|
9
|
+
/**
|
|
10
|
+
* Creates a function that requests authorization for a bootstrap identity.
|
|
11
|
+
*
|
|
12
|
+
* @param authorizationService - The service handling platform-specific authorization logic
|
|
13
|
+
* @returns A function that takes input and returns a ResultAsync with the authorization result
|
|
14
|
+
*/
|
|
15
|
+
export declare const requestAuthorization: (authorizationService: AuthorizationService) => (input: RequestAuthorizationInput) => ResultAsync<AuthorizationResult, AuthorizationError>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Authorization Use Case
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates an authorization request by delegating to the
|
|
5
|
+
* technology-agnostic AuthorizationService.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a function that requests authorization for a bootstrap identity.
|
|
9
|
+
*
|
|
10
|
+
* @param authorizationService - The service handling platform-specific authorization logic
|
|
11
|
+
* @returns A function that takes input and returns a ResultAsync with the authorization result
|
|
12
|
+
*/
|
|
13
|
+
export const requestAuthorization = (authorizationService) => (input) => authorizationService.requestAuthorization(input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/dx-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI useful to manage DX tools.",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@azure/arm-authorization": "^9.0.0",
|
|
25
|
+
"@azure/arm-keyvault": "^4.0.0",
|
|
25
26
|
"@azure/arm-msi": "^2.2.0",
|
|
27
|
+
"@azure/keyvault-secrets": "^4.9.0",
|
|
26
28
|
"@azure/arm-resourcegraph": "^4.2.1",
|
|
27
29
|
"@azure/arm-resources": "^7.0.0",
|
|
28
30
|
"@azure/arm-resources-subscriptions": "^2.1.0",
|
|
@@ -36,6 +36,7 @@ module "azure-{{displayName}}_bootstrap" {
|
|
|
36
36
|
name = data.azurerm_key_vault.common.name
|
|
37
37
|
resource_group_name = data.azurerm_key_vault.common.resource_group_name
|
|
38
38
|
}
|
|
39
|
+
use_github_app = true
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
apim_id = data.azurerm_api_management.apim.id
|
|
@@ -103,6 +104,7 @@ module "azure-{{displayName}}_bootstrap" {
|
|
|
103
104
|
name = module.azure-{{displayName}}_core_values.common_key_vault.name
|
|
104
105
|
resource_group_name = module.azure-{{displayName}}_core_values.common_key_vault.resource_group_name
|
|
105
106
|
}
|
|
107
|
+
use_github_app = true
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
pep_vnet_id = module.azure-{{displayName}}_core_values.common_vnet.id
|
|
@@ -11,6 +11,11 @@ terraform {
|
|
|
11
11
|
version = "~> 2.0"
|
|
12
12
|
}
|
|
13
13
|
{{/with}}
|
|
14
|
+
|
|
15
|
+
github = {
|
|
16
|
+
source = "integrations/github"
|
|
17
|
+
version = "~> 6.0"
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
|
|
@@ -24,3 +29,7 @@ provider "azurerm" {
|
|
|
24
29
|
}
|
|
25
30
|
{{/each}}
|
|
26
31
|
{{/with}}
|
|
32
|
+
|
|
33
|
+
provider "github" {
|
|
34
|
+
owner = "{{github.owner}}"
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{{#with cloudAccountsByCsp.azure}}
|
|
2
|
+
|
|
3
|
+
{{#each this}}
|
|
4
|
+
data "azurerm_resource_group" "azure-{{displayName}}_common" {
|
|
5
|
+
provider = azurerm.{{displayName}}
|
|
6
|
+
name = provider::dx::resource_name(merge(local.environment, {
|
|
7
|
+
resource_type = "resource_group",
|
|
8
|
+
name = "common"
|
|
9
|
+
instance_number = 1
|
|
10
|
+
}, local.azure_accounts.{{displayName}}))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
to = module.azure-{{displayName}}_core.azurerm_resource_group.common
|
|
15
|
+
id = data.azurerm_resource_group.azure-{{displayName}}_common.id
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
data "azurerm_key_vault" "azure-{{displayName}}_common" {
|
|
19
|
+
provider = azurerm.{{displayName}}
|
|
20
|
+
name = provider::dx::resource_name(merge(local.environment, {
|
|
21
|
+
resource_type = "key_vault"
|
|
22
|
+
name = "common"
|
|
23
|
+
instance_number = 1
|
|
24
|
+
}, local.azure_accounts.{{displayName}}))
|
|
25
|
+
resource_group_name = data.azurerm_resource_group.azure-{{displayName}}_common.name
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
to = module.azure-{{displayName}}_core.module.key_vault.azurerm_key_vault.common
|
|
30
|
+
id = data.azurerm_key_vault.azure-{{displayName}}_common.id
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
{{/each}}
|
|
34
|
+
{{/with}}
|