Normalize Docker image names and paths
While trying to use the package include functionality that we have for the skeletons I noticed an annoying situation; the path for an image is too different when built locally vs
Problem
The idea is that we know what we want, like the NED cisco-ios-cli-6.44
for NSO version 5.3.1
and if we built it locally it should be available under that name, i.e. cisco-ios-cli-6.44:5.3.1
. This is also the case. The idea is then that when that NED is built in CI, we just append the registry path and we can instead fetch the NED from the Docker registry. PKG_PATH is meant to specify that path for all packages, so if it is empty, then we effectively use locally built packages whereas if it is set to something then we'll pull the images down. But it doesn't compose nicely.
Locally the image name is
cisco-ios-cli-6.44:5.3.1
We want to set the PKG_PATH to something like
registry.gitlab.com/nso-developer/
And would thus get:
registry.gitlab.com/intnso/cisco-ios-cli-6.44:5.3.1
But the actual image is currently living at:
registry.gitlab.com/intnso/cisco-ios-cli-6.44/cisco-ios-cli-6.44:5.3.1
In my include file I have now had to use bash expansion tricks, like the following, to get it to work. Non-desirable!
${PKG_PATH}${PKG_PATH+cisco-ios-cli-6.44/}cisco-ios-cli-6.44:${NSO_VERSION}
Potential solution
I think the best way of fixing this is to change the output path of packages that we build. The base should be (for the cisco-ios-cli-6.44 NED):
cisco-ios-cli-6.44/ned:${NSO_VERSION}
And the name for when build by CI is simply lengthened by adding the CI_PROJECT_NAMESPACE, like so:
registry.gitlab.com/intnso/cisco-ios-cli-6.44/ned:5.3.1
I think we need to potentially update how we figure out the name of the NED / project. Right now I thin we actually use NED_NAME, which is based on the name of the NED package (the directory name) and we find that by looking for where package-meta-data.xml is, like in a NID NED repo, in the packages/
directory, we find the package that has a package-meta-data and take the name of its parent directory to derive the name of the NED. The Docker images names however must be based on the Gitlab project name (i.e. entire git repo). Just need to keep this in mind.