provider

package
v0.15.14 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BootstrapCommand = cli.Command{
	Name:        "bootstrap",
	Description: "Before you can deploy a Provider, you will need to bootstrap it. This process will copy the files from the Provider Registry to your bootstrap bucket.",
	Usage:       "Copy a Provider into your AWS account",
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "id", Required: true, Usage: "publisher/name@version"},
		&cli.BoolFlag{Name: "force", Usage: "force copy provider assets to bootstrap bucket"},
	},

	Action: func(c *cli.Context) error {
		ctx := c.Context

		registry, err := registryclient.New(ctx)
		if err != nil {
			return errors.Wrap(err, "configuring provider registry client")
		}

		id := c.String("id")

		provider, err := providerregistrysdk.ParseProvider(id)
		if err != nil {
			return err
		}

		res, err := registry.GetProviderWithResponse(ctx, provider.Publisher, provider.Name, provider.Version)
		if err != nil {
			return err
		}

		clio.Success("Provider exists in the registry")

		awsConfig, err := cfaws.ConfigFromContextOrDefault(ctx)
		if err != nil {
			return err
		}

		bs := bootstrapper.NewFromConfig(awsConfig)
		if err != nil {
			return err
		}

		clio.Info("Copying provider assets...")

		err = bs.CopyProviderFiles(ctx, *res.JSON200, bootstrapper.WithForceCopy(c.Bool("force")))
		if err != nil {
			return err
		}

		return nil
	},
}
View Source
var Command = cli.Command{
	Name:        "provider-v2",
	Description: "Explore and manage Providers from the Provider Registry",
	Usage:       "Explore and manage Providers from the Provider Registry",
	Subcommands: []*cli.Command{
		mw.WithBeforeFuncs(&BootstrapCommand, mw.RequireAWSCredentials()),
		&ListCommand,
		&generate.Command,
		mw.WithBeforeFuncs(&deployCommand, mw.RequireAWSCredentials()),
		mw.WithBeforeFuncs(&destroyCommand, mw.RequireAWSCredentials()),
	},
}
View Source
var ListCommand = cli.Command{
	Name:        "list",
	Aliases:     []string{"ls"},
	Description: "List providers",
	Usage:       "List providers",
	Action: func(c *cli.Context) error {
		ctx := c.Context
		registry, err := registryclient.New(ctx)
		if err != nil {
			return errors.Wrap(err, "configuring provider registry client")
		}

		res, err := registry.ListAllProvidersWithResponse(ctx, &providerregistrysdk.ListAllProvidersParams{
			WithDev: aws.Bool(false),
		})
		if err != nil {
			return err
		}
		tbl := table.New(os.Stderr)
		tbl.Columns("ID", "Name", "Publisher", "Version", "Kinds")
		for _, d := range res.JSON200.Providers {
			var kinds []string
			if d.Schema.Targets != nil {
				for kind := range *d.Schema.Targets {
					kinds = append(kinds, kind)
				}
			}
			tbl.Row(getProviderId(d.Publisher, d.Name, d.Version), d.Name, d.Publisher, d.Version, strings.Join(kinds, ", "))
		}
		return tbl.Flush()
	},
}

Functions

This section is empty.

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