forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#1356 from squeed/network-config
types: rename network type to match Network.config.openshift.io.
- Loading branch information
Showing
14 changed files
with
471 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package conversion | ||
|
||
import ( | ||
"github.com/openshift/installer/pkg/ipnet" | ||
"github.com/openshift/installer/pkg/types" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// ConvertInstallConfig is modeled after the k8s conversion schemes, which is | ||
// how deprecated values are upconverted. | ||
// This updates the APIVersion to reflect the fact that we've internally | ||
// upconverted. | ||
func ConvertInstallConfig(config *types.InstallConfig) error { | ||
// check that the version is convertible | ||
switch config.APIVersion { | ||
case types.InstallConfigVersion, "v1beta3": | ||
// works | ||
default: | ||
return errors.Errorf("cannot upconvert from version %s", config.APIVersion) | ||
} | ||
ConvertNetworking(config) | ||
|
||
config.APIVersion = types.InstallConfigVersion | ||
return nil | ||
} | ||
|
||
// ConvertNetworking upconverts deprecated fields in networking | ||
func ConvertNetworking(config *types.InstallConfig) { | ||
if config.Networking == nil { | ||
return | ||
} | ||
|
||
netconf := config.Networking | ||
|
||
if len(netconf.ClusterNetwork) == 0 { | ||
netconf.ClusterNetwork = netconf.DeprecatedClusterNetworks | ||
} | ||
|
||
if len(netconf.ServiceNetwork) == 0 && netconf.DeprecatedServiceCIDR != nil { | ||
netconf.ServiceNetwork = []ipnet.IPNet{*netconf.DeprecatedServiceCIDR} | ||
} | ||
|
||
// Convert type to networkType if the latter is missing | ||
if netconf.NetworkType == "" { | ||
netconf.NetworkType = netconf.DeprecatedType | ||
} | ||
|
||
// Convert hostSubnetLength to hostPrefix | ||
for i, entry := range netconf.ClusterNetwork { | ||
if entry.HostPrefix == 0 && entry.DeprecatedHostSubnetLength != 0 { | ||
_, size := entry.CIDR.Mask.Size() | ||
netconf.ClusterNetwork[i].HostPrefix = int32(size) - entry.DeprecatedHostSubnetLength | ||
} | ||
} | ||
} |
Oops, something went wrong.