-
Notifications
You must be signed in to change notification settings - Fork 13
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
Flagfeature #1237
Flagfeature #1237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my suggestions and a question!
messages/clone.md
Outdated
|
||
# error.sandboxNameQueryFailed | ||
|
||
Unable to find the ID of the sandboxName "%s" that's defined in the definition file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unable to find the ID of the sandboxName "%s" that's defined in the definition file. | |
Unable to find the ID of the sandbox "%s" that's defined in the definition file. |
messages/create.sandbox.md
Outdated
The value of --clone must be an existing sandbox. The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses. | ||
The value of --source-sandbox-name must be an existing sandbox. The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses. | ||
|
||
You can specify either --source-sandbox-name or --source-id for clone an existing sandbox but not both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can specify either --source-sandbox-name or --source-id for clone an existing sandbox but not both. | |
You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both. |
messages/create.sandbox.md
Outdated
|
||
The value of --source-id must be an existing sandbox. The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses. | ||
|
||
You can specify either --source-sandbox-name or --source-id for clone an existing sandbox but not both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can specify either --source-sandbox-name or --source-id for clone an existing sandbox but not both. | |
You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both. |
messages/create.sandbox.md
Outdated
@@ -120,6 +132,14 @@ The sandbox request configuration isn't acceptable. | |||
|
|||
The poll interval (%d seconds) can't be larger that wait (%d in seconds) | |||
|
|||
# error.noCloneSource | |||
# error.noCloneSourceName | |||
|
|||
Could not find the clone sandbox name "%s" in the target org. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find the clone sandbox name "%s" in the target org. | |
Couldn't find the clone sandbox name "%s" in the target org. |
messages/create.sandbox.md
Outdated
|
||
# error.noCloneSourceId | ||
|
||
Could not find the clone sandbox id "%s" in the target org. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find the clone sandbox id "%s" in the target org. | |
Couldn't find the clone sandbox ID "%s" in the target org. |
messages/create.sandbox.md
Outdated
|
||
# error.cloneFlagsConflict | ||
|
||
You can not use clone Name or Id flags and clone Name or Id fields in the definition file at the same time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what this error message means. Can you elaborate? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our DMs, it sounds like this error occurs if users try to use --source-sandbox-name
AND --definition-file
AND the definition file contains SourceSandboxName
. Ditto for the ID equivalents. And I guess this isn't allowed? If this is indeed the situation, here's my edit of the error:
You can't specify both the --source-sandbox-name and --definition-file flags, and also include the "SourceSandboxName" option in the definition file. Same with the --source-id flag and "SourceId" option. Pick one method of cloning a sandbox and try again.
src/commands/force/org/create.ts
Outdated
@@ -211,7 +211,7 @@ export class Create extends SfCommand<CreateResult> { | |||
}); | |||
|
|||
const { sandboxReq } = await requestFunctions.createSandboxRequest( | |||
false, | |||
// false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this comment
src/commands/org/create/sandbox.ts
Outdated
@@ -20,13 +20,15 @@ const getLicenseTypes = (): string[] => Object.values(SandboxLicenseType); | |||
|
|||
type SandboxConfirmData = SandboxRequest & { CloneSource?: string }; | |||
|
|||
// eslint-disable-next-line sf-plugin/only-extend-SfCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were these causing errors? if not, let's re-enable them 👍🏼 (warnings reminds us we have to do it anyway)
src/commands/org/create/sandbox.ts
Outdated
@@ -79,18 +81,25 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxCommandResp | |||
return Promise.resolve(name); | |||
}, | |||
}), | |||
clone: Flags.string({ | |||
'source-sandbox-name': Flags.string({ | |||
char: 'c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the short flag -c
should also be a deprecated alias.
src/commands/org/create/sandbox.ts
Outdated
deprecateAliases: true, | ||
aliases: ['clone'], | ||
}), | ||
'source-id': Flags.string({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be a salesforceId
flag, example:
plugin-org/src/commands/org/create/scratch.ts
Lines 148 to 155 in 0e7d3a7
'source-org': Flags.salesforceId({ | |
summary: messages.getMessage('flags.source-org.summary'), | |
startsWith: '00D', | |
length: 15, | |
helpGroup: definitionFileHelpGroupName, | |
// salesforceId flag has `i` and that would be a conflict with client-id | |
char: undefined, | |
}), |
I don't see the API mentions sandbox IDs start with a particular prefix so we can omit the startWith
option.
Flags.salesforceId
will validate that the ID length is 15 or 18.
src/commands/org/create/sandbox.ts
Outdated
? { SourceId: await requestFunctions.getSrcIdByName(this.flags['target-org'].getConnection(), srcSandboxName) } | ||
: {}), | ||
...(srcId ? { SourceId: srcId } : {}), | ||
...(this.flags['source-id'] ? { SourceId: await this.getSourceId() } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check for flags and props, on L140 we already pass the source flags as requestOptions
to requestFunctions.createSandboxRequest
, srcSandboxName
and srcId
should have the flag/def. file values.
src/commands/org/create/sandbox.ts
Outdated
? { CloneSource: this.flags['source-sandbox-name'] } | ||
: this.flags['source-id'] | ||
? { CloneSource: this.flags['source-id'] } | ||
: {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CloneSource
will only be shown if when using the source flags, what if I'm specifying the ID in the def. file instead?
Maybe CloneSource
should always show the source ID (you can grab it from sandboxReq.SourceId
, so we don't need to check flag/def. file values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soridalac this is still unresolved ⬆️
we can ignore --source-sandbox-name
, just check for sandboxReq.SourceId
src/commands/org/create/sandbox.ts
Outdated
const sourceSandboxNameInDefFile = !!defFileContent.SourceSandboxName; | ||
|
||
if ((sourceIdFlag || sourceSandboxNameFlag) && (sourceIdInDefFile || sourceSandboxNameInDefFile)) { | ||
throw messages.createError('error.cloneFlagsConflict'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these validations don't require any specific context other than reading the def.file, let's move these to each source flag, like this:
parse: (name: string): Promise<string> => { |
you can do more specific error msgs like Can't use --source-id and define
sourceId in the def. file
at the same time.
src/commands/org/create/sandbox.ts
Outdated
return sourceOrg.SandboxInfoId; | ||
} catch (err) { | ||
throw messages.createError('error.noCloneSource', [this.flags.clone], [], err as Error); | ||
throw messages.createError('error.noCloneSourceId', [this.flags['source-id']], [], err as Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method can be removed, the value of --source-id
or sourceId
in the def. file is already a valid ID that we can pass to the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requested some changes.
Also can you add some UTs in test/shared/sandboxRequest.test.ts
to cover the new scenarios? e.g. sourceId/sourceSandboxName
throws, sourceId/sourceSandboxName
trigger a clone.
if (!SourceSandboxName) { | ||
// error - we need SourceSandboxName to know which sandbox to clone from | ||
if (!sandboxReqWithName.SourceSandboxName && !sandboxReqWithName.SourceId) { | ||
// error - we need SourceSandboxName or SourceId to know which sandbox to clone from | ||
throw new SfError( | ||
cloneMessages.getMessage('missingSourceSandboxName', ['SourceSandboxName']), | ||
cloneMessages.getMessage('missingSourceSandboxNameAction', ['SourceSandboxName']) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update these errors so they point if either SourceSandboxName
or SourceId
are being missed? the missingSourceSandboxName
error will only mention SourceSandboxName
src/commands/org/create/sandbox.ts
Outdated
return { | ||
...sandboxReq, | ||
...(this.flags.clone ? { SourceId: await this.getSourceId() } : {}), | ||
...(srcSandboxName ?? this.flags['source-sandbox-name'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to check for --source-sandbox-name
here, srcSandboxName
should have that value (requestFunctions.createSandboxRequest
takes these flags as requestOptions
and merges them with the def.file).
src/commands/org/create/sandbox.ts
Outdated
...(srcSandboxName ?? this.flags['source-sandbox-name'] | ||
? { SourceId: await requestFunctions.getSrcIdByName(this.flags['target-org'].getConnection(), srcSandboxName) } | ||
: {}), | ||
...(srcId ?? this.flags['source-id'] ? { SourceId: srcId } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, srcId
should have the flag value, def. file value or undefined
https://github.com/salesforcecli/plugin-org/pull/1237/files#r1805117017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there!
there are a few unresolved comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, I'm approving code changes only, will ping Juliet for another review of the messages before merging.
✅ fixed |
What does this PR do?
feat: update flags and fields in definition file for cloning existing sandbox.
What issues does this PR fix or reference?
@W-16883274@
forcedotcom/cli#3036