| | |
| | | "strings" |
| | | |
| | | "basic.com/aps/aps_deploy.git/src/util" |
| | | "basic.com/aps/aps_deploy.git/src/rancher" |
| | | ) |
| | | |
| | | type Cluster struct { |
| | |
| | | |
| | | req, err := http.NewRequest("GET", url, nil) |
| | | if err != nil { |
| | | return "", fmt.Errorf("failed to create cluster list request: %v", err) |
| | | return "", fmt.Errorf("failed to get cluster list request: %v", err) |
| | | } |
| | | |
| | | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", bearerToken)) |
| | |
| | | SSHPort int `json:"sshPort"` |
| | | } |
| | | |
| | | type RancherConfig struct { |
| | | RancherURL string `json:"rancherURL"` |
| | | BearerToken string `json:"bearerToken"` |
| | | } |
| | | |
| | | type ClusterCreateRequest struct { |
| | | Name string `json:"name"` |
| | |
| | | return true, nil |
| | | } |
| | | |
| | | func CreateCluster(rancherConfig RancherConfig, clusterName string) error { |
| | | func CreateCluster(rancherClusterConfig rancher.RancherClusterConfig, clusterName string) error { |
| | | requestBody := createClusterData(clusterName) |
| | | fmt.Println(rancherClusterConfig.RancherURL) |
| | | |
| | | url := fmt.Sprintf("%s/v3/clusters", rancherConfig.RancherURL) |
| | | url := fmt.Sprintf("%s/v3/clusters", rancherClusterConfig.RancherURL) |
| | | req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody)) |
| | | if err != nil { |
| | | return fmt.Errorf("Failed to create HTTP request: %v", err) |
| | | } |
| | | |
| | | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", rancherConfig.BearerToken)) |
| | | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", rancherClusterConfig.BearerToken)) |
| | | req.Header.Set("Content-Type", "application/json") |
| | | |
| | | client := util.CreateHTTPClient() |