report

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "report",
	Short: "Generate inventory reports based on CAI outputs in a directory.",
	Long: `Generate inventory reports for resources in Cloud Asset Inventory (CAI) output files, with reports defined in rego (in '<path_to_cloud-foundation-toolkit>/reports/sample' folder).

	Example:
	  cft report --query-path <path_to_cloud-foundation-toolkit>/reports/sample \
		--dir-path <path-to-directory-containing-cai-export> \
		--report-path <path-to-directory-for-report-output>
	`,

	Args: cobra.NoArgs,

	RunE: func(cmd *cobra.Command, args []string) error {
		err := GenerateReports(flags.dirName, flags.queryPath, flags.outputPath, viper.GetString("report-format"))
		if err != nil {
			return err
		}
		return nil
	},
}

Cmd represents the base report command

Functions

func GenerateReports

func GenerateReports(dirPath string, queryPath string, outputPath string, reportFormat string) error

GenerateReports takes raw CAI exports from <dirPath> directory, run rego queries defined <queryPath> directory, and generate output of <reportFormat> in <outputPath> directory

func ListAvailableReports

func ListAvailableReports(queryPath string) error

ListAvailableReports lists the names of available reports in queryPath

func ReadFilesAndConcat

func ReadFilesAndConcat(dir string) (results []interface{}, err error)

ReadFilesAndConcat reads json files in a directory that are one object per row, and concats all objects into one single array

Types

This section is empty.

Jump to

Keyboard shortcuts

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