provider

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 31 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")

		awsContext, err := mw.AWSContextFromContext(ctx)
		if err != nil {
			return err
		}

		bs := bootstrapper.NewFromConfig(awsContext.Config)
		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",
	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,
		mw.WithBeforeFuncs(&installCommand, mw.RequireAWSCredentials()),
		mw.WithBeforeFuncs(&uninstallCommand, 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)
		if err != nil {
			return err
		}

		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"id", "name", "publisher", "version"})
		table.SetAutoWrapText(false)
		table.SetAutoFormatHeaders(true)
		table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
		table.SetAlignment(tablewriter.ALIGN_LEFT)
		table.SetCenterSeparator("")
		table.SetColumnSeparator("")
		table.SetRowSeparator("")
		table.SetHeaderLine(false)
		table.SetBorder(true)

		if res.JSON200 != nil {
			for _, d := range res.JSON200.Providers {

				table.Append([]string{
					getProviderId(d.Publisher, d.Name, d.Version), d.Name, d.Publisher, d.Version,
				})
			}
		}

		table.Render()

		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