-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.go
31 lines (26 loc) · 893 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
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("")
if err := systemtemplate.SystemTemplate(resp, image.Resolve(settings.AgentImage.Get()), token, url); err != nil {
resp.WriteHeader(500)
resp.Write([]byte(err.Error()))
}
}