Files
my-rook-config/cmd/rook/userfacing/multus/validation/config.go
T
Blaine Gardner f8d9076a38 multus: add config file for validation tool
Allow the validation tool to read test config from a yaml file. To help
users, also allow outputting a config file with default values and
comments instructing how to use the config file.

This work is in anticipation of adding more advanced configuration
options that would be too cumbersome to set using cli flags.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2023-06-20 11:54:37 -06:00

51 lines
1.2 KiB
Go

/*
Copyright 2023 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package validation
import (
"fmt"
"github.com/rook/rook/pkg/daemon/multus"
"github.com/spf13/cobra"
)
var (
configCmd = &cobra.Command{
Use: "config",
Short: "Generate a validation test config file for different default scenarios.",
Args: cobra.NoArgs,
}
simpleConfigCmd = &cobra.Command{
Use: "simple",
Short: "Generate a simple default config file.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
y, err := multus.NewDefaultValidationTestConfig().ToYAML()
if err != nil {
return err
}
fmt.Print(y)
return nil
},
}
)
func init() {
configCmd.AddCommand(simpleConfigCmd)
}