Skip to content

Commit ec2c08a

Browse files
committed
update examples
Signed-off-by: Evgenii Orlov <[email protected]>
1 parent b421dc4 commit ec2c08a

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

transform/ports.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,3 @@ func portDefaults(data any, _ tree.Path, _ bool) (any, error) {
102102
return data, nil
103103
}
104104
}
105-
106-
// EnhancedPortDefaults is an example of an enhanced port defaults function
107-
// that supports additional protocols and domain names in the published field.
108-
// This function can be used as a replacement for the default portDefaults
109-
// by registering it with RegisterDefaultTransformer.
110-
//
111-
// Example usage:
112-
// transform.RegisterDefaultTransformer("services.*.ports.*", transform.EnhancedPortDefaults)
113-
//
114-
// This function supports:
115-
// - Additional protocols: "http", "https", "tcp", "udp"
116-
// - Domain names in the published field (e.g., "example.com:80")
117-
// - All existing functionality of the original portDefaults
118-
func EnhancedPortDefaults(data any, _ tree.Path, _ bool) (any, error) {
119-
switch v := data.(type) {
120-
case map[string]any:
121-
// Set default protocol if not specified
122-
if _, ok := v["protocol"]; !ok {
123-
v["protocol"] = "tcp"
124-
}
125-
// Set default mode if not specified
126-
if _, ok := v["mode"]; !ok {
127-
v["mode"] = "ingress"
128-
}
129-
// Additional logic can be added here to handle domain names
130-
// in the published field or other custom transformations
131-
return v, nil
132-
default:
133-
return data, nil
134-
}
135-
}

0 commit comments

Comments
 (0)