Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2398 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
Change app generated namespace to be deterministic
  • Loading branch information
ibuildthecloud authored Jan 6, 2024
2 parents 46a667b + 8cc6896 commit 407ca5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/appdefinition/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1"
"github.com/acorn-io/runtime/pkg/condition"
"github.com/acorn-io/runtime/pkg/labels"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
kclient "sigs.k8s.io/controller-runtime/pkg/client"
)
Expand All @@ -21,8 +22,12 @@ func AssignNamespace(req router.Request, resp router.Response) (err error) {
err = nil
}()

parts := strings.Split(appInstance.Name, ".")
appInstance.Status.Namespace = name.SafeConcatName(parts[len(parts)-1], appInstance.ShortID())
if appInstance.Status.Namespace == "" {
parts := strings.Split(appInstance.Name, ".")
slices.Reverse(parts)
parts = append(parts, appInstance.Namespace)
appInstance.Status.Namespace = name.SafeHashConcatName(parts...)
}

resp.Objects(appInstance)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ status:
success: true
type: namespace
defaults: {}
namespace: default-1234567890ab
namespace: default-random-2fcaa72a
resolvedOfferings: {}
staged:
appImage:
Expand Down Expand Up @@ -52,7 +52,7 @@ status:
success: true
type: namespace
defaults: {}
namespace: default-1234567890ab
namespace: default-random-2fcaa72a
resolvedOfferings: {}
staged:
appImage:
Expand Down

0 comments on commit 407ca5d

Please sign in to comment.