forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.go
37 lines (31 loc) · 1023 Bytes
/
import.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package clusterregistrationtokens
import (
"net/http"
"github.com/gorilla/mux"
"github.com/rancher/norman/types"
"github.com/rancher/norman/urlbuilder"
"github.com/rancher/rancher/pkg/image"
"github.com/rancher/rancher/pkg/settings"
"github.com/rancher/rancher/pkg/systemtemplate"
"github.com/rancher/types/apis/management.cattle.io/v3/schema"
)
func ClusterImportHandler(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("Content-Type", "text/plain")
token := mux.Vars(req)["token"]
urlBuilder, err := urlbuilder.New(req, schema.Version, types.NewSchemas())
if err != nil {
resp.WriteHeader(500)
resp.Write([]byte(err.Error()))
return
}
url := urlBuilder.RelativeToRoot("")
authImage := ""
authImages := req.URL.Query()["authImage"]
if len(authImages) > 0 {
authImage = authImages[0]
}
if err := systemtemplate.SystemTemplate(resp, image.Resolve(settings.AgentImage.Get()), authImage, token, url); err != nil {
resp.WriteHeader(500)
resp.Write([]byte(err.Error()))
}
}