Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scheduler (9/): add uniquename utility for preparing binding names #404

Merged
merged 4 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/scheduler/framework/uniquename/uniquename.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func minInt(a, b int) int {
return b
}

// ClusterResourceBindingUniqueName returns a unique name for a cluster resource binding in the
// NewlusterResourceBindingName returns a unique name for a cluster resource binding in the
michaelawyu marked this conversation as resolved.
Show resolved Hide resolved
// format of DNS subdomain names (RFC 1123).
//
// The name is generated using the following format:
Expand All @@ -39,7 +39,7 @@ func minInt(a, b int) int {
//
// In addition, note that this function assumes that both the CRP name and the cluster name
// are valid DNS subdomain names (RFC 1123).
func ClusterResourceBindingUniqueName(CRPName string, clusterName string) (string, error) {
func NewlusterResourceBindingName(CRPName string, clusterName string) (string, error) {
reservedSlots := 2 + uuidLength // 2 dashs + 6 character UUID string

slotsPerSeg := (validation.DNS1123SubdomainMaxLength - reservedSlots) / 2
Expand All @@ -50,6 +50,7 @@ func ClusterResourceBindingUniqueName(CRPName string, clusterName string) (strin
)

if errs := validation.IsDNS1123Subdomain(uniqueName); len(errs) != 0 {
// Do a sanity check here; normally this would not occur.
return "", fmt.Errorf("failed to format a unique RFC 1123 DNS subdomain name with namespace %s, name %s: %v", CRPName, clusterName, errs)
michaelawyu marked this conversation as resolved.
Show resolved Hide resolved
}
return uniqueName, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/framework/uniquename/uniquename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestClusterResourceBindingUniqueName(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
name, err := ClusterResourceBindingUniqueName(tc.crpName, tc.clusterName)
name, err := NewlusterResourceBindingName(tc.crpName, tc.clusterName)

if tc.expectedToFail {
if err == nil {
Expand Down