export

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutputLocationKey         = "output"
	OutputLocationShorthand   = "o"
	OutputTypeKey             = "output-type"
	OutputWithDiffCommentsKey = "diff"
	OutputVersionKey          = "output-version"
	OutputVersionShortHand    = "v"
	OutputVersionV1           = "v1"
	OutputVersionV2           = "v2"
)
View Source
const (
	OutputTypeSingleFile = "single-file"
	OutputTypeDirectory  = "dir"
)

Variables

View Source
var ExportClientIntentsCmd = &cobra.Command{
	Use:          "export [<service-id>]",
	Short:        "Export client intents for a service",
	Args:         cobra.MaximumNArgs(1),
	SilenceUsage: true,
	RunE: func(_ *cobra.Command, args []string) error {
		ctxTimeout, cancel := context.WithTimeout(context.Background(), config.DefaultTimeout)
		defer cancel()

		c, err := cloudclient.NewClient(ctxTimeout)
		if err != nil {
			return err
		}

		filter, err := servicesFilterFromFlags(ctxTimeout, c)
		if err != nil {
			return err
		}

		if len(args) == 1 {

			serviceID := args[0]
			filter.ServiceIds = lo.ToPtr(append(lo.FromPtr(filter.ServiceIds), serviceID))
		}

		featureFlags := cloudapi.InputFeatureFlags{}
		if viper.GetString(OutputVersionKey) == OutputVersionV2 {
			featureFlags.UseClientIntentsV2 = lo.ToPtr(true)
		}

		r, err := c.ClientIntentsQueryWithResponse(ctxTimeout, cloudapi.ClientIntentsQueryJSONRequestBody{
			ClusterIds:    filter.ClusterIds,
			Filter:        filter,
			LastSeenAfter: nil,
			FeatureFlags:  &featureFlags,
		})
		if err != nil {
			return err
		}

		outputLocation := viper.GetString(OutputLocationKey)
		outputType := viper.GetString(OutputTypeKey)
		withDiffComments := viper.GetBool(OutputWithDiffCommentsKey)

		writer := NewIntentsWriter(outputLocation, outputType, withDiffComments)

		return writer.WriteExportedIntents(lo.FromPtr(r.JSON200))
	},
}

Functions

This section is empty.

Types

type IntentsWriter added in v1.0.13

type IntentsWriter struct {
	OutputLocation   string
	OutputType       string
	WithDiffComments bool
}

func NewIntentsWriter added in v1.0.13

func NewIntentsWriter(outputLocation string, outputType string, withDiffComments bool) *IntentsWriter

func (*IntentsWriter) WriteExportedIntents added in v1.0.13

func (w *IntentsWriter) WriteExportedIntents(files []cloudapi.ClientIntentsFileRepresentation) error

Jump to

Keyboard shortcuts

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