mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-05 03:30: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'
|
||||
|
||||
export class ContextManager {
|
||||
private sasViyaApiClient: SASViyaApiClient | null = null
|
||||
|
||||
constructor(
|
||||
private serverUrl: string,
|
||||
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(
|
||||
contextName: string,
|
||||
launchContextName: string,
|
||||
@@ -87,6 +84,14 @@ export class ContextManager {
|
||||
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) {
|
||||
const launcherContexts = await this.getLauncherContexts(accessToken)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user