Help us shape the future of Go! Take the 2026 Go Developer Survey

cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SchemaListCmd = &cobra.Command{
	Use:          "list",
	Short:        "list available schemas",
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error
		var c *config.Config
		var cd *configdiff.ConfigDiff

		ctx := cmd.Context()

		opts := config.ConfigOpts{}
		c, err = config.NewConfig(opts...)
		if err != nil {
			return err
		}

		cd, err = configdiff.NewConfigDiff(ctx, c)
		if err != nil {
			return err
		}

		schemas, err := cd.SchemasList(ctx)
		if err != nil {
			return err
		}

		outputSchemas := output.NewSchemaOutputList(schemas)

		err = WriteOutput(ctx, outputSchemas)
		if err != nil {
			return err
		}

		return nil

	},
}

SchemaListCmd represents the list command

View Source
var SchemaLoadCmd = &cobra.Command{
	Use:          "load",
	Short:        "load a schema",
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error

		ctx := cmd.Context()

		rawParam := rawparams.NewSchemaLoadConfigRaw()
		rawParam.SetFile(schemaDefinitionFile)

		if rpcOutput {
			return pipeline.PipelineAppendStep(os.Stdout, rawParam)
		}

		opts := config.ConfigOpts{

			config.WithSchemaPathCleanup(schemaPathCleanup),
		}
		optsP = append(optsP, config.WithTargetName(targetName))

		out, err := RunFromRaw(ctx, opts, optsP, true, rawParam)
		if err != nil {
			return err
		}
		err = WriteOutput(ctx, out)
		if err != nil {
			return err
		}
		return nil
	},
}

SchemaLoadCmd represents the list command

View Source
var SchemaRemoveCmd = &cobra.Command{
	Use:          "remove",
	Short:        "remove a certain schema",
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error

		ctx := cmd.Context()

		opts := config.ConfigOpts{}
		c, err := config.NewConfigPersistent(opts, optsP)
		if err != nil {
			return err
		}

		log.Infof("Schema Remove")
		cd, err := configdiff.NewConfigDiffPersistence(ctx, c)
		if err != nil {
			return err
		}

		if schemaDefinitionFile != "" {
			schema, err := utils.GetSchemaConfig(schemaDefinitionFile)
			if err != nil {
				return err
			}
			schemaVendor = schema.Spec.Provider
			schemaVersion = schema.Spec.Version
		}

		err = cd.SchemaRemove(ctx, schemaVendor, schemaVersion)
		if err != nil {
			return err
		}
		log.Infof("Schema Vendor: %s, Version: %s - Removed Successful", schemaVendor, schemaVersion)
		return nil
	},
}

SchemaListCmd represents the list command

Functions

func AddDetailedFlag

func AddDetailedFlag(c *cobra.Command) error

func AddPathPersistentFlag

func AddPathPersistentFlag(c *cobra.Command) error

func AddRpcOutputFlag

func AddRpcOutputFlag(c *cobra.Command) error

func AddTargetPersistentFlag

func AddTargetPersistentFlag(c *cobra.Command) error

func ConvertSDCConfigToInternalIntent

func ConvertSDCConfigToInternalIntent(ctx context.Context, cd *configdiff.ConfigDiff, sdcConfig *v1alpha1.Config) (*rawparams.ConfigLoadRaw, error)

func EmitBashCompletionWithWordbreakMods

func EmitBashCompletionWithWordbreakMods(root *cobra.Command, out io.Writer) error

EmitBashCompletionWithWordbreakMods writes a bash completion script for root to out, but replaces the registration so a wrapper is used which temporarily modifies COMP_WORDBREAKS.

  • `adds` is a slice of single-character strings to append to COMP_WORDBREAKS if not already present (e.g. []string{"/", ":"}).
  • `removes` is a slice of single-character strings to remove from COMP_WORDBREAKS while completing (e.g. []string{"=", "[", "]", "/"}).

The wrapper restores the original COMP_WORDBREAKS after the underlying completion function returns.

func EnableFlagAndDisableFileCompletion

func EnableFlagAndDisableFileCompletion(cmd *cobra.Command)

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately.

func LoadSDCConfigCR

func LoadSDCConfigCR(configByte []byte) (*v1alpha1.Config, error)

func RunFromRaw

func RunFromRaw(ctx context.Context, opts config.ConfigOpts, optsP config.ConfigPersistentOpts, persist bool, rpcParams ...rpc.RpcRawParams) (interfaces.Output, error)

func WriteOutput

func WriteOutput(ctx context.Context, o interfaces.Output) (err error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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