From 01378fa144975d95ec7550d6e228d823fa9bc5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Mon, 16 Sep 2024 10:40:22 +0200 Subject: [PATCH] add comments to public methods --- pipeline-runner/internal/jobs/build/acr.go | 1 + .../internal/jobs/build/buildkit.go | 7 +-- .../internal/jobs/build/interface.go | 2 + .../internal/jobs/build/internal/kubejob.go | 2 + .../internal/jobs/build/kubejob.go | 43 ------------------- 5 files changed, 9 insertions(+), 46 deletions(-) delete mode 100644 pipeline-runner/internal/jobs/build/kubejob.go diff --git a/pipeline-runner/internal/jobs/build/acr.go b/pipeline-runner/internal/jobs/build/acr.go index 672863869..fc7db5a06 100644 --- a/pipeline-runner/internal/jobs/build/acr.go +++ b/pipeline-runner/internal/jobs/build/acr.go @@ -27,6 +27,7 @@ const ( acrHomePath = "/home/radix-image-builder" ) +// NewBuildKit returns a JobBuilder implementation for building components and jobs using radix-image-builder (https://github.com/equinor/radix-image-builder) func NewACR() JobsBuilder { return &acr{} } diff --git a/pipeline-runner/internal/jobs/build/buildkit.go b/pipeline-runner/internal/jobs/build/buildkit.go index 4c9061478..b3a0dda26 100644 --- a/pipeline-runner/internal/jobs/build/buildkit.go +++ b/pipeline-runner/internal/jobs/build/buildkit.go @@ -27,9 +27,10 @@ const ( buildKitHomePath = "/home/build" buildKitBuildSecretsPath = "/build-secrets" privateImageHubDockerAuthPath = "/radix-private-image-hubs" - defaultExternalRegistruAuthPath = "/radix-default-external-registry-auth" + defaultExternalRegistryAuthPath = "/radix-default-external-registry-auth" ) +// NewBuildKit returns a JobBuilder implementation for building components and jobs using radix-buildkit-builder (https://github.com/equinor/radix-buildkit-builder) func NewBuildKit() JobsBuilder { return &buildKit{} } @@ -239,7 +240,7 @@ func (c *buildKitKubeJobProps) getPodContainerArgs() []string { // When multiple files contains credentials for the same registry (e.g. docker.io), credentials from the last file is used var authFiles []string if len(c.pipelineArgs.ExternalContainerRegistryDefaultAuthSecret) > 0 { - authFiles = append(authFiles, path.Join(defaultExternalRegistruAuthPath, corev1.DockerConfigJsonKey)) + authFiles = append(authFiles, path.Join(defaultExternalRegistryAuthPath, corev1.DockerConfigJsonKey)) } authFiles = append(authFiles, path.Join(privateImageHubDockerAuthPath, corev1.DockerConfigJsonKey)) for _, authFile := range authFiles { @@ -347,7 +348,7 @@ func (c *buildKitKubeJobProps) getPodContainerVolumeMounts() []corev1.VolumeMoun volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: c.pipelineArgs.ExternalContainerRegistryDefaultAuthSecret, - MountPath: defaultExternalRegistruAuthPath, + MountPath: defaultExternalRegistryAuthPath, ReadOnly: true, }, ) diff --git a/pipeline-runner/internal/jobs/build/interface.go b/pipeline-runner/internal/jobs/build/interface.go index bede1e3ef..f72998153 100644 --- a/pipeline-runner/internal/jobs/build/interface.go +++ b/pipeline-runner/internal/jobs/build/interface.go @@ -6,6 +6,8 @@ import ( batchv1 "k8s.io/api/batch/v1" ) +// JobsBuilder defines interface for creating pipeline build jobs type JobsBuilder interface { + // BuildJobs returns a slice of Kubernetes jobs to be used for building container images for Radix components and jobs BuildJobs(useBuildCache bool, pipelineArgs model.PipelineArguments, cloneURL, gitCommitHash, gitTags string, componentImages []pipeline.BuildComponentImage, buildSecrets []string) []batchv1.Job } diff --git a/pipeline-runner/internal/jobs/build/internal/kubejob.go b/pipeline-runner/internal/jobs/build/internal/kubejob.go index 1b3676ae1..0dad4a2ef 100644 --- a/pipeline-runner/internal/jobs/build/internal/kubejob.go +++ b/pipeline-runner/internal/jobs/build/internal/kubejob.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// KubeJobProps defines properties to be used with the BuildKubeJob function. type KubeJobProps interface { JobName() string JobLabels() map[string]string @@ -21,6 +22,7 @@ type KubeJobProps interface { PodContainers() []corev1.Container } +// BuildKubeJob builds a Kubernetes job with properties defined by source argument func BuildKubeJob(props KubeJobProps) batchv1.Job { return batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pipeline-runner/internal/jobs/build/kubejob.go b/pipeline-runner/internal/jobs/build/kubejob.go deleted file mode 100644 index 5cf010408..000000000 --- a/pipeline-runner/internal/jobs/build/kubejob.go +++ /dev/null @@ -1,43 +0,0 @@ -package build - -// type kubeJobProps interface { -// JobName() string -// JobLabels() map[string]string -// JobAnnotations() map[string]string -// PodLabels() map[string]string -// PodAnnotations() map[string]string -// PodTolerations() []corev1.Toleration -// PodAffinity() *corev1.Affinity -// PodSecurityContext() *corev1.PodSecurityContext -// PodVolumes() []corev1.Volume -// PodInitContainers() []corev1.Container -// PodContainers() []corev1.Container -// } - -// func buildKubeJob(props kubeJobProps) batchv1.Job { -// return batchv1.Job{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: props.JobName(), -// Labels: props.JobLabels(), -// Annotations: props.JobAnnotations(), -// }, -// Spec: batchv1.JobSpec{ -// BackoffLimit: pointers.Ptr[int32](0), -// Template: corev1.PodTemplateSpec{ -// ObjectMeta: metav1.ObjectMeta{ -// Labels: props.PodLabels(), -// Annotations: props.PodAnnotations(), -// }, -// Spec: corev1.PodSpec{ -// RestartPolicy: corev1.RestartPolicyNever, -// Affinity: props.PodAffinity(), -// Tolerations: props.PodTolerations(), -// SecurityContext: props.PodSecurityContext(), -// Volumes: props.PodVolumes(), -// InitContainers: props.PodInitContainers(), -// Containers: props.PodContainers(), -// }, -// }, -// }, -// } -// }