Skip to content

Commit

Permalink
feat: improve stuck server (#22)
Browse files Browse the repository at this point in the history
* feat: don't look process with server's error handling

* feat: improve regex to check label name

* feat: bump version

* fix: mananger better error about destination rule

* chore: edit version edition
  • Loading branch information
Tchoupinax authored Sep 24, 2024
1 parent 0284613 commit 6ec1ccb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
15 changes: 8 additions & 7 deletions steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,15 @@ func AddLabelToIstioDestinatonRulesSelector(
utils.LogInfo("9. Add the label as a selector in istio destination rules...")
currentDestinationRule, err := istioClient.NetworkingV1alpha3().DestinationRules(namespace).Get(context.TODO(), applicationName, v1.GetOptions{})

if strings.HasSuffix(err.Error(), "not found") {
utils.LogSuccess("9. Not Istio rules configured")
utils.LogInfo("============================================================")
if err != nil {
if strings.HasSuffix(err.Error(), "not found") {
utils.LogSuccess("9. Not Istio rules configured")
utils.LogInfo("============================================================")
} else {
fmt.Println(err)
utils.Check(err)
}
} else {
fmt.Println(currentDestinationRule)
fmt.Println(err)
utils.Check(err)

var futureDestinationRule = currentDestinationRule
if removeLabel {
// Update the value of the label
Expand Down
10 changes: 4 additions & 6 deletions summary/webapp/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ func StartWebServer(
err := utils.OpenURL("http://localhost:8080")
utils.Check(err)

httpServerError := make(chan error, 1)
go func() {
httpServerError <- http.ListenAndServe(":8080", nil)
httpServerError := http.ListenAndServe(":8080", nil)
if err := httpServerError; err != nil {
fmt.Println(err)
}
}()

if err := <-httpServerError; err != nil {
fmt.Println(err)
}
}
4 changes: 2 additions & 2 deletions utils/check-arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

func CheckLabelKey(key string) error {
r, _ := regexp.Compile("^[a-z]{1}[a-z./]*[a-z]{1}$")
r, _ := regexp.Compile("^[a-z]{1}[a-z./-]*[a-z]{1}$")
if r.MatchString(key) {
return nil
} else {
return fmt.Errorf("The label key does not respect this regex: ^[a-z]{1}[a-z./]*[a-z]{1}$")
return fmt.Errorf("The label key does not respect this regex: ^[a-z]{1}[a-z./-]*[a-z]{1}$")
}
}

Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/fatih/color"
)

const Version string = "0.1.4"
const BuildDate string = "2024-08-12"
const Version string = "0.1.5"
const BuildDate string = "2024-09-24"

func cliCommandDisplayHelp(args []string) {
displayVersion := utils.StringInSlice("-v", args[1:]) || utils.StringInSlice("--version", args[1:])
Expand Down

0 comments on commit 6ec1ccb

Please sign in to comment.