Skip to content

Commit 1d5e669

Browse files
committed
libcloud.groovy: buildfetch ostree artifact before creating winli image
The AWS ore wrapper relies on information from image.json. Buildfetch the ostree artifact before creating and replicating the AWS Windows License Included (winli) image to be consistent and use the same values as the original AMI. Also, remove the hack to get around buildfetch'ing the vmdk image since the build artifact is no longer required in the winli build case. See: coreos/coreos-assembler#4315
1 parent 7219a72 commit 1d5e669

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

libcloud.groovy

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def replicate_to_clouds(pipecfg, basearch, buildID, stream) {
99
def builders = [:]
1010
def credentials
1111
def stream_info = pipecfg.streams[stream]
12+
def pipeutils = load("utils.groovy")
1213

1314
credentials = [file(variable: "ALIYUN_IMAGE_UPLOAD_CONFIG",
1415
credentialsId: "aliyun-image-upload-config")]
@@ -52,20 +53,23 @@ def replicate_to_clouds(pipecfg, basearch, buildID, stream) {
5253
// all regions, if the option is set for the current stream. `cosa aws-replicate`
5354
// will handle both traditional AMIs and aws-winli AMIs if present in the metadata.
5455
// aws-winli is only supported on x86_64.
55-
def awsWinLIBuildClosure = { config, aws_image_name, credentialId ->
56+
def awsWinLIBuildClosure = { config, credentialId ->
5657
def creds = [file(variable: "AWS_CONFIG_FILE", credentialsId: credentialId)]
5758
withCredentials(creds) {
5859
utils.syncCredentialsIfInRemoteSession(["AWS_CONFIG_FILE"])
59-
def c = config
60-
61-
// Since we are not uploading anything, let's just touch the vmdk image
62-
// file to satisfy the cosa ore wrapper, which still requires the file
63-
// in the cosa working dir.
64-
def aws_image_path = "builds/${buildID}/${basearch}/${aws_image_name}"
60+
def s3_stream_dir = pipeutils.get_s3_streams_dir(config, stream)
61+
// the AWS ore wrapper relies on information stored in image.json. We need to buildfetch
62+
// the ostree artifact to be consistent and use the same values as the original AMI.
6563
shwrap("""
66-
touch ${aws_image_path}
64+
cosa buildfetch \
65+
--build=${buildID} \
66+
--arch=${basearch} \
67+
--artifact=ostree \
68+
--url=s3://${s3_stream_dir}/builds \
69+
--aws-config-file \${AWS_CONFIG_FILE}
6770
""")
6871

72+
def c = config.clouds.aws
6973
def extraArgs = []
7074
if (c.grant_users) {
7175
extraArgs += c.grant_users.collect{"--grant-user=${it}"}
@@ -101,15 +105,10 @@ def replicate_to_clouds(pipecfg, basearch, buildID, stream) {
101105
if (pipecfg.clouds?.aws &&
102106
utils.credentialsExist(credentials)) {
103107

104-
// grab the aws vmdk image name from the metadata to pass to the winli closure.
105-
// the cosa ore wrapper still requires the image to exist, but we dont upload
106-
// anything so we'll just touch the file in the cosa working dir.
107-
def aws_image_name = meta.images.aws.path
108108
// aws-winli is only supported on x86_64
109109
if ((basearch == "x86_64") && (stream_info.create_and_replicate_winli_ami)) {
110110
builders["☁️ 🔨:aws-winli"] = {
111-
awsWinLIBuildClosure.call(pipecfg.clouds.aws, aws_image_name,
112-
"aws-build-upload-config")
111+
awsWinLIBuildClosure.call(pipecfg, "aws-build-upload-config")
113112
}
114113
}
115114
replicators["☁️ 🔄:aws"] = {

0 commit comments

Comments
 (0)