786689e0fd
Introduce a catalog-driven Tools Management section under Clusters so admins can install/uninstall infrastructure tools per cluster: cert-manager (Helm/jetstack), ClusterIssuer (email + HTTP01 form, depends on cert-manager), and central Elasticsearch. Cluster creation no longer auto-installs Elastic or the cloudhost-node-cluster-dns DaemonSet; build bootstrap stays automatic. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { ClusterToolsService } from './cluster-tools.service';
|
|
import { InstallToolDto } from './dto/install-tool.dto';
|
|
import { RolesGuard } from '../common/guards/roles.guard';
|
|
import { Roles } from '../common/decorators/roles.decorator';
|
|
import { UserRole } from '../common/enums';
|
|
import { ClusterToolId } from './cluster-tools.types';
|
|
|
|
@ApiTags('Clusters - Tools')
|
|
@ApiBearerAuth()
|
|
@Controller('clusters/:id/tools')
|
|
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
|
@Roles(UserRole.ADMIN)
|
|
export class ClusterToolsController {
|
|
constructor(private readonly toolsService: ClusterToolsService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List installable tools and their status on a cluster (Admin)' })
|
|
async list(@Param('id') id: string) {
|
|
return this.toolsService.getToolsForCluster(id);
|
|
}
|
|
|
|
@Post(':toolId/install')
|
|
@ApiOperation({ summary: 'Install an infrastructure tool on a cluster (Admin)' })
|
|
async install(
|
|
@Param('id') id: string,
|
|
@Param('toolId') toolId: ClusterToolId,
|
|
@Body() dto: InstallToolDto,
|
|
) {
|
|
return this.toolsService.install(id, toolId, { ...dto } as Record<string, string>);
|
|
}
|
|
|
|
@Delete(':toolId')
|
|
@ApiOperation({ summary: 'Uninstall an infrastructure tool from a cluster (Admin)' })
|
|
async uninstall(
|
|
@Param('id') id: string,
|
|
@Param('toolId') toolId: ClusterToolId,
|
|
) {
|
|
return this.toolsService.uninstall(id, toolId);
|
|
}
|
|
}
|