Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OC command to remove multiple old tag(s) from an Image Stream?

I know oc tag -d python:3.5 will remove only 3.5 tag.However I would like to remove multiple old tags from the same Image Stream using oc command.

For instance image streams phython:rel-1, phython:rel-2, phython:rel-3. I am trying like oc tag -d python:rel-*. But I end up with below error message.

*Error from server (NotFound): imagestreamtags.image.openshift.io "rel-*" not found*

I am wondering is there any way to apply wildcards for tags to remove multiple old tags in one go?

like image 334
srk Avatar asked Apr 13 '18 13:04

srk


1 Answers

Not fully tested, and you can't do it in one command invocation, but you can use a shell script something like:

#!/bin/bash

TAGS=`oc get is python --template='{{range .spec.tags}}{{" "}}{{.name}}{{end}}{{"\n"}}'`

for tag in $TAGS; do
    if [[ "$tag" = rel-* ]]; then
        oc tag python:$tag -d
    fi
done
like image 95
Graham Dumpleton Avatar answered Oct 03 '22 01:10

Graham Dumpleton