Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ext overrides3 storage headless migrate #8696

Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('add s3 walkthrough tests', () => {
.mockResolvedValueOnce([S3PermissionType.CREATE_AND_UPDATE, S3PermissionType.READ, S3PermissionType.DELETE]) // What kind of permissions (Auth)


prompter.confirmContinue = jest
prompter.yesOrNo = jest
Copy link
Contributor

Choose a reason for hiding this comment

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

we already fixed this right in earlier PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was missed out in the earlier PR

.fn()
.mockReturnValueOnce(true) //Do you want to add a Lambda Trigger ?
.mockResolvedValueOnce(false); //Do you want to edit the lamdba function now?
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('add s3 walkthrough tests', () => {
.mockResolvedValueOnce(S3TriggerFunctionType.EXISTING_FUNCTION)
.mockResolvedValueOnce(S3MockDataBuilder.mockExistingFunctionName1 ); //Selected the First Existing function from the list.

prompter.confirmContinue = jest
prompter.yesOrNo = jest
.fn()
.mockReturnValueOnce(true) //Do you want to add a Lambda Trigger ?
.mockResolvedValueOnce(false); //Do you want to edit the lamdba function now?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ export async function askCRUDQuestion(
const message = `What kind of access do you want for ${userRole} users?`;
const choices = possibleCRUDOperations;
const initialIndexes = getIndexArrayByValue(possibleCRUDOperations, roleDefaultValues);
const selectedPermissions = await prompter.pick<'many', string>(message, choices, { returnSize: 'many', initial: initialIndexes });
let selectedPermissions;
do {
selectedPermissions = await prompter.pick<'many', string>(message, choices, { returnSize: 'many', initial: initialIndexes });
if( !selectedPermissions || selectedPermissions.length <= 0 ){
printer.warn('Select at least one option');
}
} while( !selectedPermissions || selectedPermissions.length <= 0 );
return selectedPermissions as Array<S3PermissionType>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { $TSContext, AmplifyCategories, AmplifySupportedService, CLISubCommandTy
import { AmplifyS3ResourceStackTransform } from '../cdk-stack-builder/s3-stack-transform';
import { S3UserInputTriggerFunctionParams, S3UserInputs } from '../service-walkthrough-types/s3-user-input-types';
import { S3InputState } from './s3-user-input-state';
import { createNewLambdaAndUpdateCFN } from './s3-walkthrough';
import { createNewLambdaAndUpdateCFN, migrateStorageCategory } from './s3-walkthrough';

/**
* @returns Name of S3 resource or undefined
Expand All @@ -28,7 +28,9 @@ export function s3GetResourceName(): string | undefined {
* @returns
*/
export async function s3GetUserInput(context: $TSContext, s3ResourceName: string): Promise<S3UserInputs> {
const cliInputsState = new S3InputState(s3ResourceName as string, undefined);
//migrate storage and fetch cliInputsState
await migrateStorageCategory(context, s3ResourceName);
let cliInputsState = new S3InputState(s3ResourceName as string, undefined);
return cliInputsState.getUserInput();
}

Expand Down Expand Up @@ -194,8 +196,12 @@ export async function addLambdaTrigger(

/** HELPERS */
async function s3APIHelperTransformAndSaveState(context: $TSContext, storageInput: S3UserInputs, phase: CLISubCommandType) {
//migrate storage and fetch cliInputsState
await migrateStorageCategory(context, storageInput.resourceName as string);

//Save CLI Inputs payload
let cliInputsState;

if ( phase === CLISubCommandType.ADD ){
cliInputsState = new S3InputState(storageInput.resourceName as string, storageInput);
} else {
Expand Down