apply

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package apply provides the apply command for the minder CLI

Index

Constants

This section is empty.

Variables

View Source
var ApplyCmd = &cobra.Command{
	Use:   "apply (-f FILENAME)",
	Short: "Appy a configuration to a minder control plane",
	Long:  `The minder apply command applies a configuration to a minder control plane.`,
	PreRun: func(cmd *cobra.Command, args []string) {
		err := viper.BindPFlags(cmd.Flags())
		util.ExitNicelyOnError(err, "Error binding flags")
	},
	Run: func(cmd *cobra.Command, args []string) {
		f := util.GetConfigValue(viper.GetViper(), "file", "file", cmd, "").(string)

		var data []byte
		var err error

		if f == "-" {
			data, err = io.ReadAll(os.Stdin)
			util.ExitNicelyOnError(err, "Error reading from stdin")
		} else {
			f = filepath.Clean(f)
			data, err = os.ReadFile(f)
			util.ExitNicelyOnError(err, "Error reading file")
		}

		objects, err := parseContent(data)
		util.ExitNicelyOnError(err, "Error parsing content")

		for _, object := range objects {

			params := object.Parameters
			for k, v := range params {
				valueType := reflect.TypeOf(v)
				if valueType.Kind() == reflect.Int {
					v1 := v.(int)
					viper.Set(k, int32(v1))
				} else {
					viper.Set(k, v)
				}
			}
		}
	},
}

ApplyCmd is the root command for the apply subcommands

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL