Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ListCmd = base.ListCmd{ ResourceNamePlural: "SSH keys", JSONKeyGetByName: "ssh_keys", DefaultColumns: []string{"id", "name", "fingerprint", "age"}, Fetch: func(ctx context.Context, client hcapi2.Client, _ *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) { opts := hcloud.SSHKeyListOpts{ListOpts: listOpts} if len(sorts) > 0 { opts.Sort = sorts } sshKeys, err := client.SSHKey().AllWithOpts(ctx, opts) var resources []interface{} for _, n := range sshKeys { resources = append(resources, n) } return resources, err }, OutputTable: func(_ hcapi2.Client) *output.Table { return output.NewTable(). AddAllowedFields(hcloud.SSHKey{}). AddFieldFn("labels", output.FieldFn(func(obj interface{}) string { sshKey := obj.(*hcloud.SSHKey) return util.LabelsToString(sshKey.Labels) })). AddFieldFn("created", output.FieldFn(func(obj interface{}) string { sshKey := obj.(*hcloud.SSHKey) return util.Datetime(sshKey.Created) })). AddFieldFn("age", output.FieldFn(func(obj interface{}) string { sshKey := obj.(*hcloud.SSHKey) return util.Age(sshKey.Created, time.Now()) })) }, JSONSchema: func(resources []interface{}) interface{} { sshKeySchemas := make([]schema.SSHKey, 0, len(resources)) for _, resource := range resources { sshKey := resource.(*hcloud.SSHKey) sshKeySchema := schema.SSHKey{ ID: sshKey.ID, Name: sshKey.Name, Fingerprint: sshKey.Fingerprint, PublicKey: sshKey.PublicKey, Labels: sshKey.Labels, Created: sshKey.Created, } sshKeySchemas = append(sshKeySchemas, sshKeySchema) } return sshKeySchemas }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.