Hey @barryjump yes this is possible via API or SDK. Let me try to tell you more details below.
First of all, a delta is unique between any combination of (delta version, source image ID, destination image ID), so you’ll need to determine the appropriate values before querying the API.
If you have the version and the image IDs you can query:
$ curl \
-H "Authorization: Bearer ${TOKEN}" \
'https://api.resin.io/v4/delta?$filter=((status%20eq%20%27success%27)%20and%20(version%20eq%20'${DELTA_VERSION}')%20and%20(originates_from__image%20eq%20'${SRC_ID}')%20and%20(produces__image%20eq%20'${DST_ID}'))'
| jq .d[0]
If you only have the names of the images involved you can use:
curl \
-H "Authorization: Bearer ${TOKEN}" \
'https://api.resin.io/v4/delta?$filter=((status%20eq%20%27success%27)%20and%20(version%20eq%20'${DELTA_VERSION}')%20and%20(originates_from__image/any(source:source/is_stored_at__image_location%20eq%20%27'${SRC_NAME}'%27))%20and%20(produces__image/any(destination:destination/is_stored_at__image_location%20eq%20%27'${DST_NAME}'%27)))'
| jq .d[0]
where SRC_NAME
and DST_NAME
should be the image name complete with the registry without a tag or SHA reference.
To get a list of all the services and the size of the delta updates for each between two release IDs, run the following from the browser console, release IDs can be found easily in the URL of the releases page of the app:
release1 = <OLD_RELEASE_ID>
release2 = <NEW_RELEASE_ID>
sdk.pine.get({
resource: 'release',
options: {
$filter: {
id:{ $in: [ release1, release2 ]},
},
$orderby: 'id asc',
$expand: {
image__is_part_of__release: {
$select: 'id',
$expand: {
image: {
$select: [
'id'
],
$expand: {
is_a_build_of__service: {
$select: 'service_name'
}
}
}
}
}
}
}
}).then(([r1, r2]) => {
r1services = { }
_.each(r1.image__is_part_of__release, (ipr) => {
r1services[ipr.image[0].is_a_build_of__service[0].service_name] = ipr.image[0].id;
})
r2services = { }
_.each(r2.image__is_part_of__release, (ipr) => {
r2services[ipr.image[0].is_a_build_of__service[0].service_name] = ipr.image[0].id;
})
deltaSizes = { }
return Promise.all(_.map(r1services, (id, name) => {
return sdk.pine.get({
resource: 'delta',
options: {
$filter: {
originates_from__image: id,
produces__image: r2services[name]
},
$select: 'size'
}
}).then(([ img ]) => {
if (img != null) {
deltaSizes[name] = img.size
} else {
deltaSizes[name] = 0
}
});
})).then(() => console.log(deltaSizes))
})
Let us know if this works for you!
And of course, I remember that you are asking that you would like to estimate. I just created a pattern inside balena.