github.com/openshift/installer@v1.4.17/pkg/types/agent/conversion/agentconfig.go (about) 1 package conversion 2 3 import ( 4 "fmt" 5 6 "k8s.io/apimachinery/pkg/util/validation/field" 7 8 "github.com/openshift/installer/pkg/types/agent" 9 ) 10 11 // ConvertAgentConfig is modeled after the k8s conversion schemes, which is 12 // how deprecated values are upconverted. 13 // This updates the APIVersion to reflect the fact that we've internally 14 // upconverted. 15 func ConvertAgentConfig(config *agent.Config) error { 16 // check that the version is convertible 17 switch config.APIVersion { 18 case agent.AgentConfigVersion, "v1alpha1": 19 // works 20 case "": 21 return field.Required(field.NewPath("apiVersion"), "no version was provided") 22 default: 23 return field.Invalid(field.NewPath("apiVersion"), config.APIVersion, fmt.Sprintf("cannot upconvert from version %s", config.APIVersion)) 24 } 25 26 config.APIVersion = agent.AgentConfigVersion 27 return nil 28 }