Compare commits

..

5 Commits

Author SHA1 Message Date
Unbound Release 7c850018ca chore(release): prepare for 1.2.1 2025-10-01 10:50:19 +02:00
argoyle 3623ede85d refactor: simplify namespace exclusion logic
Replace the manual loop for checking excluded namespaces with 
the built-in slices.Contains function. This change enhances 
the readability and efficiency of the code, while also 
allowing for wildcard matching in exclusion.
2025-10-01 10:38:25 +02:00
argoyle a7ce0a5b5d docs(deploy): add delete permission for limitranges resource
Adds the delete verb for limitranges in the deploy.yaml file. This
change allows for the deletion of the specific resource named
"extreme-request-defaults," enabling better resource management
and cleanup in the deployment process.
2025-10-01 10:33:02 +02:00
Unbound Release 6b70891bb0 chore(release): prepare for 1.2.0 2025-10-01 10:24:35 +02:00
argoyle 4452c7e136 feat: improve LimitRange management in namespaces
Add logging for LimitRange checks, enhance error handling for 
listing LimitRanges, and streamline the creation and deletion 
of the 'extreme-request-defaults' LimitRange based on namespace 
exclusion. This improves reliability and visibility during 
namespace management.
2025-10-01 10:06:57 +02:00
4 changed files with 42 additions and 17 deletions
+1
View File
@@ -0,0 +1 @@
{"version":"1.2.1"}
+16
View File
@@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [1.2.1] - 2025-10-01
### 🚜 Refactor
- Simplify namespace exclusion logic
### 📚 Documentation
- *(deploy)* Add delete permission for limitranges resource
## [1.2.0] - 2025-10-01
### 🚀 Features
- Improve LimitRange management in namespaces
## [1.1.14] - 2025-09-10 ## [1.1.14] - 2025-09-10
### 🐛 Bug Fixes ### 🐛 Bug Fixes
+4
View File
@@ -17,6 +17,10 @@ rules:
- apiGroups: [""] - apiGroups: [""]
resources: ["limitranges"] resources: ["limitranges"]
verbs: ["list","create"] verbs: ["list","create"]
- apiGroups: [""]
resources: ["limitranges"]
verbs: ["delete"]
resourceNames: ["extreme-request-defaults"]
--- ---
+14 -10
View File
@@ -4,6 +4,7 @@ import (
"context" "context"
"flag" "flag"
"log" "log"
"slices"
"strings" "strings"
"time" "time"
@@ -61,11 +62,13 @@ func main() {
} }
for _, ns := range namespaces.Items { for _, ns := range namespaces.Items {
if !nsExcluded(ns.Name, excludedNS) {
log.Printf("Checking for LimitRange named extreme-request-defaults in namespace '%v'\n", ns.Name) log.Printf("Checking for LimitRange named extreme-request-defaults in namespace '%v'\n", ns.Name)
if limitRanges, err := clientset.CoreV1().LimitRanges(ns.Name).List(ctx, metav1.ListOptions{FieldSelector: "metadata.name=extreme-request-defaults"}); err != nil { limitRanges, err := clientset.CoreV1().LimitRanges(ns.Name).List(ctx, metav1.ListOptions{FieldSelector: "metadata.name=extreme-request-defaults"})
panic(err) if err != nil {
} else { log.Printf("Unable to list LimitRanges in namespace '%v': Error: %v\n", ns.Name, err)
continue
}
if !nsExcluded(ns.Name, excludedNS) {
if len(limitRanges.Items) == 0 { if len(limitRanges.Items) == 0 {
log.Printf("Trying to create LimitRange\n") log.Printf("Trying to create LimitRange\n")
if _, err := clientset.CoreV1().LimitRanges(ns.Name).Create(ctx, &limitRange, metav1.CreateOptions{}); err != nil { if _, err := clientset.CoreV1().LimitRanges(ns.Name).Create(ctx, &limitRange, metav1.CreateOptions{}); err != nil {
@@ -74,6 +77,12 @@ func main() {
log.Printf("LimitRange extreme-request-defaults created in namespace '%v'\n", ns.Name) log.Printf("LimitRange extreme-request-defaults created in namespace '%v'\n", ns.Name)
} }
} }
} else {
if len(limitRanges.Items) > 0 {
log.Printf("Trying to delete LimitRange\n")
if err := clientset.CoreV1().LimitRanges(ns.Name).Delete(ctx, "extreme-request-defaults", metav1.DeleteOptions{}); err != nil {
log.Printf("Unable to delete LimitRange in namespace '%v': Error: %v\n", ns.Name, err)
}
} }
} }
} }
@@ -83,12 +92,7 @@ func main() {
} }
func nsExcluded(name string, excludedNS []string) bool { func nsExcluded(name string, excludedNS []string) bool {
for _, ns := range excludedNS { return slices.Contains(excludedNS, name) || slices.Contains(excludedNS, "*")
if name == ns {
return true
}
}
return false
} }
func parseArgs() args { func parseArgs() args {