Skip to content

Commit

Permalink
Introduce DefaultPodNetworkName constant
Browse files Browse the repository at this point in the history
Existing DefaultNetworkName will be deprecated in favour of this new
constant. We plan to support both `pod-network` and `default` values
until we come up with a migration plan.

Importing libraries/files should use the new `IsDefaultNetwork` which
will return true if network is default instead of directly comparing the
constants.
  • Loading branch information
shouri007 committed Jan 26, 2023
1 parent bb1acae commit 5a53707
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crd/apis/network/v1/network.go
Expand Up @@ -6,7 +6,14 @@ package v1
// the same as the default. Use before comparisons of networks.
func DefaultNetworkIfEmpty(s string) string {
if s == "" {
return DefaultNetworkName
return DefaultPodNetworkName
}
return s
}

// IsDefaultNetwork takes a network name and returns if it is a default network.
// Both DefaultNetworkName and DefaultPodNetworkName are considered as default network for compatibility purposes.
// DefaultNetworkName will eventually be removed.
func IsDefaultNetwork(networkName string) bool {
return networkName == DefaultNetworkName || networkName == DefaultPodNetworkName
}
3 changes: 3 additions & 0 deletions crd/apis/network/v1/network_types.go
Expand Up @@ -5,6 +5,9 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
const (
// DefaultNetworkName is the network used by the VETH interface.
DefaultNetworkName = "pod-network"
// DefaultPodNetworkName is the network used by the VETH interface.
// This is same as DefaultNetworkName except for a different name. DefaultNetworkName will be eventually deprecated.
DefaultPodNetworkName = "default"
// NetworkResourceKeyPrefix is the prefix for extended resource
// name corresponding to the network.
// e.g. "networking.gke.io.networks/my-network.IP"
Expand Down

0 comments on commit 5a53707

Please sign in to comment.