balena-io-modules / balena-preload

Script for preloading containers onto balena device images
https://www.balena.io/
Apache License 2.0
35 stars 8 forks source link

Fix supervisor repository regex #246

Closed alexgg closed 3 years ago

alexgg commented 3 years ago

Update the supervisor repository regex so the supervisor version can be correctly extracted from the images.

Change-type: patch Signed-off-by: Alex Gonzalez alexg@balena.io

alexgg commented 3 years ago

Quick validation script:

#!/usr/bin/python3

import re
import sys

SUPERVISOR_REPOSITORY_RE = "^((balena|resin|balenaplayground)/)?(armel|rpi|armv7hf|aarch64|i386|amd64|i386-nlp)-supervisor$"

matches = [
    ("resin/amd64-supervisor", 1),
    ("balena/amd64-supervisor", 1),
    ("balenaplayground/amd64-supervisor", 1),
    ("amd64-supervisor", 1),
    ("balenaamd64-supervisor", 0),
    ("balena//amd64-supervisor", 0),
    ("balena/amd64-supervisor-", 0),
    ("balena/amd64--supervisor", 0),
    ("amd64--supervisor", 0),
    (" amd64-supervisor", 0),
    ("amd64-supervisor ", 0),
    ("amd64 supervisor", 0),
    ("aarch64-supervisor", 1),
    (" balena/amd64-supervisor ", 0),
    ("/amd64-supervisor", 0)
]

for t in matches:
    if t[1] == 1 and re.match(SUPERVISOR_REPOSITORY_RE, t[0]):
        continue
    elif t[1] == 0 and re.match(SUPERVISOR_REPOSITORY_RE, t[0]) is None:
        continue
    else:
        print("Failed on %s match" % (t[0]))
        sys.exit(1)
alexgg commented 3 years ago

@balena-ci rebase