Merge branch 'feat/docker-validator' into chore/all-my-stuffs

# Conflicts:
#	package.json
#	pnpm-lock.yaml
#	src/tools/index.ts
This commit is contained in:
ShareVB committed 2024-11-03 22:44:38 +01:00
commit dd49e2fceb
6 files changed
+107

No files matched your search

+1
View File
@@ -122,6 +122,7 @@
"countries-and-timezones": "^3.7.2",
"countries-and-timezones": "^3.6.0",
"convert": "^5.4.1",
"composeverter": "^1.7.2",
"country-code-lookup": "^0.1.0",
"crc": "^4.3.2",
"countries-and-timezones": "^3.6.0",
+3
View File
@@ -191,6 +191,9 @@ dependencies:
composerize-ts:
specifier: ^0.6.2
version: 0.6.2
composeverter:
specifier: ^1.7.2
version: 1.7.2
convert:
specifier: ^5.4.1
version: 5.5.1
+19
View File
@@ -0,0 +1,19 @@
declare module 'composeverter' {
interface Configuration {
expandVolumes?: boolean;
expandPorts?: boolean;
indent?: number;
}
interface DockerComposeValidatioError {
line?: number;
message: string;
helpLink?: string;
}
export function validateDockerComposeToCommonSpec(content: string): DockerComposeValidatioError[];
export function migrateFromV2xToV3x(content: string, configuration?: Configuration = null): string;
export function migrateFromV3xToV2x(content: string, configuration?: Configuration = null): string;
export function migrateFromV1ToV2x(content: string, configuration?: Configuration = null): string;
export function migrateToCommonSpec(content: string, configuration?: Configuration = null): string;
export function migrateFromV2xToV3x(content: string, configuration?: Configuration = null): string;
export function getDockerComposeSchemaWithoutFormats(): object;
}
@@ -0,0 +1,70 @@
<script setup lang="ts">
import {
validateDockerComposeToCommonSpec,
} from 'composeverter';
const dockerCompose = ref(
`version: '3.3'
services:
nginx:
ports:
- '80:80'
volumes:
- '/var/run/docker.sock:/tmp/docker.sock:ro'
restart: always
logging:
options:
max-size: 1g
image: nginx`,
);
const conversionResult = computed(() => {
try {
return validateDockerComposeToCommonSpec(dockerCompose.value);
}
catch (e: any) {
return e.toString().split('\n').map((err: string) => ({ line: -1, message: err, helpLink: '' }));
}
});
const errors = computed(() => conversionResult.value);
const MONACO_EDITOR_OPTIONS = {
automaticLayout: true,
formatOnType: true,
formatOnPaste: true,
};
</script>
<template>
<div>
<c-label label="Paste your Docker Compose file content:">
<div relative w-full>
<c-monaco-editor
v-model:value="dockerCompose"
theme="vs-dark"
language="yaml"
height="250px"
:options="MONACO_EDITOR_OPTIONS"
/>
</div>
</c-label>
<div v-if="errors.length > 0">
<n-alert title="The following errors occured" type="error" mt-5>
<ul>
<li v-for="(message, index) of errors" :key="index">
{{ message.message }} (<n-a v-if="message.helpLink" target="_blank" rel="noreferer noopener">
See Docker Compose help
</n-a>)
</li>
</ul>
</n-alert>
</div>
<div v-else>
<n-alert type="success" mt-5>
Validation successful!
</n-alert>
</div>
</div>
</template>
@@ -0,0 +1,12 @@
import { BrandDocker } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Docker Compose Validator',
path: '/docker-compose-validator',
description: 'Validate Docker Compose files against CommonSpec schema',
keywords: ['docker', 'compose', 'validator', 'commonspec'],
component: () => import('./docker-compose-validator.vue'),
icon: BrandDocker,
createdAt: new Date('2024-01-25'),
});
+2
View File
@@ -108,6 +108,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as csrGenerator } from './csr-generator';
import { tool as dockerRunToKubernetesConverter } from './docker-run-to-kubernetes';
import { tool as dockerComposeValidator } from './docker-compose-validator';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -347,6 +348,7 @@ export const toolsByCategory: ToolCategory[] = [
dockerComposeToDockerRunConverter,
dockerComposeToKubernetesConverter,
dockerRunToKubernetesConverter,
dockerComposeValidator,
xmlFormatter,
xsltTester,
yamlViewer,