Scott Baker | 63ce82e | 2019-05-15 09:01:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Portions copyright 2019-present Open Networking Foundation |
| 3 | * Original copyright 2019-present Ciena Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | package commands |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
| 21 | flags "github.com/jessevdk/go-flags" |
Scott Baker | ce11c49 | 2019-07-30 15:53:34 -0700 | [diff] [blame^] | 22 | "github.com/opencord/cordctl/internal/pkg/config" |
Scott Baker | 63ce82e | 2019-05-15 09:01:42 -0700 | [diff] [blame] | 23 | "gopkg.in/yaml.v2" |
| 24 | ) |
| 25 | |
| 26 | const copyrightNotice = ` |
| 27 | # Portions copyright 2019-present Open Networking Foundation |
| 28 | # Original copyright 2019-present Ciena Corporation |
| 29 | # |
| 30 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 31 | # you may not use this file except in compliance with the License. |
| 32 | # You may obtain a copy of the License at |
| 33 | # |
| 34 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 35 | # |
| 36 | # Unless required by applicable law or agreed to in writing, software |
| 37 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 38 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 39 | # See the License for the specific language governing permissions and |
| 40 | # limitations under the License. |
| 41 | # |
| 42 | ` |
| 43 | |
| 44 | type ConfigOptions struct { |
| 45 | } |
| 46 | |
| 47 | func RegisterConfigCommands(parent *flags.Parser) { |
| 48 | parent.AddCommand("config", "generate cordctl configuration", "Commands to generate cordctl configuration", &ConfigOptions{}) |
| 49 | } |
| 50 | |
| 51 | func (options *ConfigOptions) Execute(args []string) error { |
| 52 | //GlobalConfig |
Scott Baker | ce11c49 | 2019-07-30 15:53:34 -0700 | [diff] [blame^] | 53 | config.ProcessGlobalOptions() |
| 54 | b, err := yaml.Marshal(config.GlobalConfig) |
Scott Baker | 63ce82e | 2019-05-15 09:01:42 -0700 | [diff] [blame] | 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | fmt.Println(copyrightNotice) |
| 59 | fmt.Println(string(b)) |
| 60 | return nil |
| 61 | } |