Closed nxtcoder36 closed 1 week ago
This pull request implements several refactoring changes across multiple files, focusing on improving the cluster management, connection handling, and overall code structure. The changes include updates to the API client, modifications to the K3s implementation, enhancements to the command-line interface, and adjustments to the build process.
sequenceDiagram
participant Cmd
participant FC as FileClient
participant K3sTracker
participant EnvClient
participant Connect
Cmd->>FC: GetK3sTracker()
alt Error
Cmd->>Cmd: Log error
Cmd->>Cmd: Return
end
Cmd->>K3sTracker: Check Compute and Gateway
alt Compute and Gateway are true
Cmd->>Cmd: Log "Running: true"
else
Cmd->>Cmd: Log "Running: false"
end
Cmd->>K3sTracker: Check Compute
alt Compute is true
Cmd->>Cmd: Log "Local Cluster: ready"
else
Cmd->>Cmd: Log "Local Cluster: getting ready"
end
Cmd->>K3sTracker: Check Gateway
alt Gateway is true
Cmd->>Cmd: Log "Edge Gateway Connection: online"
else
Cmd->>Cmd: Log "Edge Gateway Connection: offline"
end
Cmd->>EnvClient: InsideBox()
alt InsideBox is true
Cmd->>Connect: Check Wireguard Connection
alt Connection is true
Cmd->>Cmd: Log "Edge Connection: online"
else
Cmd->>Cmd: Log "Edge Connection: offline"
end
end
sequenceDiagram
participant Cmd
participant K3sClient
participant EnvClient
Cmd->>K3sClient: NewClient()
alt Error
Cmd->>Cmd: PrintError
Cmd->>Cmd: Return
end
Cmd->>K3sClient: CheckK3sRunningLocally()
alt Not Running
Cmd->>Cmd: Return
end
Cmd->>EnvClient: InsideBox()
alt Not InsideBox
Cmd->>K3sClient: RestartWgProxyContainer()
alt Error
Cmd->>Cmd: PrintError
Cmd->>Cmd: Return
end
end
Cmd->>Cmd: ExecNoOutput("wg-quick down kl-vpn")
Cmd->>K3sClient: RestartWgProxyContainer()
Cmd->>Cmd: ExecNoOutput("wg-quick up kl-workspace-wg")
Cmd->>Cmd: ExecNoOutput("wg-quick up kl-vpn")
Cmd->>Cmd: Sleep(1 second)
Cmd->>Cmd: Open "/tmp/kl/online.status"
classDiagram
class Cluster {
+string DisplayName
+string ClusterToken
+string Name
+time.Time LastOnlineAt
+InstallCommand InstallCommand
+map Metadata
}
class BYOKCluster {
+string DisplayName
+Metadata Metadata
}
class InstallCommand {
+map Metadata
}
Cluster --> InstallCommand
Cluster --> Metadata
BYOKCluster --> Metadata
Change | Details | Files |
---|---|---|
Refactoring of cluster management and API client |
|
domain/apiclient/clusters.go domain/apiclient/k3s-local.go domain/apiclient/impl.go cmd/clone/env.go |
Enhancements to the command-line interface |
|
cmd/status/status.go cmd/connect/connect.go |
Updates to K3s implementation and container management |
|
k3s/impl.go k3s/main.go cmd/connect/connect.go |
Build process and versioning updates |
|
k3s/k3s-base/Runfile.yml constants/main.go |
Summary by Sourcery
Refactor cluster management functions to improve cluster selection and status logging. Enhance the WireGuard connection process by checking local K3s status before execution. Update Docker build tasks to support version tagging and pushing.
Enhancements:
ListBYOKClusters
function to useGetClustersOfTeam
for retrieving clusters, improving the cluster selection process.getK3sStatus
function to include more detailed logging of cluster and gateway status.startWg
function to check if K3s is running locally before proceeding with WireGuard operations.CheckK3sRunningLocally
to the K3s client to verify the local running status of K3s containers.Build:
container:push
task with preconditions for tagging.