Initial project source
这个提交包含在:
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "json"
|
||||
|
||||
project_root = File.realpath(ARGV.fetch(0))
|
||||
config = JSON.parse($stdin.read)
|
||||
errors = []
|
||||
|
||||
errors << "Compose project name is not fixed" unless config["name"] == "aixun-datagov-local"
|
||||
|
||||
services = config.fetch("services", {})
|
||||
platform_services = %w[redis nacos gateway auth system resource integration dataops governance dataproduct frontend]
|
||||
m2_services = %w[
|
||||
m2-source-mysql m2-seatunnel m2-dolphinscheduler
|
||||
m2-hive-mysql m2-hive-minio m2-hive-minio-bootstrap m2-hive-metastore m2-hive
|
||||
m2-doris-fe m2-doris-be
|
||||
]
|
||||
expected_services = services.key?("m2-source-mysql") ? platform_services + m2_services : platform_services
|
||||
errors << "Unexpected service set" unless services.keys.sort == expected_services.sort
|
||||
|
||||
services.each do |name, service|
|
||||
container_name = service["container_name"].to_s
|
||||
labels = service.fetch("labels", {})
|
||||
image = service["image"].to_s
|
||||
|
||||
errors << "#{name}: invalid container name" unless container_name.start_with?("aixun-datagov-")
|
||||
errors << "#{name}: missing project label" unless labels["com.aixun.project"] == "aixun-datagov"
|
||||
|
||||
unless image.start_with?("aixun-datagov/")
|
||||
errors << "#{name}: third-party image is not digest pinned" unless image.include?("@sha256:")
|
||||
end
|
||||
|
||||
errors << "#{name}: latest tag is forbidden" if image.match?(/:latest(?:@|$)/)
|
||||
|
||||
service.fetch("volumes", []).each do |mount|
|
||||
next unless mount["type"] == "bind"
|
||||
|
||||
source = File.expand_path(mount.fetch("source"))
|
||||
errors << "#{name}: bind mount escapes the repository" unless source.start_with?(project_root + File::SEPARATOR)
|
||||
errors << "#{name}: Docker socket mount is forbidden" if mount["target"] == "/var/run/docker.sock"
|
||||
end
|
||||
end
|
||||
|
||||
config.fetch("networks", {}).each do |name, network|
|
||||
errors << "network #{name}: invalid name" unless network["name"].to_s.start_with?("aixun-datagov-local-")
|
||||
errors << "network #{name}: missing project label" unless network.fetch("labels", {})["com.aixun.project"] == "aixun-datagov"
|
||||
end
|
||||
|
||||
config.fetch("volumes", {}).each do |name, volume|
|
||||
errors << "volume #{name}: invalid name" unless volume["name"].to_s.start_with?("aixun-datagov-local-")
|
||||
errors << "volume #{name}: missing project label" unless volume.fetch("labels", {})["com.aixun.project"] == "aixun-datagov"
|
||||
end
|
||||
|
||||
unless errors.empty?
|
||||
warn errors.join("\n")
|
||||
exit 1
|
||||
end
|
||||
在新工单中引用
屏蔽一个用户