updated file browser url logic
All checks were successful
Build and Push Docker Image / Build image (push) Successful in 1m40s
All checks were successful
Build and Push Docker Image / Build image (push) Successful in 1m40s
This commit is contained in:
@@ -3,6 +3,7 @@ package docker
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"maps"
|
||||
@@ -656,6 +657,14 @@ func (im *InstanceManager) StopFileBrowser(ctx context.Context, serverId string)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (im *InstanceManager) GetServerIdFromFileBrowserUrl(ctx context.Context, url string) (string, error) {
|
||||
pathSegments := strings.Split(url, "/")
|
||||
if len(pathSegments) < 3 {
|
||||
return "", errors.New("invalid url")
|
||||
}
|
||||
return pathSegments[2], nil
|
||||
}
|
||||
|
||||
func NewInstanceManager(config models.DockerInstanceManagerConfig, siteDomain string) (*InstanceManager, error) {
|
||||
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||
if err != nil {
|
||||
|
@@ -60,6 +60,7 @@ type InstanceManager interface {
|
||||
// Read Only
|
||||
GetFileBrowser(ctx context.Context, serverId string) (*models.FileBrowser, error)
|
||||
ListFileBrowsers(ctx context.Context) ([]models.FileBrowser, error)
|
||||
GetServerIdFromFileBrowserUrl(ctx context.Context, serverId string) (string, error)
|
||||
|
||||
// Status Changing
|
||||
StartFileBrowser(ctx context.Context, serverId string) (*models.FileBrowser, error)
|
||||
|
@@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
gerrors "errors"
|
||||
|
||||
"git.acooldomain.co/server-manager/backend/instancemanager"
|
||||
"git.acooldomain.co/server-manager/backend/models"
|
||||
servermanagerv1 "git.acooldomain.co/server-manager/kubernetes-operator/api/v1alpha1"
|
||||
@@ -355,6 +357,14 @@ func (i *InstanceManager) StopFileBrowser(ctx context.Context, serverId string)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (im *InstanceManager) GetServerIdFromFileBrowserUrl(ctx context.Context, url string) (string, error) {
|
||||
pathSegments := strings.Split(url, "/")
|
||||
if len(pathSegments) < 4 {
|
||||
return "", gerrors.New("invalid url")
|
||||
}
|
||||
return pathSegments[3], nil
|
||||
}
|
||||
|
||||
func NewInstanceManager(config models.KubernetesInstanceManagerConfig) (*InstanceManager, error) {
|
||||
c, err := rest.InClusterConfig()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user