91ce11274d
CI / checks (pull_request) Successful in 25m47s
Labels, empty states, error messages and defaults the console shows now name TheCloud or its runtimes. Identifiers that must match the emulator (FLOCI_* settings, the X-Floci-CSRF header, emulator-returned host names) are unchanged.
89 lines
6.7 KiB
TypeScript
89 lines
6.7 KiB
TypeScript
import type {FieldSchema, ServiceSchema, TableColumnSchema} from './types'
|
|
|
|
const projectColumns: TableColumnSchema[] = [
|
|
{name: 'name', label: 'Name'},
|
|
{name: 'environmentType', label: 'Environment', path: 'metadata.environmentType', format: 'badge'},
|
|
{name: 'computeType', label: 'Compute', path: 'metadata.computeType', format: 'badge'},
|
|
{name: 'createdAt', label: 'Created', format: 'datetime'},
|
|
]
|
|
|
|
const projectFilters: FieldSchema[] = [{name: 'search', label: 'Search', type: 'text', required: false}]
|
|
|
|
export const DEFAULT_DOCKER_TO_ECR_BUILDSPEC = 'version: 0.2\nphases:\n install:\n commands:\n - apt-get update && apt-get install -y --no-install-recommends awscli docker.io\n pre_build:\n commands:\n - REPOSITORY_URI=$(aws --endpoint-url "$AWS_ENDPOINT_URL" ecr describe-repositories --repository-names "$ECR_REPOSITORY" --query "repositories[0].repositoryUri" --output text)\n - ECR_REGISTRY=${REPOSITORY_URI%%/*}\n - aws --endpoint-url "$AWS_ENDPOINT_URL" ecr get-login-password | docker login --username AWS --password-stdin "$ECR_REGISTRY"\n build:\n commands:\n - REPOSITORY_URI=$(aws --endpoint-url "$AWS_ENDPOINT_URL" ecr describe-repositories --repository-names "$ECR_REPOSITORY" --query "repositories[0].repositoryUri" --output text)\n - IMAGE_TAG=build-$CODEBUILD_BUILD_NUMBER\n - docker build -t "$REPOSITORY_URI:$IMAGE_TAG" .\n - docker push "$REPOSITORY_URI:$IMAGE_TAG"\n post_build:\n commands:\n - REPOSITORY_URI=$(aws --endpoint-url "$AWS_ENDPOINT_URL" ecr describe-repositories --repository-names "$ECR_REPOSITORY" --query "repositories[0].repositoryUri" --output text)\n - IMAGE_TAG=build-$CODEBUILD_BUILD_NUMBER\n - printf \'{"ImageURI":"%s"}\' "$REPOSITORY_URI:$IMAGE_TAG" > imageDetail.json\nartifacts:\n files:\n - imageDetail.json\n - taskdef.json\n - appspec.yaml'
|
|
|
|
/** The console exposes only source and artifact modes the local runtime can execute. */
|
|
export function awsCodeBuildSchema(): ServiceSchema {
|
|
return {
|
|
cloud: 'aws',
|
|
service: 'codebuild',
|
|
displayName: 'AWS CodeBuild',
|
|
fields: [
|
|
{name: 'name', label: 'Project name', type: 'text', required: true, group: 'Required'},
|
|
{name: 'serviceRole', label: 'Service role ARN', type: 'text', required: true, group: 'Required'},
|
|
{
|
|
name: 'sourceType', label: 'Source type', type: 'select', required: true, group: 'Source', defaultValue: 'NO_SOURCE',
|
|
options: [{label: 'No source', value: 'NO_SOURCE'}, {label: 'Amazon S3', value: 'S3'}],
|
|
description: 'S3 source is supported locally. GitHub and Gitea sources are not executed by the local runner.',
|
|
},
|
|
{
|
|
name: 'sourceBucket', label: 'Source S3 bucket', type: 'text', required: false, requiredWhen: {field: 'sourceType', equals: 'S3'}, group: 'Source',
|
|
validation: {pattern: '^[a-z0-9](?:[a-z0-9.-]{1,61}[a-z0-9])?$', message: 'Use a valid 3-63 character S3 bucket name.'},
|
|
},
|
|
{
|
|
name: 'sourceKey', label: 'Source object key', type: 'text', required: false, requiredWhen: {field: 'sourceType', equals: 'S3'}, group: 'Source',
|
|
description: 'The ZIP source object key in the source bucket.',
|
|
},
|
|
{
|
|
name: 'buildspec', label: 'Buildspec', type: 'textarea', required: false, group: 'Source', span: true,
|
|
defaultValueWhen: {field: 'sourceType', values: {NO_SOURCE: DEFAULT_DOCKER_TO_ECR_BUILDSPEC, S3: ''}},
|
|
description: 'For no source, this is TheCloud\'s Node 20 Docker-to-ECR buildspec. For S3, leave blank to use buildspec.yml from the source, or provide an override. Include taskdef.json and appspec.yaml in the source for CodeDeployToECS.',
|
|
},
|
|
{
|
|
name: 'artifactsType', label: 'Artifact type', type: 'select', required: true, group: 'Artifacts', defaultValue: 'NO_ARTIFACTS',
|
|
options: [{label: 'No artifacts', value: 'NO_ARTIFACTS'}, {label: 'Amazon S3', value: 'S3'}],
|
|
},
|
|
{
|
|
name: 'artifactsBucket', label: 'Artifact S3 bucket', type: 'text', required: false, requiredWhen: {field: 'artifactsType', equals: 'S3'}, group: 'Artifacts',
|
|
validation: {pattern: '^[a-z0-9](?:[a-z0-9.-]{1,61}[a-z0-9])?$', message: 'Use a valid 3-63 character S3 bucket name.'},
|
|
},
|
|
{
|
|
name: 'artifactsPrefix', label: 'Artifact prefix', type: 'text', required: false, group: 'Artifacts',
|
|
description: 'Optional S3 key prefix for build artifacts.',
|
|
},
|
|
{
|
|
name: 'environmentImage', label: 'Runtime image', type: 'select', required: true, group: 'Environment',
|
|
defaultValue: 'node:20-bookworm',
|
|
options: [
|
|
{label: 'CodeBuild Standard 7.0', value: 'aws/codebuild/standard:7.0'},
|
|
{label: 'Node.js 20 (Debian)', value: 'node:20-bookworm'},
|
|
],
|
|
description: 'Choose the container runtime for your build commands.',
|
|
},
|
|
{
|
|
name: 'computeType', label: 'Compute type', type: 'select', required: true, group: 'Environment', defaultValue: 'BUILD_GENERAL1_SMALL',
|
|
options: [{label: 'General 1 small', value: 'BUILD_GENERAL1_SMALL'}],
|
|
},
|
|
{
|
|
name: 'ecrRepository', label: 'ECR repository', type: 'text', required: true, group: 'Docker and ECR',
|
|
description: 'An existing ECR repository. The project exports it as ECR_REPOSITORY for the Docker buildspec.',
|
|
},
|
|
{
|
|
name: 'dockerPrivilegedMode', label: 'Docker daemon', type: 'select', required: true, group: 'Docker and ECR', defaultValue: 'enabled',
|
|
options: [{label: 'Enabled (required for Docker builds)', value: 'enabled'}],
|
|
description: 'CodeBuild runs Docker-in-Docker in privileged mode for ECS EC2 and Fargate deployment artifacts.',
|
|
},
|
|
],
|
|
actions: ['list', 'create', 'delete', 'inspect'],
|
|
capabilities: {
|
|
resourceActions: [
|
|
{name: 'list', label: 'List projects', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'inspect', label: 'Inspect project', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'create', label: 'Create project', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'delete', label: 'Delete project', enabled: true, status: 'available', runtimeRequired: true},
|
|
],
|
|
},
|
|
filters: projectFilters,
|
|
columns: projectColumns,
|
|
}
|
|
}
|