iso

package
v1.65.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DescribeCmd = base.DescribeCmd[*hcloud.ISO]{
	ResourceNameSingular: "ISO",
	ShortDescription:     "Describe an ISO",
	NameSuggestions:      func(c hcapi2.Client) func() []string { return c.ISO().Names },
	Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.ISO, any, error) {
		iso, _, err := s.Client().ISO().Get(s, idOrName)
		if err != nil {
			return nil, nil, err
		}
		return iso, hcloud.SchemaFromISO(iso), nil
	},
	PrintText: func(_ state.State, _ *cobra.Command, out io.Writer, iso *hcloud.ISO) error {
		fmt.Fprint(out, DescribeISO(iso))
		return nil
	},
}

DescribeCmd defines a command for describing a iso.

View Source
var ListCmd = &base.ListCmd[*hcloud.ISO, schema.ISO]{
	ResourceNamePlural: "ISOs",
	JSONKeyGetByName:   "isos",
	DefaultColumns:     []string{"id", "name", "description", "type", "architecture"},
	SortOption:         nil,

	AdditionalFlags: func(cmd *cobra.Command) {
		cmd.Flags().StringSlice("architecture", []string{}, "Only show Images of given architecture: x86|arm")
		_ = cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))

		cmd.Flags().Bool("include-architecture-wildcard", false, "Include ISOs with unknown architecture, only required if you want so show custom ISOs and still filter for architecture. (true, false)")

		cmd.Flags().StringSlice("type", []string{"public", "private"}, "Types to include (public, private)")
		_ = cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("public", "private"))
	},

	Fetch: func(s state.State, flags *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]*hcloud.ISO, error) {
		opts := hcloud.ISOListOpts{ListOpts: listOpts}

		types, _ := flags.GetStringSlice("type")

		var unknown []string
		for _, t := range types {
			switch t {
			case string(hcloud.ISOTypePublic), string(hcloud.ISOTypePrivate):
			default:
				unknown = append(unknown, t)
			}
		}
		if len(unknown) > 0 {
			return nil, fmt.Errorf("unknown ISO types %s", strings.Join(unknown, ", "))
		}

		architecture, _ := flags.GetStringSlice("architecture")
		if len(architecture) > 0 {
			for _, arch := range architecture {
				opts.Architecture = append(opts.Architecture, hcloud.Architecture(arch))
			}
		}

		includeArchitectureWildcard, _ := flags.GetBool("include-architecture-wildcard")
		if includeArchitectureWildcard {
			opts.IncludeArchitectureWildcard = includeArchitectureWildcard
		}

		if len(sorts) > 0 {
			opts.Sort = sorts
		}

		isos, err := s.Client().ISO().AllWithOpts(s, opts)
		if err != nil {
			return nil, err
		}

		var filtered []*hcloud.ISO
		for _, iso := range isos {
			if slices.Contains(types, string(iso.Type)) {
				filtered = append(filtered, iso)
			}
		}
		return filtered, nil
	},

	OutputTable: func(t *output.Table[*hcloud.ISO], _ hcapi2.Client) {
		t.
			AddAllowedFields(&hcloud.ISO{}).
			AddFieldFn("architecture", func(iso *hcloud.ISO) string {
				if iso.Architecture == nil {
					return "-"
				}
				return string(*iso.Architecture)
			})
	},

	Schema: hcloud.SchemaFromISO,
}

Functions

func DescribeISO added in v1.56.0

func DescribeISO(iso *hcloud.ISO) string

func NewCommand

func NewCommand(s state.State) *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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