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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 28 additions & 12 deletions src/otomi-stack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CoreV1Api, KubeConfig, User as k8sUser, V1ObjectReference } from '@kubernetes/client-node'
import Debug from 'debug'

import { getRegions, ObjectStorageKeyRegions } from '@linode/api-v4'
import { getRegions, ObjectStorageKeyRegions, Region, ResourcePage } from '@linode/api-v4'
import { existsSync, rmSync } from 'fs'
import { pathExists, unlink } from 'fs-extra'
import { readdir, readFile, writeFile } from 'fs/promises'
Expand Down Expand Up @@ -105,6 +105,7 @@ import {
HIDDEN_APPS,
KNOWLEDGE_BASE_KIND,
OBJ_STORAGE_APPS,
OBJECT_STORAGE_UI_EXCLUSIONS,
PREINSTALLED_EXCLUDED_APPS,
TOOLS_HOST,
VERSIONS,
Expand Down Expand Up @@ -169,6 +170,7 @@ const env = cleanEnv({
HIDDEN_APPS,
OBJ_STORAGE_APPS,
KNOWLEDGE_BASE_KIND,
OBJECT_STORAGE_UI_EXCLUSIONS,
})

export const rootPath = '/tmp/otomi/values'
Expand Down Expand Up @@ -2980,17 +2982,7 @@ export default class OtomiStack {
const valuesSchema = await getValuesSchema()
const currentSha = rootStack.git.commitSha
const { obj } = this.getSettings(['obj'])
let regions
try {
regions = await getRegions()
} catch (error) {
debug('Error fetching object storage regions:', error.message)
}
const objStorageRegions =
regions?.data
?.filter((region) => region.capabilities.includes('Object Storage'))
?.map(({ id, label }) => ({ id, label }))
?.sort((a, b) => a.label.localeCompare(b.label)) || []
const objStorageRegions = await this.getObjStorageRegions()
const data: Session = {
ca: env.CUSTOM_ROOT_CA,
core: this.getCore() as Record<string, any>,
Expand All @@ -3010,4 +3002,28 @@ export default class OtomiStack {
}
return data
}

private async getObjStorageRegions() {
const allRegions: Region[] = []
try {
let page = 1
let totalPages: number
do {
const response: ResourcePage<Region> = await getRegions({ page, page_size: 500 })
allRegions.push(...response.data)
totalPages = response.pages
page++
} while (page <= totalPages)
} catch (error) {
debug('Error fetching object storage regions:', error.message)
}
const objStorageRegions = allRegions
.filter(
(region) =>
region.capabilities?.includes('Object Storage') && !env.OBJECT_STORAGE_UI_EXCLUSIONS.includes(region.id),
)
.sort((a, b) => a.label.localeCompare(b.label))
.map(({ id, label }) => ({ id, label }))
return objStorageRegions
}
}
4 changes: 4 additions & 0 deletions src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export const TRUST_PROXY = num({
default: 2,
devDefault: 0,
})
export const OBJECT_STORAGE_UI_EXCLUSIONS = json<string[]>({
desc: 'Object Storage regions hidden in the UI',
default: ['fr-par-2', 'in-bom-2'],
})
const { env } = process
export function cleanEnv<T>(validators: { [K in keyof T]: ValidatorSpec<T[K]> }, options: CleanOptions<T> = {}) {
if (env.NODE_ENV === 'test') {
Expand Down
Loading