ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
4 changed files with 145336 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namePrefix: mirrored-image-
|
||||
resources:
|
||||
- ../../../../project-delivery/k8s/workflows/go-oci/base
|
||||
- project.yaml
|
||||
configMapGenerator:
|
||||
- name: project
|
||||
namespace: project-delivery
|
||||
files:
|
||||
- projects.fsx=projects.fsx
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
labels:
|
||||
app.kubernetes.io/name: project-delivery
|
||||
app.kubernetes.io/instance: mirrored-image
|
||||
patches:
|
||||
- path: workflow-patch.yaml
|
||||
target:
|
||||
group: argoproj.io
|
||||
version: v1alpha1
|
||||
kind: WorkflowTemplate
|
||||
name: build
|
||||
replacements:
|
||||
- source:
|
||||
group: argoproj.io
|
||||
version: v1alpha1
|
||||
kind: WorkflowTemplate
|
||||
name: mirrored-image-build
|
||||
fieldPath: metadata.name
|
||||
targets:
|
||||
- select:
|
||||
group: delivery.quorate.dev
|
||||
version: v1alpha1
|
||||
kind: ProjectDelivery
|
||||
name: mirrored-image-delivery
|
||||
fieldPaths:
|
||||
- spec.workflowTemplateRef.name
|
||||
18
services/mirrored-image/k8s/delivery/controller/project.yaml
Normal file
18
services/mirrored-image/k8s/delivery/controller/project.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: delivery.quorate.dev/v1alpha1
|
||||
kind: ProjectDelivery
|
||||
metadata:
|
||||
name: delivery
|
||||
namespace: project-delivery
|
||||
spec:
|
||||
source:
|
||||
repository: https://forge.quorate.internal/quorate/cluster
|
||||
continuous:
|
||||
ref: refs/heads/master
|
||||
paths:
|
||||
- services/mirrored-image/controller
|
||||
- services/mirrored-image/k8s/delivery
|
||||
targets:
|
||||
- kind: QuayOCI
|
||||
repository: quorate/mirrored-image-controller
|
||||
workflowTemplateRef:
|
||||
name: build
|
||||
73
services/mirrored-image/k8s/delivery/controller/projects.fsx
Normal file
73
services/mirrored-image/k8s/delivery/controller/projects.fsx
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#load "contract.fsx"
|
||||
|
||||
open System.IO
|
||||
open Contract
|
||||
|
||||
type Binary =
|
||||
{ Module: string
|
||||
Package: string
|
||||
Destination: string }
|
||||
|
||||
type Project =
|
||||
{ Name: string
|
||||
Workflow: string
|
||||
Repository: string
|
||||
Modules: string list
|
||||
Binaries: Binary list
|
||||
FileCaps: Map<string, FileCap list>
|
||||
Entrypoint: string list
|
||||
WorkingDir: string }
|
||||
|
||||
type ToolchainProfile =
|
||||
{ Name: string
|
||||
Packages: string list
|
||||
TestApplets: string list
|
||||
CachePaths: string list }
|
||||
|
||||
let projects =
|
||||
[ { Name = "mirrored-image"
|
||||
Workflow = "mirrored-image-build"
|
||||
Repository = "quorate/mirrored-image-controller"
|
||||
Modules = [ "services/mirrored-image/controller" ]
|
||||
Binaries =
|
||||
[ { Module = "services/mirrored-image/controller"
|
||||
Package = "."
|
||||
Destination = "mirrored-image" } ]
|
||||
FileCaps = Map.empty
|
||||
Entrypoint = [ "/mirrored-image" ]
|
||||
WorkingDir = "/" } ]
|
||||
|
||||
let selectProject (targets: Target array) =
|
||||
require (targets.Length = 1 && targets[0].Kind = "QuayOCI") "invalid delivery target"
|
||||
|
||||
projects
|
||||
|> List.tryFind (fun project -> project.Repository = targets[0].Repository)
|
||||
|> Option.defaultWith (fun () -> fail "unsupported delivery target")
|
||||
|
||||
let moduleRoot sourceRoot (path: string) = Path.Combine(sourceRoot, path)
|
||||
|
||||
let validateProject sourceRoot project =
|
||||
project.Modules
|
||||
|> List.iter (fun path ->
|
||||
let root = moduleRoot sourceRoot path
|
||||
require (Directory.Exists root) $"missing module: {path}"
|
||||
require (File.Exists(Path.Combine(root, "go.mod"))) $"missing go.mod: {path}")
|
||||
|
||||
let inputPaths sourceRoot project =
|
||||
project.Modules
|
||||
|> List.collect (fun path ->
|
||||
[ Path.Combine(path, "go.mod"); Path.Combine(path, "go.sum") ]
|
||||
|> List.filter (fun item -> File.Exists(Path.Combine(sourceRoot, item))))
|
||||
|> List.distinct
|
||||
|
||||
let toolchainProfile =
|
||||
{ Name = "pure-go"
|
||||
Packages = []
|
||||
TestApplets = []
|
||||
CachePaths = [] }
|
||||
|
||||
let toolchainProfileName = toolchainProfile.Name
|
||||
let runtimeAssets (_: Project) : (string * string * string) list = []
|
||||
|
||||
let toolchainCachePaths (_: Project) =
|
||||
[ "usr/lib/go"; "image-base"; "modules"; "gopath" ]
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
- op: replace
|
||||
path: /spec/templates/1/volumes/0
|
||||
value: &orchestration
|
||||
name: orchestration
|
||||
projected:
|
||||
defaultMode: 0444
|
||||
sources:
|
||||
- configMap:
|
||||
name: go-oci-orch
|
||||
- configMap:
|
||||
name: mirrored-image-project
|
||||
items:
|
||||
- {key: projects.fsx, path: projects.fsx}
|
||||
- op: replace
|
||||
path: /spec/templates/3/volumes/0
|
||||
value: *orchestration
|
||||
- op: replace
|
||||
path: /spec/templates/4/volumes/0
|
||||
value: *orchestration
|
||||
- op: replace
|
||||
path: /spec/templates/5/volumes/0
|
||||
value: *orchestration
|
||||
- op: replace
|
||||
path: /spec/templates/6/volumes/0
|
||||
value: *orchestration
|
||||
- op: replace
|
||||
path: /spec/templates/7/volumes/0
|
||||
value: *orchestration
|
||||
- op: replace
|
||||
path: /spec/templates/8/volumes/0
|
||||
value: *orchestration
|
||||
Loading…
Reference in a new issue