(configFileName string, configBytes []byte, force bool)
| 84 | } |
| 85 | |
| 86 | func Deploy(configFileName string, configBytes []byte, force bool) ([]schema.DeployResult, error) { |
| 87 | apiConfigs, err := spec.ExtractAPIConfigs(configBytes, configFileName) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | |
| 92 | err = ValidateClusterAPIs(apiConfigs) |
| 93 | if err != nil { |
| 94 | err = errors.Append(err, fmt.Sprintf("\n\napi configuration schema can be found at https://docs.cortex.dev/v/%s/", consts.CortexVersionMinor)) |
| 95 | return nil, err |
| 96 | } |
| 97 | |
| 98 | // This is done if user specifies RealtimeAPIs in same file as TrafficSplitter |
| 99 | apiConfigs = append(ExclusiveFilterAPIsByKind(apiConfigs, userconfig.TrafficSplitterKind), InclusiveFilterAPIsByKind(apiConfigs, userconfig.TrafficSplitterKind)...) |
| 100 | |
| 101 | results := make([]schema.DeployResult, 0, len(apiConfigs)) |
| 102 | for i := range apiConfigs { |
| 103 | apiConfig := apiConfigs[i] |
| 104 | |
| 105 | api, msg, err := UpdateAPI(&apiConfig, force) |
| 106 | |
| 107 | result := schema.DeployResult{ |
| 108 | Message: msg, |
| 109 | API: api, |
| 110 | } |
| 111 | |
| 112 | if err != nil { |
| 113 | result.Error = errors.ErrorStr(err) |
| 114 | } |
| 115 | |
| 116 | results = append(results, result) |
| 117 | } |
| 118 | |
| 119 | return results, nil |
| 120 | } |
| 121 | |
| 122 | func UpdateAPI(apiConfig *userconfig.API, force bool) (*schema.APIResponse, string, error) { |
| 123 | deployedResource, err := GetDeployedResourceByNameOrNil(apiConfig.Name) |
no test coverage detected