File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package tekton
22
33import (
44 "context"
5+ "crypto/sha256"
6+ "encoding/hex"
57 "errors"
68 "fmt"
79
@@ -57,7 +59,22 @@ func getPipelineName(f fn.Function) string {
5759 } else {
5860 source = "git"
5961 }
60- return fmt .Sprintf ("%s-%s-%s-pipeline" , f .Name , f .Build .Builder , source )
62+
63+ // Kubernetes resource names must be <= 63 characters (RFC 1123)
64+ // We use a hash-based approach to guarantee uniqueness while staying under the limit
65+
66+ // Create a unique identifier based on function name, builder, and source
67+ fullIdentifier := fmt .Sprintf ("%s-%s-%s" , f .Name , f .Build .Builder , source )
68+
69+ // Generate hash of the full identifier
70+ hash := sha256 .Sum256 ([]byte (fullIdentifier ))
71+ // Use first 8 characters of hex encoding (4 bytes = 8 hex chars)
72+ shortHash := hex .EncodeToString (hash [:4 ])
73+
74+ // Format: func-{hash}-{builder}-{source}
75+ // This gives us: 4 + 1 + 8 + 1 + 3-4 + 1 + 6-3 = 24-26 chars max
76+ // Well under the 63 char limit with room for future additions
77+ return fmt .Sprintf ("func-%s-%s-%s" , shortHash , f .Build .Builder , source )
6178}
6279
6380func getPipelineRunGenerateName (f fn.Function ) string {
You can’t perform that action at this time.
0 commit comments