All files / src/cli/docker types.ts

100% Statements 5/5
50% Branches 1/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185                                                                                                                                                                                                      5x                                                                                                                                               5x                 5x 48x 48x    
/**
 * Types for Docker module
 */
 
/**
 * Container runtime type (docker or podman)
 */
export type ContainerRuntime = "docker" | "podman";
 
/**
 * Detected container runtime information
 */
export interface ContainerRuntimeInfo {
  /** Which runtime was detected */
  runtime: ContainerRuntime;
  /** Command to invoke the runtime (e.g. "docker" or "podman") */
  runtimeCmd: string;
  /** Whether the runtime daemon is accessible */
  runtimeAvailable: boolean;
  /** Compose command tokens, e.g. ["docker", "compose"] or ["podman-compose"], null if unavailable */
  composeCmd: string[] | null;
  /** Version string of the runtime, undefined if not detected */
  runtimeVersion?: string;
}
 
/**
 * Docker container status
 */
export type ContainerStatus =
  | "running"
  | "stopped"
  | "paused"
  | "restarting"
  | "created"
  | "exited"
  | "dead";
 
/**
 * Docker container info
 */
export interface ContainerInfo {
  id: string;
  name: string;
  image: string;
  status: ContainerStatus;
  ports: string[];
  created: string;
  uptime?: string;
}
 
/**
 * GitLab instance OAuth configuration
 */
export interface GitLabInstanceOAuth {
  clientId: string;
  clientSecretEnv: string;
}
 
/**
 * GitLab instance configuration
 */
export interface GitLabInstance {
  /** Instance host (e.g., gitlab.com, gitlab.company.com) */
  host: string;
  /** Display name */
  name: string;
  /** OAuth configuration */
  oauth?: GitLabInstanceOAuth;
  /** Default preset for this instance */
  defaultPreset?: string;
}
 
/**
 * Docker configuration for gitlab-mcp
 */
export interface DockerConfig {
  /** SSE port (default: 3333) */
  port: number;
  /** Deployment type (standalone, external-db, compose-bundle) */
  deploymentType?: "standalone" | "external-db" | "compose-bundle";
  /** Enable OAuth mode */
  oauthEnabled: boolean;
  /** OAuth session secret */
  oauthSessionSecret?: string;
  /** Database URL for sessions */
  databaseUrl?: string;
  /** Additional environment variables (e.g., GITLAB_PROFILE, USE_* flags) */
  environment?: Record<string, string>;
  /** Configured GitLab instances */
  instances: GitLabInstance[];
  /** Container name */
  containerName: string;
  /** Docker image */
  image: string;
}
 
/**
 * Default Docker configuration
 */
export const DEFAULT_DOCKER_CONFIG: DockerConfig = {
  port: 3333,
  oauthEnabled: false,
  instances: [],
  containerName: "gitlab-mcp",
  image: "ghcr.io/structured-world/gitlab-mcp:latest",
};
 
/**
 * Docker compose service configuration
 */
export interface DockerComposeService {
  image: string;
  container_name: string;
  ports: string[];
  environment: string[];
  volumes: string[];
  restart: string;
  depends_on?: string[];
}
 
/**
 * Docker compose file structure
 */
export interface DockerComposeFile {
  version: string;
  services: Record<string, DockerComposeService>;
  volumes?: Record<string, object>;
}
 
/**
 * Instances YAML file structure
 */
export interface InstancesYaml {
  instances: Record<
    string,
    {
      name: string;
      oauth?: {
        client_id: string;
        client_secret_env: string;
      };
      default_preset?: string;
    }
  >;
}
 
/**
 * Docker command result
 */
export interface DockerCommandResult {
  success: boolean;
  output?: string;
  error?: string;
}
 
/**
 * Docker status result
 */
export interface DockerStatusResult {
  dockerInstalled: boolean;
  dockerRunning: boolean;
  composeInstalled: boolean;
  container?: ContainerInfo;
  instances: GitLabInstance[];
  /** Detected container runtime details */
  runtime?: ContainerRuntimeInfo;
}
 
/**
 * Config directory paths
 */
export const CONFIG_PATHS = {
  darwin: "~/.config/gitlab-mcp",
  win32: "%APPDATA%/gitlab-mcp",
  linux: "~/.config/gitlab-mcp",
} as const;
 
/**
 * Get config directory for current platform
 */
export function getConfigDir(): string {
  const platform = process.platform as "darwin" | "win32" | "linux";
  return CONFIG_PATHS[platform] ?? CONFIG_PATHS.linux;
}