mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 10:58:31 -05:00
Remove azdata eula acceptance from arc deployments (#12292)
* saving to switch tasks * activate to exports in extApi * working version - cleanup pending * improve messages * apply pr feedback from a different review * remove unneeded strings * redo apiService * remove async from getVersionFromOutput * remove _ prefix from protected fields * error message fix * throw specif errors from azdata extension * arrow methods to regular methods * pr feedback * expand azdata extension api * pr feedback * remove unused var * pr feedback
This commit is contained in:
@@ -24,9 +24,6 @@ const enum AzdataDeployOption {
|
||||
* Interface for an object to interact with the azdata tool installed on the box.
|
||||
*/
|
||||
export interface IAzdataTool extends azdataExt.IAzdataApi {
|
||||
path: string,
|
||||
cachedVersion: SemVer
|
||||
|
||||
/**
|
||||
* Executes azdata with the specified arguments (e.g. --version) and returns the result
|
||||
* @param args The args to pass to azdata
|
||||
@@ -39,9 +36,26 @@ export interface IAzdataTool extends azdataExt.IAzdataApi {
|
||||
* An object to interact with the azdata tool installed on the box.
|
||||
*/
|
||||
export class AzdataTool implements IAzdataTool {
|
||||
public cachedVersion: SemVer;
|
||||
constructor(public path: string, version: string) {
|
||||
this.cachedVersion = new SemVer(version);
|
||||
|
||||
private _semVersion: SemVer;
|
||||
constructor(private _path: string, version: string) {
|
||||
this._semVersion = new SemVer(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* The semVersion corresponding to this installation of azdata. version() method should have been run
|
||||
* before fetching this value to ensure that correct value is returned. This is almost always correct unless
|
||||
* Azdata has gotten reinstalled in the background after this IAzdataApi object was constructed.
|
||||
*/
|
||||
public getSemVersion() {
|
||||
return this._semVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the path where azdata tool is installed
|
||||
*/
|
||||
public getPath() {
|
||||
return this._path;
|
||||
}
|
||||
|
||||
public arc = {
|
||||
@@ -141,8 +155,8 @@ export class AzdataTool implements IAzdataTool {
|
||||
* It also updates the cachedVersion property based on the return value from the tool.
|
||||
*/
|
||||
public async version(): Promise<azdataExt.AzdataOutput<string>> {
|
||||
const output = await executeAzdataCommand(`"${this.path}"`, ['--version']);
|
||||
this.cachedVersion = new SemVer(parseVersion(output.stdout));
|
||||
const output = await executeAzdataCommand(`"${this._path}"`, ['--version']);
|
||||
this._semVersion = new SemVer(parseVersion(output.stdout));
|
||||
return {
|
||||
logs: [],
|
||||
stdout: output.stdout.split(os.EOL),
|
||||
@@ -153,7 +167,7 @@ export class AzdataTool implements IAzdataTool {
|
||||
|
||||
public async executeCommand<R>(args: string[], additionalEnvVars?: { [key: string]: string }): Promise<azdataExt.AzdataOutput<R>> {
|
||||
try {
|
||||
const output = JSON.parse((await executeAzdataCommand(`"${this.path}"`, args.concat(['--output', 'json']), additionalEnvVars)).stdout);
|
||||
const output = JSON.parse((await executeAzdataCommand(`"${this._path}"`, args.concat(['--output', 'json']), additionalEnvVars)).stdout);
|
||||
return {
|
||||
logs: <string[]>output.log,
|
||||
stdout: <string[]>output.stdout,
|
||||
@@ -172,7 +186,7 @@ export class AzdataTool implements IAzdataTool {
|
||||
// it means this was probably some other generic error (such as command not being found)
|
||||
// check if azdata still exists if it does then rethrow the original error if not then emit a new specific error.
|
||||
try {
|
||||
await fs.promises.access(this.path);
|
||||
await fs.promises.access(this._path);
|
||||
//this.path exists
|
||||
throw err; // rethrow the error
|
||||
} catch (e) {
|
||||
@@ -207,7 +221,7 @@ export async function findAzdata(): Promise<IAzdataTool> {
|
||||
try {
|
||||
const azdata = await findSpecificAzdata();
|
||||
await vscode.commands.executeCommand('setContext', azdataFound, true); // save a context key that azdata was found so that command for installing azdata is no longer available in commandPalette and that for updating it is.
|
||||
Logger.log(loc.foundExistingAzdata(azdata.path, azdata.cachedVersion.raw));
|
||||
Logger.log(loc.foundExistingAzdata(azdata.getPath(), azdata.getSemVersion().raw));
|
||||
return azdata;
|
||||
} catch (err) {
|
||||
Logger.log(loc.couldNotFindAzdata(err));
|
||||
@@ -293,12 +307,12 @@ export async function checkAndInstallAzdata(userRequested: boolean = false): Pro
|
||||
*/
|
||||
export async function checkAndUpdateAzdata(currentAzdata?: IAzdataTool, userRequested: boolean = false): Promise<boolean> {
|
||||
if (currentAzdata !== undefined) {
|
||||
const newVersion = await discoverLatestAvailableAzdataVersion();
|
||||
if (newVersion.compare(currentAzdata.cachedVersion) === 1) {
|
||||
Logger.log(loc.foundAzdataVersionToUpdateTo(newVersion.raw, currentAzdata.cachedVersion.raw));
|
||||
return await promptToUpdateAzdata(newVersion.raw, userRequested);
|
||||
const newSemVersion = await discoverLatestAvailableAzdataVersion();
|
||||
if (newSemVersion.compare(currentAzdata.getSemVersion()) === 1) {
|
||||
Logger.log(loc.foundAzdataVersionToUpdateTo(newSemVersion.raw, currentAzdata.getSemVersion().raw));
|
||||
return await promptToUpdateAzdata(newSemVersion.raw, userRequested);
|
||||
} else {
|
||||
Logger.log(loc.currentlyInstalledVersionIsLatest(currentAzdata.cachedVersion.raw));
|
||||
Logger.log(loc.currentlyInstalledVersionIsLatest(currentAzdata.getSemVersion().raw));
|
||||
}
|
||||
} else {
|
||||
Logger.log(loc.updateCheckSkipped);
|
||||
|
||||
Reference in New Issue
Block a user