Skip to content

Commit 19b4da9

Browse files
committed
Re-named aws-configure to aws-profile
1 parent beacfa2 commit 19b4da9

9 files changed

Lines changed: 33 additions & 39 deletions

File tree

package-lock.json

Lines changed: 5 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ajv": "^8.12.0",
2323
"ajv-formats": "^2.1.1",
2424
"semver": "^7.6.0",
25-
"codify-plugin-test": "0.0.4",
25+
"codify-plugin-test": "0.0.5",
2626
"codify-plugin-lib": "1.0.73",
2727
"codify-schemas": "1.0.42",
2828
"chalk": "^5.3.0",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Plugin, runPlugin } from 'codify-plugin-lib';
22

33
import { AwsCliResource } from './resources/aws-cli/cli/aws-cli.js';
4-
import { AwsConfigureResource } from './resources/aws-cli/configure/aws-configure.js';
4+
import { AwsProfileResource } from './resources/aws-cli/profile/aws-profile.js';
55
import { GitCloneResource } from './resources/git/clone/git-clone.js';
66
import { GitLfsResource } from './resources/git/lfs/git-lfs.js';
77
import { HomebrewResource } from './resources/homebrew/homebrew.js';
@@ -24,7 +24,7 @@ runPlugin(Plugin.create(
2424
new PyenvResource(),
2525
new GitLfsResource(),
2626
new AwsCliResource(),
27-
new AwsConfigureResource(),
27+
new AwsProfileResource(),
2828
new TerraformResource(),
2929
new NvmResource(),
3030
new PgcliResource(),

src/resources/aws-cli/configure/aws-configure.test.ts renamed to src/resources/aws-cli/profile/aws-configure.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { describe, expect, it } from 'vitest';
2-
import { AwsConfigureResource } from './aws-configure.js';
2+
import { AwsProfileResource } from './aws-profile.js';
33

4-
describe('AWS configure validation tests', () => {
4+
describe('AWS profile validation tests', () => {
55
it('Validates secret key id and secret key', async () => {
6-
const resource = new AwsConfigureResource()
6+
const resource = new AwsProfileResource()
77

88
const result = await resource.validate({
99
awsAccessKeyId: 'abc',
@@ -22,7 +22,7 @@ describe('AWS configure validation tests', () => {
2222
});
2323

2424
it('Validates csv credentials', async () => {
25-
const resource = new AwsConfigureResource()
25+
const resource = new AwsProfileResource()
2626

2727
const result = await resource.validate({
2828
csvCredentials: '../../path/to/csv'
@@ -40,7 +40,7 @@ describe('AWS configure validation tests', () => {
4040
});
4141

4242
it('Rejects both csv credentials and secrets', async () => {
43-
const resource = new AwsConfigureResource()
43+
const resource = new AwsProfileResource()
4444

4545
const result = await resource.validate({
4646
csvCredentials: '../../path/to/csv',

src/resources/aws-cli/configure/aws-configure-schema.json renamed to src/resources/aws-cli/profile/aws-profile-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://www.codifycli.com/aws-cli.json",
3+
"$id": "https://www.codifycli.com/aws-profile.json",
44
"title": "Aws-CLI configure resource",
55
"type": "object",
66
"properties": {

src/resources/aws-cli/configure/aws-configure.ts renamed to src/resources/aws-cli/profile/aws-profile.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import os from 'node:os';
55
import path from 'node:path';
66

77
import { SpawnStatus, codifySpawn } from '../../../utils/codify-spawn.js';
8+
import Schema from './aws-profile-schema.json'
89
import { CSVCredentialsParameter } from './csv-credentials-parameter.js';
910

10-
export interface AwsConfigureConfig extends StringIndexedObject {
11+
export interface AwsProfileConfig extends StringIndexedObject {
1112
awsAccessKeyId: string;
1213
awsSecretAccessKey: string;
1314
csvCredentials: string,
@@ -18,7 +19,7 @@ export interface AwsConfigureConfig extends StringIndexedObject {
1819
region?: string;
1920
}
2021

21-
export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
22+
export class AwsProfileResource extends Resource<AwsProfileConfig> {
2223

2324
constructor() {
2425
super({
@@ -29,18 +30,19 @@ export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
2930
csvCredentials: { transformParameter: new CSVCredentialsParameter() },
3031
profile: { default: 'default' },
3132
},
32-
type: 'aws-configure',
33+
schema: Schema,
34+
type: 'aws-profile',
3335
});
3436
}
3537

36-
override async customValidation(parameters: Partial<AwsConfigureConfig>): Promise<void> {
38+
override async customValidation(parameters: Partial<AwsProfileConfig>): Promise<void> {
3739
if (parameters.csvCredentials
3840
&& (parameters.awsAccessKeyId || parameters.awsSecretAccessKey)) {
3941
throw new Error('Csv credentials cannot be added together with awsAccessKeyId or awsSecretAccessKey')
4042
}
4143
}
4244

43-
async refresh(parameters: Partial<AwsConfigureConfig>): Promise<Partial<AwsConfigureConfig> | null> {
45+
async refresh(parameters: Partial<AwsProfileConfig>): Promise<Partial<AwsProfileConfig> | null> {
4446
const profile = parameters.profile!;
4547

4648
// Make sure aws-cli is installed
@@ -58,7 +60,7 @@ export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
5860
const awsAccessKeyId = await this.getAwsConfigureValueOrNull('aws_access_key_id', profile);
5961
const awsSecretAccessKey = await this.getAwsConfigureValueOrNull('aws_secret_access_key', profile);
6062

61-
const result: Partial<AwsConfigureConfig> = {
63+
const result: Partial<AwsProfileConfig> = {
6264
awsAccessKeyId: awsAccessKeyId ?? undefined,
6365
awsSecretAccessKey: awsSecretAccessKey ?? undefined,
6466
profile,
@@ -83,7 +85,7 @@ export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
8385
return result;
8486
}
8587

86-
async applyCreate(plan: CreatePlan<AwsConfigureConfig>): Promise<void> {
88+
async applyCreate(plan: CreatePlan<AwsProfileConfig>): Promise<void> {
8789
// Assert that aws-cli is installed
8890
await codifySpawn('which aws')
8991

@@ -118,8 +120,8 @@ export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
118120
}
119121

120122
async applyModify(
121-
pc: ParameterChange<AwsConfigureConfig>,
122-
plan: ModifyPlan<AwsConfigureConfig>
123+
pc: ParameterChange<AwsProfileConfig>,
124+
plan: ModifyPlan<AwsProfileConfig>
123125
): Promise<void> {
124126
if (pc.name === 'awsAccessKeyId') {
125127
await this.setAwsConfigureValue('aws_access_key_id', pc.newValue, plan.desiredConfig.profile);
@@ -130,7 +132,7 @@ export class AwsConfigureResource extends Resource<AwsConfigureConfig> {
130132
}
131133
}
132134

133-
async applyDestroy(plan: DestroyPlan<AwsConfigureConfig>): Promise<void> {
135+
async applyDestroy(plan: DestroyPlan<AwsProfileConfig>): Promise<void> {
134136
const regex = /^\[.*]$/g;
135137
const { profile } = plan.currentConfig;
136138

src/resources/aws-cli/configure/csv-credentials-parameter.ts renamed to src/resources/aws-cli/profile/csv-credentials-parameter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import * as fs from 'node:fs/promises';
44
import path from 'node:path';
55

66
import { untildify } from '../../../utils/untildify.js';
7-
import { AwsConfigureConfig } from './aws-configure.js';
7+
import { AwsProfileConfig } from './aws-profile.js';
88

9-
export class CSVCredentialsParameter extends TransformParameter<AwsConfigureConfig>{
9+
export class CSVCredentialsParameter extends TransformParameter<AwsProfileConfig>{
1010

11-
async transform(value: any): Promise<Partial<AwsConfigureConfig>> {
11+
async transform(value: any): Promise<Partial<AwsProfileConfig>> {
1212
const csvPath = path.resolve(untildify(value));
1313

1414
if (!fsSync.existsSync(csvPath)) {

src/utils/file-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2-
import mock from 'mock-fs'
2+
import * as mock from 'mock-fs'
33
import { FileUtils } from './file-utils';
44
import * as fs from 'node:fs/promises';
55

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, it } from 'vitest';
22
import { PluginTester } from 'codify-plugin-test';
33
import * as path from 'node:path';
44

5-
describe('Aws configure tests', async () => {
5+
describe('Aws profile tests', async () => {
66
let plugin: PluginTester;
77

88
beforeEach(() => {
@@ -14,7 +14,7 @@ describe('Aws configure tests', async () => {
1414
{ type: 'homebrew' },
1515
{ type: 'aws-cli' },
1616
{
17-
type: 'aws-configure',
17+
type: 'aws-profile',
1818
awsAccessKeyId: 'keyId',
1919
awsSecretAccessKey: 'secretAccessKey',
2020
region: 'us-west-2',
@@ -25,7 +25,7 @@ describe('Aws configure tests', async () => {
2525

2626
it('Can add custom profiles', { timeout: 300000 }, async () => {
2727
await plugin.fullTest([{
28-
type: 'aws-configure',
28+
type: 'aws-profile',
2929
profile: 'codify',
3030
awsAccessKeyId: 'keyId',
3131
awsSecretAccessKey: 'secretAccessKey',

0 commit comments

Comments
 (0)