Closed nxtcoder36 closed 7 hours ago
This pull request implements port exposure functionality for the Kloudlite CLI tool. It adds new commands to expose and sync ports, updates the proxy synchronization logic, and makes necessary adjustments to support these features.
sequenceDiagram
participant User
participant CLI as Kloudlite CLI
participant Docker
User->>CLI: Run expose port command
CLI->>CLI: Create file client
CLI->>CLI: Get current working directory
CLI->>CLI: Get Kloudlite config file
CLI->>CLI: Add ports to config file
CLI->>CLI: Write updated config file
CLI->>Docker: List existing proxy containers
alt Existing proxy with same port hash
CLI->>User: Return (no action needed)
else No existing proxy or different port hash
CLI->>Docker: Kill and remove existing proxy container
CLI->>Docker: Create new proxy container with exposed ports
CLI->>Docker: Start new proxy container
end
CLI->>User: Return success or error
classDiagram
class ProxyConfig {
+GetHash() string
+ExposedPorts []int
+TargetContainerPath string
}
class client {
+SyncProxy(config ProxyConfig) error
+Stop() error
+Restart() error
+Start() error
}
class KLFileType {
+EnvVars EnvVars
+Mounts Mounts
+Ports []int
+TeamName string
}
class fileclient {
+New() fileclient
+GetKlFile(path string) (KLFileType, error)
+WriteKLFile(file KLFileType) error
}
ProxyConfig --> client
KLFileType --> fileclient
Change | Details | Files |
---|---|---|
Implement port exposure functionality |
|
cmd/expose/port.go cmd/expose/sync.go cmd/expose/expose.go domain/fileclient/kl-file.go constants/main.go |
Uncomment and update SyncProxy function |
|
cmd/box/boxpkg/proxy.go cmd/box/boxpkg/main.go |
Update CLI command structure |
|
clis/kl/loadsubs.go cmd/status/status.go |
Minor code improvements and cleanup |
|
pkg/updater/main.go clis/kl/update.go |
Summary by Sourcery
Add a new 'expose' command to manage port exposure in the kl-config file, including functionality to add and sync ports. Refactor the SyncProxy function to utilize the command context for Docker operations, enhancing code clarity. Clean up code by removing redundant print statements.
New Features:
Enhancements:
Chores: