Skip to main content

CGC Universe at your disposal

With context you are allowed to quickly switch from one CGC instance to another.

You either need to register on every CGC instance, or import existing context files, that you own.

This is essential for managing development, staging, and production environments without constantly reconfiguring your connection.

  • Different Kubernetes namespaces
  • Isolated environments with separate resource quotas
  • Independent configuration sets
  • Distinct access permissions and policies

Context management

The CGC SDK provides two main functions for context management:

List available contexts

Display all context available for the CGC app within environment.

import cgc.sdk.context as context

# Get all available contexts
contexts = context.list_contexts()
print("Available contexts:", contexts)

# Example output:
# Available contexts: ['cfg.json', '2.json', '3.json']

Switch between contexts

Switch from one CGC instance (or instance namespace) to another.

import cgc.sdk.context as context

# Switch to context 2
context.switch_context(2)
print("Switched to context 2")

# Switch back to the default context (1)
context.switch_context(1)
print("Switched back to default context")

Important notes

Context numbering

Contexts are identified by numbers, not names:

  • Context 1: Default context (cfg.json)
  • Context 2: Second context (2.json)
  • Context 3: Third context (3.json)
  • And so on...

Configuration files

Each context corresponds to a configuration file:

  • Context 1 → cfg.json
  • Context 2 → 2.json
  • Context 3 → 3.json