aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/namegenerator/namegenerator.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/k8splugin/internal/namegenerator/namegenerator.go')
-rw-r--r--src/k8splugin/internal/namegenerator/namegenerator.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/k8splugin/internal/namegenerator/namegenerator.go b/src/k8splugin/internal/namegenerator/namegenerator.go
index 52eef366..0a49633a 100644
--- a/src/k8splugin/internal/namegenerator/namegenerator.go
+++ b/src/k8splugin/internal/namegenerator/namegenerator.go
@@ -141,8 +141,28 @@ func (c *cache) generateName() string {
}
}
+func (c *cache) releaseName(name string) {
+ c.mux.Lock()
+ defer c.mux.Unlock()
+
+ c.init()
+
+ if c.isAlreadyUsed(name) {
+ c.cache[name] = false
+
+ // Update the cache and db
+ c.writeCacheToDB()
+ }
+}
+
// Generate returns an autogenerated name
func Generate() string {
return nameCache.generateName()
}
+
+// Release name from cache
+func Release(name string) {
+
+ nameCache.releaseName(name)
+}