Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/openapi/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@ Cluster:
k8sContext:
type: string
x-hidden: true
owner:
title: Owner
$ref: 'definitions.yaml#/idName'
description: The name of the organization owning the cluster.
default: otomi
provider:
$ref: 'definitions.yaml#/provider'
required:
- name
- provider
6 changes: 3 additions & 3 deletions src/otomi-stack.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import { mockDeep } from 'jest-mock-extended'
import { AplCodeRepoResponse, AplServiceRequest, App, CodeRepo, Team, TeamConfig, User } from 'src/otomi-models'
import OtomiStack from 'src/otomi-stack'
import { mockDeep } from 'jest-mock-extended'
import { PublicUrlExists } from './error'
import { loadSpec } from './app'
import { PublicUrlExists } from './error'
import { Git } from './git'
import { RepoService } from './services/RepoService'
import { TeamConfigService } from './services/TeamConfigService'
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Users tests', () => {
otomiStack.git = mockDeep<Git>()

jest.spyOn(otomiStack, 'getSettings').mockReturnValue({
cluster: { domainSuffix },
cluster: { name: 'default-cluster', domainSuffix, provider: 'linode' },
})
jest.spyOn(otomiStack, 'saveUser').mockResolvedValue()
jest.spyOn(otomiStack, 'doDeployment').mockResolvedValue()
Expand Down
18 changes: 9 additions & 9 deletions src/services/RepoService.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AlreadyExists } from '../error'
import { App, Repo, User } from '../otomi-models'
import { RepoService } from './RepoService'
import { TeamConfigService } from './TeamConfigService'
import { AlreadyExists } from '../error'

jest.mock('uuid', () => ({
v4: jest.fn(() => 'mocked-uuid'),
Expand All @@ -16,7 +16,7 @@ describe('RepoService', () => {
apps: [],
users: [],
teamConfig: {},
cluster: {},
cluster: { name: 'Test Cluster', provider: 'linode' },
dns: {},
ingress: {},
otomi: { version: '1.0.0' },
Expand Down Expand Up @@ -125,8 +125,8 @@ describe('RepoService', () => {

describe('Collection Functions', () => {
test('should retrieve a collection', () => {
service.getRepo().cluster = { name: 'Test Cluster' }
expect(service.getCollection('cluster')).toEqual({ name: 'Test Cluster' })
service.getRepo().cluster = { name: 'Test Cluster', provider: 'linode' }
expect(service.getCollection('cluster')).toEqual({ name: 'Test Cluster', provider: 'linode' })
})

test('should throw an error for non-existent collection', () => {
Expand All @@ -136,7 +136,7 @@ describe('RepoService', () => {
})

test('should update an existing collection', () => {
service.getRepo().cluster = { name: 'Old Cluster' }
service.getRepo().cluster = { name: 'Old Cluster', provider: 'linode' }
service.updateCollection('cluster', { name: 'Updated Cluster' })
expect(service.getCollection('cluster')).toEqual({ name: 'Updated Cluster' })
})
Expand All @@ -150,17 +150,17 @@ describe('RepoService', () => {

describe('Settings', () => {
test('should retrieve settings', () => {
service.getRepo().cluster = { name: 'Cluster A' }
service.getRepo().cluster = { name: 'Cluster A', provider: 'linode' }
service.getRepo().dns = { provider: { linode: { apiToken: 'test' } } }
const settings = service.getSettings()

expect(settings.cluster).toEqual({ name: 'Cluster A' })
expect(settings.cluster).toEqual({ name: 'Cluster A', provider: 'linode' })
expect(settings.dns).toEqual({ provider: { linode: { apiToken: 'test' } } })
})

test('should update settings', () => {
service.updateSettings({ cluster: { name: 'Updated Cluster' } })
expect(service.getSettings().cluster).toEqual({ name: 'Updated Cluster' })
service.updateSettings({ cluster: { name: 'Updated Cluster', provider: 'linode' } })
expect(service.getSettings().cluster).toEqual({ name: 'Updated Cluster', provider: 'linode' })
})
})

Expand Down
Loading