// SetOpenShiftDefaults sets the default settings on the passed // client configuration func SetOpenShiftDefaults(config *kclient.Config) error { if len(config.UserAgent) == 0 { config.UserAgent = DefaultOpenShiftUserAgent() } if config.Version == "" { // Clients default to the preferred code API version // TODO: implement version negotiation (highest version supported by server) config.Version = latest.Version } if config.Prefix == "" { switch config.Version { case "v1beta3": config.Prefix = "/osapi" default: config.Prefix = "/oapi" } } version := config.Version versionInterfaces, err := latest.InterfacesFor(version) if err != nil { return fmt.Errorf("API version '%s' is not recognized (valid values: %s)", version, strings.Join(latest.Versions, ", ")) } if config.Codec == nil { config.Codec = versionInterfaces.Codec } return nil }