mirror of
https://github.com/kairos-io/osbuilder.git
synced 2025-06-21 04:46:46 +00:00
Always produce an importable tar from the image
and name it after the artifact Fixes https://github.com/kairos-io/kairos/issues/514 Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
e6e5cddbfe
commit
ed201a72ef
@ -49,7 +49,8 @@ type OSArtifactSpec struct {
|
|||||||
Bundles []string `json:"bundles,omitempty"`
|
Bundles []string `json:"bundles,omitempty"`
|
||||||
PullOptions Pull `json:"pull,omitempty"`
|
PullOptions Pull `json:"pull,omitempty"`
|
||||||
OSRelease string `json:"osRelease,omitempty"`
|
OSRelease string `json:"osRelease,omitempty"`
|
||||||
PushOptions Push `json:"push,omitempty"`
|
// TODO: Currently not used. Reseved to be used when we have a way to push to registries.
|
||||||
|
PushOptions Push `json:"push,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Push struct {
|
type Push struct {
|
||||||
|
@ -65,7 +65,11 @@ func unpackContainer(id, containerImage, pullImage string, pullOptions buildv1al
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createImageContainer(containerImage string, pushOptions buildv1alpha1.Push) v1.Container {
|
func createImageContainer(containerImage string, artifact buildv1alpha1.OSArtifact) v1.Container {
|
||||||
|
imageName := "dontpush" // No image was defined, use a dummy one to let luet work
|
||||||
|
if artifact.Spec.PushOptions.ImageName != "" {
|
||||||
|
imageName = artifact.Spec.PushOptions.ImageName
|
||||||
|
}
|
||||||
return v1.Container{
|
return v1.Container{
|
||||||
ImagePullPolicy: v1.PullAlways,
|
ImagePullPolicy: v1.PullAlways,
|
||||||
Name: "create-image",
|
Name: "create-image",
|
||||||
@ -73,8 +77,9 @@ func createImageContainer(containerImage string, pushOptions buildv1alpha1.Push)
|
|||||||
Command: []string{"/bin/bash", "-cxe"},
|
Command: []string{"/bin/bash", "-cxe"},
|
||||||
Args: []string{
|
Args: []string{
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"tar -czvpf test.tar -C /rootfs . && luet util pack %s test.tar image.tar && mv image.tar /artifacts",
|
"tar -czvpf test.tar -C /rootfs . && luet util pack %[1]s test.tar %[2]s.tar && chmod +r %[2]s.tar && mv %[2]s.tar /artifacts",
|
||||||
pushOptions.ImageName,
|
imageName,
|
||||||
|
artifact.Name,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
VolumeMounts: []v1.VolumeMount{
|
VolumeMounts: []v1.VolumeMount{
|
||||||
@ -139,8 +144,6 @@ func osReleaseContainer(containerImage string) v1.Container {
|
|||||||
func (r *OSArtifactReconciler) genJob(artifact buildv1alpha1.OSArtifact) *batchv1.Job {
|
func (r *OSArtifactReconciler) genJob(artifact buildv1alpha1.OSArtifact) *batchv1.Job {
|
||||||
objMeta := genObjectMeta(artifact)
|
objMeta := genObjectMeta(artifact)
|
||||||
|
|
||||||
pushImage := artifact.Spec.PushOptions.Push
|
|
||||||
|
|
||||||
privileged := false
|
privileged := false
|
||||||
serviceAccount := true
|
serviceAccount := true
|
||||||
|
|
||||||
@ -326,11 +329,7 @@ func (r *OSArtifactReconciler) genJob(artifact buildv1alpha1.OSArtifact) *batchv
|
|||||||
pod.InitContainers = append(pod.InitContainers, buildGCECloudImageContainer)
|
pod.InitContainers = append(pod.InitContainers, buildGCECloudImageContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Does it make sense to build the image and not push it? Maybe remove
|
pod.InitContainers = append(pod.InitContainers, createImageContainer(r.ToolImage, artifact))
|
||||||
// this flag?
|
|
||||||
if pushImage {
|
|
||||||
pod.InitContainers = append(pod.InitContainers, createImageContainer(r.ToolImage, artifact.Spec.PushOptions))
|
|
||||||
}
|
|
||||||
|
|
||||||
pod.Containers = []v1.Container{
|
pod.Containers = []v1.Container{
|
||||||
createPushToServerImageContainer(r.CopierImage, r.ArtifactPodInfo),
|
createPushToServerImageContainer(r.CopierImage, r.ArtifactPodInfo),
|
||||||
|
Loading…
Reference in New Issue
Block a user