mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 02:20:53 +00:00
refactor network name in kyaml container
This commit is contained in:
@@ -33,6 +33,26 @@ const (
|
||||
UserNobody ContainerUser = "nobody"
|
||||
)
|
||||
|
||||
// ContainerNetworkName is a type for network name used in container
|
||||
type ContainerNetworkName string
|
||||
|
||||
func (n *ContainerNetworkName) String() string {
|
||||
return string(*n)
|
||||
}
|
||||
|
||||
func (n *ContainerNetworkName) IsEmpty() bool {
|
||||
return string(*n) == ""
|
||||
}
|
||||
|
||||
func (n *ContainerNetworkName) Set(s string) {
|
||||
*n = ContainerNetworkName(s)
|
||||
}
|
||||
|
||||
const (
|
||||
NetworkNameNone ContainerNetworkName = "none"
|
||||
NetworkNameEmpty ContainerNetworkName = ""
|
||||
)
|
||||
|
||||
// FunctionSpec defines a spec for running a function
|
||||
type FunctionSpec struct {
|
||||
DeferFailure bool `json:"deferFailure,omitempty" yaml:"deferFailure,omitempty"`
|
||||
@@ -75,7 +95,7 @@ type ContainerNetwork struct {
|
||||
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
|
||||
|
||||
// Name is the name of the network to use from a container
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Name ContainerNetworkName `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
}
|
||||
|
||||
// StarlarkSpec defines how to run a function as a starlark program
|
||||
@@ -128,7 +148,7 @@ func GetFunctionSpec(n *yaml.RNode) *FunctionSpec {
|
||||
}
|
||||
|
||||
if fn := getFunctionSpecFromAnnotation(n, meta); fn != nil {
|
||||
fn.Container.Network.Name = ""
|
||||
fn.Container.Network.Name = NetworkNameEmpty
|
||||
fn.StorageMounts = []StorageMount{}
|
||||
return fn
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user