diff

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example (Diff)
package main

import (
	"os"

	"github.com/aws-cloudformation/rain/internal/cmd/diff"
	"github.com/aws-cloudformation/rain/internal/console"
)

func main() {
	os.Args = []string{
		os.Args[0],
		"../../../test/templates/success.template",
		"../../../test/templates/failure.template",
	}

	console.NoColour = true

	diff.Cmd.Execute()
}
Output:

(>) Description: This template fails
(-) Parameters: {...}
(|) Resources:
(|)   Bucket1:
(-)     Properties: {...}
(+)   Bucket2:
(+)     Properties:
(+)       BucketName:
(+)         Ref: Bucket1
(+)     Type: AWS::S3::Bucket

Index

Examples

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:                   "diff <from> <to>",
	Short:                 "Compare CloudFormation templates",
	Long:                  "Outputs a summary of the changes necessary to transform the CloudFormation template named <from> into the template named <to>.",
	Args:                  cobra.ExactArgs(2),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		leftFn, rightFn := args[0], args[1]

		left, err := parse.File(leftFn)
		if err != nil {
			panic(ui.Errorf(err, "unable to parse template '%s'", leftFn))
		}

		right, err := parse.File(rightFn)
		if err != nil {
			panic(ui.Errorf(err, "unable to parse template '%s'", leftFn))
		}

		fmt.Print(ui.ColouriseDiff(diff.New(left, right), longDiff))
	},
}

Cmd is the diff command's entrypoint

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