You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If image is set, then the URL is also set and we have to download a remote file
205
+
ifimage.UseCustomImageURLCommand {
206
+
return"", false, "internal error: image.UseCustomImageURLCommand is active. Method GetDetails() should be used for the traditional way (without image-url-command)."
Copy file name to clipboardExpand all lines: main.go
+26-7Lines changed: 26 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,8 @@ var (
85
85
syncPeriod time.Duration
86
86
rateLimitWaitTime time.Duration
87
87
preProvisionCommandstring
88
-
imageURLCommandstring
88
+
hcloudImageURLCommandstring
89
+
baremetalImageURLCommandstring
89
90
skipWebhooksbool
90
91
sshAfterInstallImagebool
91
92
)
@@ -108,7 +109,8 @@ func main() {
108
109
fs.DurationVar(&rateLimitWaitTime, "rate-limit", 5*time.Minute, "The rate limiting for HCloud controller (e.g. 5m)")
109
110
fs.BoolVar(&hcloudclient.DebugAPICalls, "debug-hcloud-api-calls", false, "Debug all calls to the hcloud API.")
110
111
fs.StringVar(&preProvisionCommand, "pre-provision-command", "", "Command to run (in rescue-system) before installing the image on bare metal servers. You can use that to check if the machine is healthy before installing the image. If the exit value is non-zero, the machine is considered unhealthy. This command must be accessible by the controller pod. You can use an initContainer to copy the command to a shared emptyDir.")
111
-
fs.StringVar(&imageURLCommand, "hcloud-image-url-command", "", "Command to run (in rescue-system) to provision an hcloud machine. The command will get the imageURL, bootstrap-data and machine-name of the corresponding hcloudmachine as argument. It is up to the command to download from that URL and provision the disk accordingly. This command must be accessible by the controller pod. You can use an initContainer to copy the command to a shared emptyDir. The env var OCI_REGISTRY_AUTH_TOKEN from the caph process will be set for the command, too. The command must end with the last line containing IMAGE_URL_DONE. Otherwise the execution is considered to have failed. Docs: https://syself.com/docs/caph/developers/image-url-command")
112
+
fs.StringVar(&hcloudImageURLCommand, "hcloud-image-url-command", "", "Command to run (in rescue-system) to provision an hcloud machine. Docs: https://syself.com/docs/caph/developers/image-url-command")
113
+
fs.StringVar(&baremetalImageURLCommand, "baremetal-image-url-command", "", "Command to run (in rescue-system) to provision an baremetal machine. Docs: https://syself.com/docs/caph/developers/image-url-command")
112
114
fs.BoolVar(&skipWebhooks, "skip-webhooks", false, "Skip setting up of webhooks. Together with --leader-elect=false, you can use `go run main.go` to run CAPH in a cluster connected via KUBECONFIG. You should scale down the caph deployment to 0 before doing that. This is only for testing!")
113
115
fs.BoolVar(&sshAfterInstallImage, "baremetal-ssh-after-install-image", true, "Connect to the baremetal machine after install-image and ensure it is provisioned. Current default is true, but we might change that to false. Background: Users might not want the controller to be able to ssh onto the servers")
114
116
@@ -133,22 +135,38 @@ func main() {
133
135
}
134
136
}
135
137
136
-
// If ImageURLCommand is set, check if the file exists and validate the basename.
137
-
ifimageURLCommand!="" {
138
-
baseName:=filepath.Base(imageURLCommand)
138
+
// If hcloudImageURLCommand is set, check if the file exists and validate the basename.
139
+
ifhcloudImageURLCommand!="" {
140
+
baseName:=filepath.Base(hcloudImageURLCommand)
139
141
if!commandRegex.MatchString(baseName) {
140
142
msg:=fmt.Sprintf("basename (%s) must match the regex %s", baseName, commandRegex.String())
141
143
setupLog.Error(errors.New(msg), "")
142
144
os.Exit(1)
143
145
}
144
146
145
-
_, err:=os.Stat(imageURLCommand)
147
+
_, err:=os.Stat(hcloudImageURLCommand)
146
148
iferr!=nil {
147
149
setupLog.Error(err, "hcloud-image-url-command not found")
148
150
os.Exit(1)
149
151
}
150
152
}
151
153
154
+
// If baremetalImageURLCommand is set, check if the file exists and validate the basename.
155
+
ifbaremetalImageURLCommand!="" {
156
+
baseName:=filepath.Base(baremetalImageURLCommand)
157
+
if!commandRegex.MatchString(baseName) {
158
+
msg:=fmt.Sprintf("basename (%s) must match the regex %s", baseName, commandRegex.String())
159
+
setupLog.Error(errors.New(msg), "")
160
+
os.Exit(1)
161
+
}
162
+
163
+
_, err:=os.Stat(baremetalImageURLCommand)
164
+
iferr!=nil {
165
+
setupLog.Error(err, "baremetal-image-url-command not found")
0 commit comments