| 46 | } |
| 47 | |
| 48 | func PromptForMachinePolicy(opts *CreateTargetMachinePolicyOptions, flags *CreateTargetMachinePolicyFlags) error { |
| 49 | if flags.MachinePolicy.Value == "" { |
| 50 | selectedOption, err := selectors.Select(opts.Ask, "Select the machine policy to use", opts.GetAllMachinePoliciesCallback, func(p *machines.MachinePolicy) string { return p.Name }) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | flags.MachinePolicy.Value = selectedOption.Name |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | func getAllMachinePolicies(client client.Client) ([]*machines.MachinePolicy, error) { |
| 62 | res, err := client.MachinePolicies.GetAll() |