1
0
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:
Yury Shkoda
2020-12-29 10:00:49 +03:00
parent 8d155283dd
commit dfb9c28f3a

View File

@@ -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)