MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / convertPostgresIDToK8s

Function convertPostgresIDToK8s

pkg/specs/volumes.go:71–79  ·  view source on GitHub ↗

convertPostgresIDToK8s transforms a postgres identifier to be a valid K8s label. NOTE: this is a reversible transformation, as we swap invalid K8s chars into invalid PG chars

(tablespaceName string)

Source from the content-addressed store, hash-verified

69//
70// NOTE: this is a reversible transformation, as we swap invalid K8s chars into invalid PG chars
71func convertPostgresIDToK8s(tablespaceName string) string {
72 // Postgres identifiers can begin with _ or a letter, K8's must begin
73 // with an alphanumeric. We convert _ to 1 in this edge case
74 if strings.HasPrefix(tablespaceName, "_") {
75 tablespaceName = strings.Replace(tablespaceName, "_", "1", 1)
76 }
77 name := strings.ReplaceAll(tablespaceName, "$", "-")
78 return name
79}
80
81// PvcNameForTablespace returns the normalized tablespace PVC name for a given
82// tablespace, on a cluster pod

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected