(opts *CreateOptions)
| 86 | } |
| 87 | |
| 88 | func createRun(opts *CreateOptions) error { |
| 89 | if !opts.NoPrompt { |
| 90 | if err := PromptMissing(opts); err != nil { |
| 91 | return err |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | account, err := machinescommon.GetSshAccount(opts.SshCommonOptions, opts.SshCommonFlags) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | |
| 100 | port := opts.Port.Value |
| 101 | if port == 0 { |
| 102 | port = machinescommon.DefaultPort |
| 103 | } |
| 104 | endpoint := machines.NewSSHEndpoint(opts.HostName.Value, port, opts.Fingerprint.Value) |
| 105 | endpoint.AccountID = account.GetID() |
| 106 | |
| 107 | if opts.Runtime.Value == machinescommon.SelfContainedCalamari { |
| 108 | endpoint.DotNetCorePlatform = opts.Platform.Value |
| 109 | } |
| 110 | |
| 111 | if opts.Proxy.Value != "" { |
| 112 | proxy, err := machinescommon.FindProxy(opts.CreateTargetProxyOptions, opts.CreateTargetProxyFlags) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | endpoint.ProxyID = proxy.GetID() |
| 117 | } |
| 118 | |
| 119 | workerPoolIds, err := shared.FindWorkerPoolIds(opts.WorkerPoolOptions, opts.WorkerPoolFlags) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | |
| 124 | worker := machines.NewWorker(opts.Name.Value, endpoint) |
| 125 | worker.WorkerPoolIDs = workerPoolIds |
| 126 | machinePolicy, err := machinescommon.FindMachinePolicy(opts.GetAllMachinePoliciesCallback, opts.MachinePolicy.Value) |
| 127 | if err != nil { |
| 128 | return err |
| 129 | } |
| 130 | worker.MachinePolicyID = machinePolicy.GetID() |
| 131 | |
| 132 | createdWorker, err := opts.Client.Workers.Add(worker) |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | |
| 137 | fmt.Fprintf(opts.Out, "Successfully created SSH worker '%s'.\n", createdWorker.Name) |
| 138 | if !opts.NoPrompt { |
| 139 | autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.HostName, opts.Port, opts.Fingerprint, opts.Runtime, opts.Platform, opts.WorkerPools, opts.Account, opts.Proxy, opts.MachinePolicy) |
| 140 | fmt.Fprintf(opts.Out, "\nAutomation Command: %s\n", autoCmd) |
| 141 | } |
| 142 | |
| 143 | machinescommon.DoWebForWorkers(createdWorker, opts.Dependencies, opts.WebFlags, "ssh") |
| 144 | |
| 145 | return nil |
no test coverage detected