when creating source or target returns a 409, don't return an error. Post should be replaced by Put but not working

This commit is contained in:
pb
2025-04-10 14:22:37 +02:00
parent 2cf8923d95
commit cca59faeab
2 changed files with 11 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ import (
jwt "github.com/golang-jwt/jwt/v5"
"gopkg.in/yaml.v2"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
)
type KubeInfo struct {
@@ -141,6 +142,12 @@ func (c *AdmiraltyController) CreateSource() {
res, err := serv.CreateAdmiraltySource(c.Ctx.Request.Context(),execution)
if err != nil {
if apierrors.IsAlreadyExists(err) {
c.Ctx.Output.SetStatus(409)
c.Data["json"] = map[string]string{"info" : "A source already exists for this namespace : " + execution}
c.ServeJSON()
return
}
// change code to 500
c.Ctx.Output.SetStatus(500)
c.Data["json"] = map[string]string{"error": err.Error()}