cmd

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenerateCmd = &cobra.Command{
	Use:   "generate",
	Short: "Generates application-properties based on the hierarchy and config provided",
	RunE: func(cmd *cobra.Command, args []string) error {
		resources, err := pkg.ReadResources(input)
		if err != nil {
			return err
		}
		logger.Infof("%d resources found from %s", len(resources), input)

		for _, r := range resources {
			logger.Debugf("%s", kommons.GetName(r.Item))
		}
		buf, err := ioutil.ReadFile(configFile)
		if err != nil {
			return err
		}
		var config pkg.Config
		err = yaml.Unmarshal(buf, &config)
		if err != nil {
			return err
		}

		for _, name := range config.Applications {
			logger.Infof("[%s.properties]", name)
			hierarchy, err := pkg.GetHierarchy(configFile, name)
			if err != nil {
				return err
			}

			var file string
			if strings.ToLower(outputFileType) == "" || strings.ToLower(outputFileType) == "env" {
				file = hierarchy.GeneratePropertiesFile(resources)
			}
			if strings.ToLower(outputFileType) == "js" || strings.ToLower(outputFileType) == "javascript" {
				file = hierarchy.GenerateJsPropertiesFile(resources)
			}

			if outputType == "stdout" {
				fmt.Println(file)
			} else {
				filePath, err := text.Template(output, map[string]string{"name": name})
				if err != nil {
					return err
				}
				if err := os.MkdirAll(path.Dir(filePath), 0755); err != nil {
					return err
				}
				if err := ioutil.WriteFile(filePath, []byte(file), 0644); err != nil {
					return err
				}
			}

		}

		return nil
	},
}

GenerateCmd represents the base command when called without any subcommands

View Source
var Operator = &cobra.Command{
	Use:   "operator",
	Short: "Start the kubernetes operator",
	Run:   run,
}
View Source
var Server = &cobra.Command{
	Use:   "server",
	Short: "Start the konfig manager server and exposes the metrics",
	Run: func(cmd *cobra.Command, args []string) {
		pkg.Server(cmd)
	},
}

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