mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-17 00:50:05 +00:00
feat(createComputeContext): added throw an error if context already exists
This commit is contained in:
@@ -9,8 +9,6 @@ import { SASViyaApiClient } from './SASViyaApiClient'
|
|||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
|
|
||||||
export class ContextManager {
|
export class ContextManager {
|
||||||
private sasViyaApiClient: SASViyaApiClient | null = null
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serverUrl: string,
|
private serverUrl: string,
|
||||||
private setCsrfToken: (csrfToken: CsrfToken) => void
|
private setCsrfToken: (csrfToken: CsrfToken) => void
|
||||||
@@ -74,7 +72,6 @@ export class ContextManager {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if context already exist, reject with the error if so
|
|
||||||
public async createComputeContext(
|
public async createComputeContext(
|
||||||
contextName: string,
|
contextName: string,
|
||||||
launchContextName: string,
|
launchContextName: string,
|
||||||
@@ -87,6 +84,14 @@ export class ContextManager {
|
|||||||
throw new Error('Context name is required.')
|
throw new Error('Context name is required.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const existingComputeContexts = await this.getComputeContexts(accessToken)
|
||||||
|
|
||||||
|
if (
|
||||||
|
existingComputeContexts.find((context) => context.name === contextName)
|
||||||
|
) {
|
||||||
|
throw new Error(`Compute context '${contextName}' already exists.`)
|
||||||
|
}
|
||||||
|
|
||||||
if (launchContextName) {
|
if (launchContextName) {
|
||||||
const launcherContexts = await this.getLauncherContexts(accessToken)
|
const launcherContexts = await this.getLauncherContexts(accessToken)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user