nodelist

package
v0.1.65 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeListCmd = &cobra.Command{
	Use:   "nodelist [nodes.json]",
	Short: "Generate a node list to seed a node",
	Args:  cobra.MinimumNArgs(1),
	PreRunE: func(cmd *cobra.Command, args []string) (err error) {
		inputNodeListParams.OutputFile = args[0]
		inputNodeListParams.ProjectID, err = cmd.Flags().GetString("project-id")
		return err
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := cmd.Context()

		db := database.NewDatastore(cmd.Context(), database.DatastoreOptions{
			ProjectID: inputNodeListParams.ProjectID,
		})

		nodes, err := db.NodeList(ctx, inputNodeListParams.Limit)
		if err != nil {
			return err
		}

		bytes, err := json.MarshalIndent(nodes, "", jsonIndent)
		if err != nil {
			return err
		}

		if err = os.WriteFile(inputNodeListParams.OutputFile, bytes, 0644); err != nil {
			return err
		}

		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