get

package
v0.0.0-...-1ca99b1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetAccessGraph = &cobra.Command{
	Use:          "get",
	Short:        "Get access graph",
	SilenceUsage: true,
	Args:         cobra.NoArgs,
	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 := cloudapi.InputAccessGraphFilter{
			IncludeServicesWithNoEdges: lo.ToPtr(true),
			ClusterIds:                 lo.Ternary(viper.IsSet(clustersIdsKey), lo.ToPtr(viper.GetStringSlice(clustersIdsKey)), nil),
			EnvironmentIds:             lo.Ternary(viper.IsSet(envIdsKey), lo.ToPtr(viper.GetStringSlice(envIdsKey)), nil),
			NamespaceIds:               lo.Ternary(viper.IsSet(namespacesIdsKey), lo.ToPtr(viper.GetStringSlice(namespacesIdsKey)), nil),
			ServiceIds:                 lo.Ternary(viper.IsSet(servicesIdsKey), lo.ToPtr(viper.GetStringSlice(servicesIdsKey)), nil),
		}

		if viper.IsSet(lastSeenAfterKey) {
			lastSeenAfterStr := viper.GetString(lastSeenAfterKey)
			lastSeenAfter, err := time.Parse(time.RFC3339, lastSeenAfterStr)
			if err != nil {
				return fmt.Errorf("invalid last seen after format: %s", err)
			}
			filter.LastSeenAfter = &lastSeenAfter
		}

		r, err := c.AccessGraphQueryWithResponse(ctxTimeout, cloudapi.AccessGraphQueryJSONRequestBody{Filter: &filter})
		if err != nil {
			return err
		}

		output.FormatAccessGraph(lo.FromPtr(r.JSON200))
		return nil
	},
}

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