github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/apis/management.cattle.io/v3/schema/schema.go (about) 1 package schema 2 3 import ( 4 "net/http" 5 6 "github.com/rancher/norman/types" 7 m "github.com/rancher/norman/types/mapper" 8 v3 "github.com/rancher/types/apis/management.cattle.io/v3" 9 "github.com/rancher/types/factory" 10 "github.com/rancher/types/mapper" 11 v1 "k8s.io/api/core/v1" 12 apiserverconfig "k8s.io/apiserver/pkg/apis/config" 13 ) 14 15 var ( 16 Version = types.APIVersion{ 17 Version: "v3", 18 Group: "management.cattle.io", 19 Path: "/v3", 20 } 21 22 Schemas = factory.Schemas(&Version). 23 Init(nativeNodeTypes). 24 Init(nodeTypes). 25 Init(authzTypes). 26 Init(clusterTypes). 27 Init(catalogTypes). 28 Init(authnTypes). 29 Init(tokens). 30 Init(schemaTypes). 31 Init(userTypes). 32 Init(projectNetworkPolicyTypes). 33 Init(logTypes). 34 Init(globalTypes). 35 Init(rkeTypes). 36 Init(alertTypes). 37 Init(composeType). 38 Init(projectCatalogTypes). 39 Init(clusterCatalogTypes). 40 Init(multiClusterAppTypes). 41 Init(globalDNSTypes). 42 Init(kontainerTypes). 43 Init(etcdBackupTypes). 44 Init(clusterScanTypes). 45 Init(monitorTypes). 46 Init(credTypes). 47 Init(mgmtSecretTypes). 48 Init(clusterTemplateTypes). 49 Init(driverMetadataTypes). 50 Init(driverMetadataCisTypes). 51 Init(encryptionTypes) 52 53 TokenSchemas = factory.Schemas(&Version). 54 Init(tokens) 55 ) 56 57 func rkeTypes(schemas *types.Schemas) *types.Schemas { 58 return schemas.AddMapperForType(&Version, v3.BaseService{}, m.Drop{Field: "image"}). 59 AddMapperForType(&Version, v1.Taint{}, 60 m.Enum{Field: "effect", Options: []string{ 61 string(v1.TaintEffectNoSchedule), 62 string(v1.TaintEffectPreferNoSchedule), 63 string(v1.TaintEffectNoExecute), 64 }}, 65 m.Required{Fields: []string{ 66 "effect", 67 "value", 68 "key", 69 }}, 70 m.ReadOnly{Field: "timeAdded"}, 71 ). 72 MustImport(&Version, v3.ExtraEnv{}). 73 MustImport(&Version, v3.ExtraVolume{}). 74 MustImport(&Version, v3.ExtraVolumeMount{}). 75 MustImport(&Version, v3.LinearAutoscalerParams{}). 76 MustImport(&Version, v3.DeploymentStrategy{}). 77 MustImport(&Version, v3.DaemonSetUpdateStrategy{}) 78 } 79 80 func schemaTypes(schemas *types.Schemas) *types.Schemas { 81 return schemas. 82 MustImport(&Version, v3.DynamicSchema{}) 83 } 84 85 func credTypes(schemas *types.Schemas) *types.Schemas { 86 return schemas. 87 AddMapperForType(&Version, v3.CloudCredential{}, 88 &m.DisplayName{}, 89 &mapper.CredentialMapper{}, 90 &m.AnnotationField{Field: "name"}, 91 &m.Drop{Field: "namespaceId"}). 92 MustImport(&Version, v3.CloudCredential{}) 93 } 94 95 func mgmtSecretTypes(schemas *types.Schemas) *types.Schemas { 96 return schemas.MustImportAndCustomize(&Version, v1.Secret{}, func(schema *types.Schema) { 97 schema.ID = "managementSecret" 98 schema.PluralName = "managementSecrets" 99 schema.CodeName = "ManagementSecret" 100 schema.CodeNamePlural = "ManagementSecrets" 101 schema.MustCustomizeField("name", func(field types.Field) types.Field { 102 field.Type = "hostname" 103 field.Nullable = false 104 field.Required = true 105 return field 106 }) 107 }) 108 } 109 110 func driverMetadataTypes(schemas *types.Schemas) *types.Schemas { 111 return schemas. 112 AddMapperForType(&Version, v3.RKEK8sSystemImage{}, m.Drop{Field: "namespaceId"}). 113 AddMapperForType(&Version, v3.RKEK8sServiceOption{}, m.Drop{Field: "namespaceId"}). 114 AddMapperForType(&Version, v3.RKEAddon{}, m.Drop{Field: "namespaceId"}). 115 MustImport(&Version, v3.RKEK8sSystemImage{}). 116 MustImport(&Version, v3.RKEK8sServiceOption{}). 117 MustImport(&Version, v3.RKEAddon{}) 118 } 119 120 func driverMetadataCisTypes(schemas *types.Schemas) *types.Schemas { 121 return schemas. 122 AddMapperForType(&Version, v3.CisConfig{}, m.Drop{Field: "namespaceId"}). 123 AddMapperForType(&Version, v3.CisBenchmarkVersion{}, m.Drop{Field: "namespaceId"}). 124 MustImport(&Version, v3.CisConfig{}). 125 MustImport(&Version, v3.CisBenchmarkVersion{}) 126 } 127 128 func catalogTypes(schemas *types.Schemas) *types.Schemas { 129 return schemas. 130 AddMapperForType(&Version, v3.Catalog{}, 131 &m.Move{From: "catalogKind", To: "kind"}, 132 &m.Embed{Field: "status"}, 133 &m.Drop{Field: "helmVersionCommits"}, 134 ). 135 MustImport(&Version, v3.CatalogRefresh{}). 136 MustImportAndCustomize(&Version, v3.Catalog{}, func(schema *types.Schema) { 137 schema.ResourceActions = map[string]types.Action{ 138 "refresh": {Output: "catalogRefresh"}, 139 } 140 schema.CollectionActions = map[string]types.Action{ 141 "refresh": {Output: "catalogRefresh"}, 142 } 143 }). 144 AddMapperForType(&Version, v3.Template{}, 145 m.DisplayName{}, 146 ). 147 MustImport(&Version, v3.Template{}, struct { 148 VersionLinks map[string]string 149 }{}). 150 AddMapperForType(&Version, v3.CatalogTemplate{}, 151 m.DisplayName{}, 152 m.Drop{Field: "namespaceId"}, 153 ). 154 MustImport(&Version, v3.CatalogTemplate{}, struct { 155 VersionLinks map[string]string 156 }{}). 157 AddMapperForType(&Version, v3.CatalogTemplateVersion{}, 158 m.Drop{Field: "namespaceId"}, 159 ). 160 MustImport(&Version, v3.CatalogTemplateVersion{}). 161 MustImport(&Version, v3.TemplateVersion{}). 162 MustImport(&Version, v3.TemplateContent{}) 163 } 164 165 func nativeNodeTypes(schemas *types.Schemas) *types.Schemas { 166 return schemas. 167 TypeName("internalNodeStatus", v1.NodeStatus{}). 168 TypeName("internalNodeSpec", v1.NodeSpec{}). 169 AddMapperForType(&Version, v1.NodeStatus{}, 170 &mapper.NodeAddressMapper{}, 171 &mapper.OSInfo{}, 172 &m.Drop{Field: "addresses"}, 173 &m.Drop{Field: "daemonEndpoints"}, 174 &m.Drop{Field: "images"}, 175 &m.Drop{Field: "nodeInfo"}, 176 &m.Move{From: "conditions", To: "nodeConditions"}, 177 &m.Drop{Field: "phase"}, 178 &m.SliceToMap{Field: "volumesAttached", Key: "devicePath"}, 179 ). 180 AddMapperForType(&Version, v1.NodeSpec{}, 181 &m.Drop{Field: "externalID"}, 182 &m.Drop{Field: "configSource"}, 183 &m.Move{From: "providerID", To: "providerId"}, 184 &m.Move{From: "podCIDR", To: "podCidr"}, 185 &m.Move{From: "podCIDRs", To: "podCidrs"}, 186 m.Access{Fields: map[string]string{ 187 "podCidr": "r", 188 "podCidrs": "r", 189 "providerId": "r", 190 "taints": "ru", 191 "unschedulable": "ru", 192 }}). 193 AddMapperForType(&Version, v1.Node{}, 194 &mapper.NodeAddressAnnotationMapper{}). 195 MustImportAndCustomize(&Version, v1.NodeSpec{}, func(schema *types.Schema) { 196 schema.CodeName = "InternalNodeSpec" 197 schema.CodeNamePlural = "InternalNodeSpecs" 198 }). 199 MustImportAndCustomize(&Version, v1.NodeStatus{}, func(schema *types.Schema) { 200 schema.CodeName = "InternalNodeStatus" 201 schema.CodeNamePlural = "InternalNodeStatuses" 202 }, struct { 203 IPAddress string 204 ExternalIPAddress string `json:"externalIpAddress,omitempty"` 205 Hostname string 206 Info NodeInfo 207 }{}) 208 } 209 210 func clusterTypes(schemas *types.Schemas) *types.Schemas { 211 return schemas. 212 AddMapperForType(&Version, v3.Cluster{}, 213 &m.Embed{Field: "status"}, 214 mapper.NewDropFromSchema("genericEngineConfig"), 215 mapper.NewDropFromSchema("googleKubernetesEngineConfig"), 216 mapper.NewDropFromSchema("azureKubernetesServiceConfig"), 217 mapper.NewDropFromSchema("amazonElasticContainerServiceConfig"), 218 m.DisplayName{}, 219 ). 220 AddMapperForType(&Version, v3.ClusterStatus{}, 221 m.Drop{Field: "serviceAccountToken"}, 222 ). 223 AddMapperForType(&Version, v3.ClusterRegistrationToken{}, 224 &m.Embed{Field: "status"}, 225 ). 226 AddMapperForType(&Version, v3.RancherKubernetesEngineConfig{}, 227 m.Drop{Field: "systemImages"}, 228 ). 229 MustImport(&Version, v3.Cluster{}). 230 MustImport(&Version, v3.ClusterRegistrationToken{}). 231 MustImport(&Version, v3.GenerateKubeConfigOutput{}). 232 MustImport(&Version, v3.ImportClusterYamlInput{}). 233 MustImport(&Version, v3.RotateCertificateInput{}). 234 MustImport(&Version, v3.RotateCertificateOutput{}). 235 MustImport(&Version, v3.ImportYamlOutput{}). 236 MustImport(&Version, v3.ExportOutput{}). 237 MustImport(&Version, v3.MonitoringInput{}). 238 MustImport(&Version, v3.MonitoringOutput{}). 239 MustImport(&Version, v3.RestoreFromEtcdBackupInput{}). 240 MustImport(&Version, v3.SaveAsTemplateInput{}). 241 MustImport(&Version, v3.SaveAsTemplateOutput{}). 242 MustImportAndCustomize(&Version, v3.ETCDService{}, func(schema *types.Schema) { 243 schema.MustCustomizeField("extraArgs", func(field types.Field) types.Field { 244 field.Default = map[string]interface{}{ 245 "election-timeout": "5000", 246 "heartbeat-interval": "500"} 247 return field 248 }) 249 }). 250 MustImportAndCustomize(&Version, v3.Cluster{}, func(schema *types.Schema) { 251 schema.MustCustomizeField("name", func(field types.Field) types.Field { 252 field.Type = "dnsLabel" 253 field.Nullable = true 254 field.Required = false 255 return field 256 }) 257 schema.ResourceActions[v3.ClusterActionGenerateKubeconfig] = types.Action{ 258 Output: "generateKubeConfigOutput", 259 } 260 schema.ResourceActions[v3.ClusterActionImportYaml] = types.Action{ 261 Input: "importClusterYamlInput", 262 Output: "importYamlOutput", 263 } 264 schema.ResourceActions[v3.ClusterActionExportYaml] = types.Action{ 265 Output: "exportOutput", 266 } 267 schema.ResourceActions[v3.ClusterActionEnableMonitoring] = types.Action{ 268 Input: "monitoringInput", 269 } 270 schema.ResourceActions[v3.ClusterActionDisableMonitoring] = types.Action{} 271 schema.ResourceActions[v3.ClusterActionViewMonitoring] = types.Action{ 272 Output: "monitoringOutput", 273 } 274 schema.ResourceActions[v3.ClusterActionEditMonitoring] = types.Action{ 275 Input: "monitoringInput", 276 } 277 schema.ResourceActions[v3.ClusterActionBackupEtcd] = types.Action{} 278 schema.ResourceActions[v3.ClusterActionRestoreFromEtcdBackup] = types.Action{ 279 Input: "restoreFromEtcdBackupInput", 280 } 281 schema.ResourceActions[v3.ClusterActionRotateCertificates] = types.Action{ 282 Input: "rotateCertificateInput", 283 Output: "rotateCertificateOutput", 284 } 285 schema.ResourceActions[v3.ClusterActionRunSecurityScan] = types.Action{ 286 Input: "cisScanConfig", 287 } 288 schema.ResourceActions[v3.ClusterActionSaveAsTemplate] = types.Action{ 289 Input: "saveAsTemplateInput", 290 Output: "saveAsTemplateOutput", 291 } 292 }) 293 } 294 295 func authzTypes(schemas *types.Schemas) *types.Schemas { 296 return schemas. 297 MustImport(&Version, v3.ProjectStatus{}). 298 AddMapperForType(&Version, v3.Project{}, 299 m.DisplayName{}, 300 &m.Embed{Field: "status"}, 301 ). 302 AddMapperForType(&Version, v3.GlobalRole{}, m.DisplayName{}). 303 AddMapperForType(&Version, v3.RoleTemplate{}, m.DisplayName{}). 304 AddMapperForType(&Version, 305 v3.PodSecurityPolicyTemplateProjectBinding{}, 306 &mapper.NamespaceIDMapper{}). 307 AddMapperForType(&Version, v3.ProjectRoleTemplateBinding{}, 308 &mapper.NamespaceIDMapper{}, 309 ). 310 MustImport(&Version, v3.SetPodSecurityPolicyTemplateInput{}). 311 MustImport(&Version, v3.ImportYamlOutput{}). 312 MustImport(&Version, v3.MonitoringInput{}). 313 MustImport(&Version, v3.MonitoringOutput{}). 314 MustImportAndCustomize(&Version, v3.Project{}, func(schema *types.Schema) { 315 schema.ResourceActions = map[string]types.Action{ 316 "setpodsecuritypolicytemplate": { 317 Input: "setPodSecurityPolicyTemplateInput", 318 Output: "project", 319 }, 320 "exportYaml": {}, 321 "enableMonitoring": { 322 Input: "monitoringInput", 323 }, 324 "disableMonitoring": {}, 325 "viewMonitoring": { 326 Output: "monitoringOutput", 327 }, 328 "editMonitoring": { 329 Input: "monitoringInput", 330 }, 331 } 332 }). 333 MustImport(&Version, v3.GlobalRole{}). 334 MustImport(&Version, v3.GlobalRoleBinding{}). 335 MustImport(&Version, v3.RoleTemplate{}). 336 MustImport(&Version, v3.PodSecurityPolicyTemplate{}). 337 MustImportAndCustomize(&Version, v3.PodSecurityPolicyTemplateProjectBinding{}, func(schema *types.Schema) { 338 schema.CollectionMethods = []string{http.MethodGet, http.MethodPost} 339 schema.ResourceMethods = []string{} 340 }). 341 MustImport(&Version, v3.ClusterRoleTemplateBinding{}). 342 MustImport(&Version, v3.ProjectRoleTemplateBinding{}). 343 MustImport(&Version, v3.GlobalRoleBinding{}) 344 } 345 346 func nodeTypes(schemas *types.Schemas) *types.Schemas { 347 return schemas. 348 AddMapperForType(&Version, v3.NodeSpec{}, &m.Embed{Field: "internalNodeSpec"}). 349 AddMapperForType(&Version, v3.NodeStatus{}, 350 &m.Drop{Field: "nodeTemplateSpec"}, 351 &m.Embed{Field: "internalNodeStatus"}, 352 &m.Drop{Field: "config"}, 353 &m.SliceMerge{From: []string{"conditions", "nodeConditions"}, To: "conditions"}). 354 AddMapperForType(&Version, v3.Node{}, 355 &m.Embed{Field: "status"}, 356 &m.Move{From: "rkeNode/user", To: "sshUser"}, 357 &m.ReadOnly{Field: "sshUser"}, 358 &m.Drop{Field: "rkeNode"}, 359 &m.Drop{Field: "labels"}, 360 &m.Drop{Field: "annotations"}, 361 &m.Move{From: "nodeLabels", To: "labels"}, 362 &m.Move{From: "nodeAnnotations", To: "annotations"}, 363 &m.Drop{Field: "desiredNodeTaints"}, 364 &m.Drop{Field: "metadataUpdate"}, 365 &m.Drop{Field: "updateTaintsFromAPI"}, 366 &m.Drop{Field: "desiredNodeUnschedulable"}, 367 &m.Drop{Field: "nodeDrainInput"}, 368 &m.AnnotationField{Field: "publicEndpoints", List: true}, 369 m.Copy{From: "namespaceId", To: "clusterName"}, 370 m.DisplayName{}). 371 AddMapperForType(&Version, v3.NodeDriver{}, m.DisplayName{}). 372 AddMapperForType(&Version, v3.NodeTemplate{}, m.DisplayName{}). 373 MustImport(&Version, v3.PublicEndpoint{}). 374 MustImportAndCustomize(&Version, v3.NodePool{}, func(schema *types.Schema) { 375 schema.ResourceFields["driver"] = types.Field{ 376 Type: "string", 377 CodeName: "Driver", 378 Create: false, 379 Update: false, 380 } 381 }). 382 MustImportAndCustomize(&Version, v3.NodeDrainInput{}, func(schema *types.Schema) { 383 dsField := schema.ResourceFields["ignoreDaemonSets"] 384 test := true 385 dsField.Default = &test 386 }). 387 MustImportAndCustomize(&Version, v3.Node{}, func(schema *types.Schema) { 388 labelField := schema.ResourceFields["labels"] 389 labelField.Create = true 390 labelField.Update = true 391 schema.ResourceFields["labels"] = labelField 392 annotationField := schema.ResourceFields["annotations"] 393 annotationField.Create = true 394 annotationField.Update = true 395 schema.ResourceFields["annotations"] = annotationField 396 unschedulable := schema.ResourceFields["unschedulable"] 397 unschedulable.Create = false 398 unschedulable.Update = false 399 schema.ResourceFields["unschedulable"] = unschedulable 400 clusterField := schema.ResourceFields["clusterId"] 401 clusterField.Type = "reference[cluster]" 402 schema.ResourceFields["clusterId"] = clusterField 403 schema.ResourceActions["cordon"] = types.Action{} 404 schema.ResourceActions["uncordon"] = types.Action{} 405 schema.ResourceActions["stopDrain"] = types.Action{} 406 schema.ResourceActions["drain"] = types.Action{ 407 Input: "nodeDrainInput", 408 } 409 }, struct { 410 PublicEndpoints string `json:"publicEndpoints" norman:"type=array[publicEndpoint],nocreate,noupdate"` 411 }{}). 412 MustImportAndCustomize(&Version, v3.NodeDriver{}, func(schema *types.Schema) { 413 schema.ResourceActions["activate"] = types.Action{ 414 Output: "nodeDriver", 415 } 416 schema.ResourceActions["deactivate"] = types.Action{ 417 Output: "nodeDriver", 418 } 419 }). 420 MustImportAndCustomize(&Version, v3.NodeTemplate{}, func(schema *types.Schema) { 421 delete(schema.ResourceFields, "namespaceId") 422 }) 423 } 424 425 func tokens(schemas *types.Schemas) *types.Schemas { 426 return schemas. 427 MustImportAndCustomize(&Version, v3.Token{}, func(schema *types.Schema) { 428 schema.CollectionActions = map[string]types.Action{ 429 "logout": {}, 430 } 431 }) 432 } 433 434 func authnTypes(schemas *types.Schemas) *types.Schemas { 435 return schemas. 436 AddMapperForType(&Version, v3.User{}, m.DisplayName{}, 437 &m.Embed{Field: "status"}). 438 AddMapperForType(&Version, v3.Group{}, m.DisplayName{}). 439 MustImport(&Version, v3.Group{}). 440 MustImport(&Version, v3.GroupMember{}). 441 MustImport(&Version, v3.SamlToken{}). 442 AddMapperForType(&Version, v3.Principal{}, m.DisplayName{}). 443 MustImportAndCustomize(&Version, v3.Principal{}, func(schema *types.Schema) { 444 schema.CollectionMethods = []string{http.MethodGet} 445 schema.ResourceMethods = []string{http.MethodGet} 446 schema.CollectionActions = map[string]types.Action{ 447 "search": { 448 Input: "searchPrincipalsInput", 449 Output: "collection", 450 }, 451 } 452 }). 453 MustImport(&Version, v3.SearchPrincipalsInput{}). 454 MustImport(&Version, v3.ChangePasswordInput{}). 455 MustImport(&Version, v3.SetPasswordInput{}). 456 MustImportAndCustomize(&Version, v3.User{}, func(schema *types.Schema) { 457 schema.ResourceActions = map[string]types.Action{ 458 "setpassword": { 459 Input: "setPasswordInput", 460 Output: "user", 461 }, 462 "refreshauthprovideraccess": {}, 463 } 464 schema.CollectionActions = map[string]types.Action{ 465 "changepassword": { 466 Input: "changePasswordInput", 467 }, 468 "refreshauthprovideraccess": {}, 469 } 470 }). 471 MustImportAndCustomize(&Version, v3.AuthConfig{}, func(schema *types.Schema) { 472 schema.CollectionMethods = []string{http.MethodGet} 473 }). 474 // Local Config 475 MustImportAndCustomize(&Version, v3.LocalConfig{}, func(schema *types.Schema) { 476 schema.BaseType = "authConfig" 477 schema.CollectionMethods = []string{} 478 schema.ResourceMethods = []string{http.MethodGet} 479 }). 480 //Github Config 481 MustImportAndCustomize(&Version, v3.GithubConfig{}, func(schema *types.Schema) { 482 schema.BaseType = "authConfig" 483 schema.ResourceActions = map[string]types.Action{ 484 "disable": {}, 485 "configureTest": { 486 Input: "githubConfig", 487 Output: "githubConfigTestOutput", 488 }, 489 "testAndApply": { 490 Input: "githubConfigApplyInput", 491 }, 492 } 493 schema.CollectionMethods = []string{} 494 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 495 }). 496 MustImport(&Version, v3.GithubConfigTestOutput{}). 497 MustImport(&Version, v3.GithubConfigApplyInput{}). 498 //AzureAD Config 499 MustImportAndCustomize(&Version, v3.AzureADConfig{}, func(schema *types.Schema) { 500 schema.BaseType = "authConfig" 501 schema.ResourceActions = map[string]types.Action{ 502 "disable": {}, 503 "configureTest": { 504 Input: "azureADConfig", 505 Output: "azureADConfigTestOutput", 506 }, 507 "testAndApply": { 508 Input: "azureADConfigApplyInput", 509 }, 510 } 511 schema.CollectionMethods = []string{} 512 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 513 }). 514 MustImport(&Version, v3.AzureADConfigTestOutput{}). 515 MustImport(&Version, v3.AzureADConfigApplyInput{}). 516 // Active Directory Config 517 MustImportAndCustomize(&Version, v3.ActiveDirectoryConfig{}, func(schema *types.Schema) { 518 schema.BaseType = "authConfig" 519 schema.ResourceActions = map[string]types.Action{ 520 "disable": {}, 521 "testAndApply": { 522 Input: "activeDirectoryTestAndApplyInput", 523 }, 524 } 525 schema.CollectionMethods = []string{} 526 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 527 }). 528 MustImport(&Version, v3.ActiveDirectoryTestAndApplyInput{}). 529 // OpenLdap Config 530 MustImportAndCustomize(&Version, v3.OpenLdapConfig{}, func(schema *types.Schema) { 531 schema.BaseType = "authConfig" 532 schema.ResourceActions = map[string]types.Action{ 533 "disable": {}, 534 "testAndApply": { 535 Input: "openLdapTestAndApplyInput", 536 }, 537 } 538 schema.CollectionMethods = []string{} 539 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 540 }). 541 MustImport(&Version, v3.OpenLdapTestAndApplyInput{}). 542 // FreeIpa Config 543 AddMapperForType(&Version, v3.FreeIpaConfig{}, m.Drop{Field: "nestedGroupMembershipEnabled"}). 544 MustImportAndCustomize(&Version, v3.FreeIpaConfig{}, func(schema *types.Schema) { 545 schema.BaseType = "authConfig" 546 schema.ResourceActions = map[string]types.Action{ 547 "disable": {}, 548 "testAndApply": { 549 Input: "freeIpaTestAndApplyInput", 550 }, 551 } 552 schema.CollectionMethods = []string{} 553 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 554 schema.MustCustomizeField("groupObjectClass", func(f types.Field) types.Field { 555 f.Default = "groupofnames" 556 return f 557 }) 558 schema.MustCustomizeField("userNameAttribute", func(f types.Field) types.Field { 559 f.Default = "givenName" 560 return f 561 }) 562 schema.MustCustomizeField("userObjectClass", func(f types.Field) types.Field { 563 f.Default = "inetorgperson" 564 return f 565 }) 566 schema.MustCustomizeField("groupDNAttribute", func(f types.Field) types.Field { 567 f.Default = "entrydn" 568 return f 569 }) 570 schema.MustCustomizeField("groupMemberUserAttribute", func(f types.Field) types.Field { 571 f.Default = "entrydn" 572 return f 573 }) 574 }). 575 MustImport(&Version, v3.FreeIpaTestAndApplyInput{}). 576 // Saml Config 577 // Ping-Saml Config 578 // KeyCloak-Saml Configs 579 MustImportAndCustomize(&Version, v3.PingConfig{}, configSchema). 580 MustImportAndCustomize(&Version, v3.ADFSConfig{}, configSchema). 581 MustImportAndCustomize(&Version, v3.KeyCloakConfig{}, configSchema). 582 MustImportAndCustomize(&Version, v3.OKTAConfig{}, configSchema). 583 MustImportAndCustomize(&Version, v3.ShibbolethConfig{}, configSchema). 584 MustImport(&Version, v3.SamlConfigTestInput{}). 585 MustImport(&Version, v3.SamlConfigTestOutput{}). 586 //GoogleOAuth Config 587 MustImportAndCustomize(&Version, v3.GoogleOauthConfig{}, func(schema *types.Schema) { 588 schema.BaseType = "authConfig" 589 schema.ResourceActions = map[string]types.Action{ 590 "disable": {}, 591 "configureTest": { 592 Input: "googleOauthConfig", 593 Output: "googleOauthConfigTestOutput", 594 }, 595 "testAndApply": { 596 Input: "googleOauthConfigApplyInput", 597 }, 598 } 599 schema.CollectionMethods = []string{} 600 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 601 }). 602 MustImport(&Version, v3.GoogleOauthConfigApplyInput{}). 603 MustImport(&Version, v3.GoogleOauthConfigTestOutput{}) 604 } 605 606 func configSchema(schema *types.Schema) { 607 schema.BaseType = "authConfig" 608 schema.ResourceActions = map[string]types.Action{ 609 "disable": {}, 610 "testAndEnable": { 611 Input: "samlConfigTestInput", 612 Output: "samlConfigTestOutput", 613 }, 614 } 615 schema.CollectionMethods = []string{} 616 schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} 617 } 618 619 func userTypes(schema *types.Schemas) *types.Schemas { 620 return schema. 621 MustImportAndCustomize(&Version, v3.Preference{}, func(schema *types.Schema) { 622 schema.MustCustomizeField("name", func(f types.Field) types.Field { 623 f.Required = true 624 return f 625 }) 626 schema.MustCustomizeField("namespaceId", func(f types.Field) types.Field { 627 f.Required = false 628 return f 629 }) 630 }). 631 MustImportAndCustomize(&Version, v3.UserAttribute{}, func(schema *types.Schema) { 632 schema.CollectionMethods = []string{} 633 schema.ResourceMethods = []string{} 634 }) 635 } 636 637 func projectNetworkPolicyTypes(schema *types.Schemas) *types.Schemas { 638 return schema. 639 MustImportAndCustomize(&Version, v3.ProjectNetworkPolicy{}, func(schema *types.Schema) { 640 schema.CollectionMethods = []string{http.MethodGet} 641 schema.ResourceMethods = []string{http.MethodGet} 642 }) 643 } 644 645 func logTypes(schema *types.Schemas) *types.Schemas { 646 return schema. 647 AddMapperForType(&Version, v3.ClusterLogging{}, 648 &m.Embed{Field: "status"}, 649 m.DisplayName{}). 650 AddMapperForType(&Version, v3.ProjectLogging{}, 651 m.DisplayName{}). 652 MustImport(&Version, v3.ClusterTestInput{}). 653 MustImport(&Version, v3.ProjectTestInput{}). 654 MustImportAndCustomize(&Version, v3.ClusterLogging{}, func(schema *types.Schema) { 655 schema.CollectionActions = map[string]types.Action{ 656 "test": { 657 Input: "clusterTestInput", 658 }, 659 "dryRun": { 660 Input: "clusterTestInput", 661 }, 662 } 663 }). 664 MustImportAndCustomize(&Version, v3.ProjectLogging{}, func(schema *types.Schema) { 665 schema.CollectionActions = map[string]types.Action{ 666 "test": { 667 Input: "projectTestInput", 668 }, 669 "dryRun": { 670 Input: "projectTestInput", 671 }, 672 } 673 }) 674 } 675 676 func globalTypes(schema *types.Schemas) *types.Schemas { 677 return schema. 678 MustImportAndCustomize(&Version, v3.Setting{}, func(schema *types.Schema) { 679 schema.MustCustomizeField("name", func(f types.Field) types.Field { 680 f.Required = true 681 return f 682 }) 683 }). 684 MustImportAndCustomize(&Version, v3.Feature{}, func(schema *types.Schema) { 685 schema.MustCustomizeField("name", func(f types.Field) types.Field { 686 f.Required = true 687 return f 688 }) 689 }) 690 } 691 692 func alertTypes(schema *types.Schemas) *types.Schemas { 693 return schema. 694 AddMapperForType(&Version, v3.Notifier{}, 695 &m.Embed{Field: "status"}, 696 m.DisplayName{}). 697 MustImport(&Version, v3.ClusterAlert{}). 698 MustImport(&Version, v3.ProjectAlert{}). 699 MustImport(&Version, v3.Notification{}). 700 MustImportAndCustomize(&Version, v3.Notifier{}, func(schema *types.Schema) { 701 schema.CollectionActions = map[string]types.Action{ 702 "send": { 703 Input: "notification", 704 }, 705 } 706 schema.ResourceActions = map[string]types.Action{ 707 "send": { 708 Input: "notification", 709 }, 710 } 711 }). 712 MustImport(&Version, v3.AlertStatus{}). 713 AddMapperForType(&Version, v3.ClusterAlertGroup{}, 714 &m.Embed{Field: "status"}, 715 m.DisplayName{}). 716 AddMapperForType(&Version, v3.ProjectAlertGroup{}, 717 &m.Embed{Field: "status"}, 718 m.DisplayName{}). 719 AddMapperForType(&Version, v3.ClusterAlertRule{}, 720 &m.Embed{Field: "status"}, 721 m.DisplayName{}). 722 AddMapperForType(&Version, v3.ProjectAlertRule{}, 723 &m.Embed{Field: "status"}, 724 m.DisplayName{}). 725 MustImport(&Version, v3.ClusterAlertGroup{}). 726 MustImport(&Version, v3.ProjectAlertGroup{}). 727 MustImportAndCustomize(&Version, v3.ClusterAlertRule{}, func(schema *types.Schema) { 728 schema.ResourceActions = map[string]types.Action{ 729 "activate": {}, 730 "deactivate": {}, 731 "mute": {}, 732 "unmute": {}, 733 } 734 }). 735 MustImportAndCustomize(&Version, v3.ProjectAlertRule{}, func(schema *types.Schema) { 736 schema.ResourceActions = map[string]types.Action{ 737 "activate": {}, 738 "deactivate": {}, 739 "mute": {}, 740 "unmute": {}, 741 } 742 }) 743 744 } 745 746 func composeType(schemas *types.Schemas) *types.Schemas { 747 return schemas.MustImport(&Version, v3.ComposeConfig{}) 748 } 749 750 func projectCatalogTypes(schemas *types.Schemas) *types.Schemas { 751 return schemas. 752 AddMapperForType(&Version, v3.ProjectCatalog{}, 753 &m.Move{From: "catalogKind", To: "kind"}, 754 &m.Embed{Field: "status"}, 755 &m.Drop{Field: "helmVersionCommits"}, 756 &mapper.NamespaceIDMapper{}). 757 MustImportAndCustomize(&Version, v3.ProjectCatalog{}, func(schema *types.Schema) { 758 schema.ResourceActions = map[string]types.Action{ 759 "refresh": {Output: "catalogRefresh"}, 760 } 761 schema.CollectionActions = map[string]types.Action{ 762 "refresh": {Output: "catalogRefresh"}, 763 } 764 }) 765 } 766 767 func clusterCatalogTypes(schemas *types.Schemas) *types.Schemas { 768 return schemas. 769 AddMapperForType(&Version, v3.ClusterCatalog{}, 770 &m.Move{From: "catalogKind", To: "kind"}, 771 &m.Embed{Field: "status"}, 772 &m.Drop{Field: "helmVersionCommits"}, 773 &mapper.NamespaceIDMapper{}). 774 MustImportAndCustomize(&Version, v3.ClusterCatalog{}, func(schema *types.Schema) { 775 schema.ResourceActions = map[string]types.Action{ 776 "refresh": {Output: "catalogRefresh"}, 777 } 778 schema.CollectionActions = map[string]types.Action{ 779 "refresh": {Output: "catalogRefresh"}, 780 } 781 }) 782 } 783 784 func multiClusterAppTypes(schemas *types.Schemas) *types.Schemas { 785 return schemas. 786 AddMapperForType(&Version, v3.MultiClusterApp{}, m.Drop{Field: "namespaceId"}). 787 AddMapperForType(&Version, v3.MultiClusterAppRevision{}, m.Drop{Field: "namespaceId"}). 788 AddMapperForType(&Version, v3.Member{}, m.Drop{Field: "userName"}, m.Drop{Field: "displayName"}). 789 MustImport(&Version, v3.MultiClusterApp{}). 790 MustImport(&Version, v3.Target{}). 791 MustImport(&Version, v3.UpgradeStrategy{}). 792 MustImport(&Version, v3.MultiClusterAppRollbackInput{}). 793 MustImport(&Version, v3.MultiClusterAppRevision{}). 794 MustImport(&Version, v3.UpdateMultiClusterAppTargetsInput{}). 795 MustImportAndCustomize(&Version, v3.MultiClusterApp{}, func(schema *types.Schema) { 796 schema.ResourceActions = map[string]types.Action{ 797 "rollback": { 798 Input: "multiClusterAppRollbackInput", 799 }, 800 "addProjects": { 801 Input: "updateMultiClusterAppTargetsInput", 802 }, 803 "removeProjects": { 804 Input: "updateMultiClusterAppTargetsInput", 805 }, 806 } 807 }) 808 } 809 810 func globalDNSTypes(schemas *types.Schemas) *types.Schemas { 811 return schemas. 812 TypeName("globalDns", v3.GlobalDNS{}). 813 TypeName("globalDnsProvider", v3.GlobalDNSProvider{}). 814 TypeName("globalDnsSpec", v3.GlobalDNSSpec{}). 815 TypeName("globalDnsStatus", v3.GlobalDNSStatus{}). 816 TypeName("globalDnsProviderSpec", v3.GlobalDNSProviderSpec{}). 817 MustImport(&Version, v3.UpdateGlobalDNSTargetsInput{}). 818 AddMapperForType(&Version, v3.GlobalDNS{}, m.Drop{Field: "namespaceId"}). 819 AddMapperForType(&Version, v3.GlobalDNSProvider{}, m.Drop{Field: "namespaceId"}). 820 MustImportAndCustomize(&Version, v3.GlobalDNS{}, func(schema *types.Schema) { 821 schema.ResourceActions = map[string]types.Action{ 822 "addProjects": { 823 Input: "updateGlobalDNSTargetsInput", 824 }, 825 "removeProjects": { 826 Input: "updateGlobalDNSTargetsInput", 827 }, 828 } 829 }). 830 MustImportAndCustomize(&Version, v3.GlobalDNSProvider{}, func(schema *types.Schema) { 831 }) 832 } 833 834 func kontainerTypes(schemas *types.Schemas) *types.Schemas { 835 return schemas. 836 AddMapperForType(&Version, v3.KontainerDriver{}, 837 &m.Embed{Field: "status"}, 838 m.DisplayName{}, 839 ). 840 MustImportAndCustomize(&Version, v3.KontainerDriver{}, func(schema *types.Schema) { 841 schema.ResourceActions = map[string]types.Action{ 842 "activate": {}, 843 "deactivate": {}, 844 } 845 schema.CollectionActions = map[string]types.Action{ 846 "refresh": {}, 847 } 848 }) 849 } 850 851 func monitorTypes(schemas *types.Schemas) *types.Schemas { 852 return schemas. 853 MustImport(&Version, v3.QueryGraphInput{}). 854 MustImport(&Version, v3.QueryClusterGraphOutput{}). 855 MustImport(&Version, v3.QueryProjectGraphOutput{}). 856 MustImport(&Version, v3.QueryClusterMetricInput{}). 857 MustImport(&Version, v3.QueryProjectMetricInput{}). 858 MustImport(&Version, v3.QueryMetricOutput{}). 859 MustImport(&Version, v3.ClusterMetricNamesInput{}). 860 MustImport(&Version, v3.ProjectMetricNamesInput{}). 861 MustImport(&Version, v3.MetricNamesOutput{}). 862 MustImport(&Version, v3.TimeSeries{}). 863 MustImportAndCustomize(&Version, v3.MonitorMetric{}, func(schema *types.Schema) { 864 schema.CollectionActions = map[string]types.Action{ 865 "querycluster": { 866 Input: "queryClusterMetricInput", 867 Output: "queryMetricOutput", 868 }, 869 "listclustermetricname": { 870 Input: "clusterMetricNamesInput", 871 Output: "metricNamesOutput", 872 }, 873 "queryproject": { 874 Input: "queryProjectMetricInput", 875 Output: "queryMetricOutput", 876 }, 877 "listprojectmetricname": { 878 Input: "projectMetricNamesInput", 879 Output: "metricNamesOutput", 880 }, 881 } 882 }). 883 MustImportAndCustomize(&Version, v3.ClusterMonitorGraph{}, func(schema *types.Schema) { 884 schema.CollectionActions = map[string]types.Action{ 885 "query": { 886 Input: "queryGraphInput", 887 Output: "queryClusterGraphOutput", 888 }, 889 } 890 }). 891 MustImportAndCustomize(&Version, v3.ProjectMonitorGraph{}, func(schema *types.Schema) { 892 schema.CollectionActions = map[string]types.Action{ 893 "query": { 894 Input: "queryGraphInput", 895 Output: "queryProjectGraphOutput", 896 }, 897 } 898 }) 899 } 900 901 func etcdBackupTypes(schemas *types.Schemas) *types.Schemas { 902 return schemas.MustImport(&Version, v3.EtcdBackup{}) 903 } 904 905 func clusterTemplateTypes(schemas *types.Schemas) *types.Schemas { 906 return schemas. 907 TypeName("clusterTemplate", v3.ClusterTemplate{}). 908 TypeName("clusterTemplateRevision", v3.ClusterTemplateRevision{}). 909 AddMapperForType(&Version, v3.ClusterTemplate{}, m.Drop{Field: "namespaceId"}, m.DisplayName{}). 910 AddMapperForType(&Version, v3.ClusterTemplateRevision{}, 911 m.Drop{Field: "namespaceId"}, 912 &m.Embed{Field: "status"}, 913 m.DisplayName{}). 914 MustImport(&Version, v3.ClusterTemplateQuestionsOutput{}). 915 MustImport(&Version, v3.ClusterTemplate{}). 916 MustImportAndCustomize(&Version, v3.ClusterTemplateRevision{}, func(schema *types.Schema) { 917 schema.ResourceActions = map[string]types.Action{ 918 "disable": {}, 919 "enable": {}, 920 } 921 schema.CollectionActions = map[string]types.Action{ 922 "listquestions": { 923 Output: "clusterTemplateQuestionsOutput", 924 }, 925 } 926 }) 927 928 } 929 930 func clusterScanTypes(schemas *types.Schemas) *types.Schemas { 931 return schemas.MustImportAndCustomize(&Version, v3.ClusterScan{}, func(schema *types.Schema) { 932 schema.CollectionMethods = []string{http.MethodGet} 933 schema.ResourceMethods = []string{http.MethodGet, http.MethodDelete} 934 }) 935 } 936 937 func encryptionTypes(schemas *types.Schemas) *types.Schemas { 938 return schemas.MustImport(&Version, v3.SecretsEncryptionConfig{}). 939 MustImport(&Version, apiserverconfig.Key{}, struct { 940 Secret string `norman:"type=password"` 941 }{}).MustImport(&Version, apiserverconfig.KMSConfiguration{}, struct { 942 Timeout string 943 }{}) 944 }