Merge pull request #3256 from zheng1/network.topology

Add network.topology into conf.ToMap()
This commit is contained in:
KubeSphere CI Bot
2021-01-11 10:03:35 +08:00
committed by GitHub
2 changed files with 17 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ func (conf *Config) ToMap() map[string]bool {
if name == "network" {
ippoolName := "network.ippool"
nsnpName := "network"
networkTopologyName := "network.topology"
if conf.NetworkOptions == nil {
result[nsnpName] = false
result[ippoolName] = false
@@ -185,6 +186,12 @@ func (conf *Config) ToMap() map[string]bool {
} else {
result[ippoolName] = true
}
if conf.NetworkOptions.WeaveScopeHost == "" {
result[networkTopologyName] = false
} else {
result[networkTopologyName] = true
}
}
continue
}
@@ -226,7 +233,7 @@ func (conf *Config) stripEmptyOptions() {
conf.OpenPitrixOptions = nil
}
if conf.NetworkOptions != nil && conf.NetworkOptions.EnableNetworkPolicy == false {
if conf.NetworkOptions != nil && conf.NetworkOptions.IsEmpty() {
conf.NetworkOptions = nil
}

View File

@@ -18,6 +18,8 @@ package network
import (
"github.com/spf13/pflag"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/apis/network/v1alpha1"
)
type NSNPOptions struct {
@@ -35,7 +37,7 @@ type Options struct {
func NewNetworkOptions() *Options {
return &Options{
EnableNetworkPolicy: false,
IPPoolType: "none",
IPPoolType: networkv1alpha1.IPPoolTypeNone,
NSNPOptions: NSNPOptions{
AllowedIngressNamespaces: []string{},
},
@@ -43,6 +45,12 @@ func NewNetworkOptions() *Options {
}
}
func (s *Options) IsEmpty() bool {
return s.EnableNetworkPolicy == false &&
s.WeaveScopeHost == "" &&
s.IPPoolType == networkv1alpha1.IPPoolTypeNone
}
func (s *Options) Validate() []error {
var errors []error
return errors