Skip to content

Commit

Permalink
consider question skipping status while validating vpc id
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh authored and bigadsoleiman committed Mar 8, 2024
1 parent f825e2c commit d995eae
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cli/magic-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const embeddingModels = [
fs.readFileSync("./bin/config.json").toString("utf8")
);
options.prefix = config.prefix;
options.vpc = config.vpc ? true : false;
options.vpcId = config.vpc?.vpcId;
options.createVpcEndpoints = config.vpc?.createVpcEndpoints;
options.privateWebsite = config.privateWebsite;
Expand Down Expand Up @@ -124,16 +123,16 @@ async function processCreateOptions(options: any): Promise<void> {
type: "confirm",
name: "existingVpc",
message: "Do you want to use existing vpc? (selecting false will create a new vpc)",
initial: options.vpc || false,
initial: options.vpcId ? true : false,
},
{
type: "input",
name: "vpcId",
message: "Specify existing VpcId (vpc-xxxxxxxxxxxxxxxxx)",
initial: options.vpcId,
validate: (vpcId: string) =>{
return RegExp(/^vpc-[0-9a-f]{8,17}$/i).test(vpcId) ? true
: "Enter a valid VpcId in vpc-0123456abdef format"
validate(vpcId: string) {
return ((this as any).skipped || RegExp(/^vpc-[0-9a-f]{8,17}$/i).test(vpcId)) ?
true : 'Enter a valid VpcId in vpc-xxxxxxxxxxx format'
},
skip(): boolean {
return !(this as any).state.answers.existingVpc;
Expand Down

0 comments on commit d995eae

Please sign in to comment.