David K. Bainbridge | 1d94644 | 2021-03-19 16:45:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-present Ciena Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package config |
| 17 | |
| 18 | import ( |
| 19 | "strconv" |
| 20 | |
| 21 | configv1 "github.com/opencord/voltctl/internal/pkg/apis/config/v1" |
| 22 | ) |
| 23 | |
| 24 | func FromConfigV1(v1 *configv1.GlobalConfigSpec) *GlobalConfigSpec { |
| 25 | v2 := NewDefaultConfig() |
| 26 | |
| 27 | v2.Server = v1.Server |
| 28 | v2.Kafka = v1.Kafka |
| 29 | v2.KvStore = v1.KvStore |
| 30 | v2.Tls.UseTls = v1.Tls.UseTls |
| 31 | v2.Tls.CACert = v1.Tls.CACert |
| 32 | v2.Tls.Cert = v1.Tls.Cert |
| 33 | v2.Tls.Key = v1.Tls.Key |
| 34 | if v1.Tls.Verify != "" { |
| 35 | if b, err := strconv.ParseBool(v1.Tls.Verify); err == nil { |
| 36 | v2.Tls.Verify = b |
| 37 | } |
| 38 | } |
| 39 | v2.Grpc.Timeout = v1.Grpc.Timeout |
| 40 | v2.Grpc.MaxCallRecvMsgSize = v1.Grpc.MaxCallRecvMsgSize |
| 41 | v2.KvStoreConfig.Timeout = v1.KvStoreConfig.Timeout |
| 42 | v2.K8sConfig = v1.K8sConfig |
| 43 | return v2 |
| 44 | } |