From 3412d1f8b9e0ad1ee58920ee26b3d4cc3fc391c1 Mon Sep 17 00:00:00 2001 From: Ginder Singh Date: Wed, 20 Aug 2025 14:33:47 -0400 Subject: [PATCH] start mobile library with provision id and custom hostname. --- cmd/cli/cli.go | 10 +++++++++- cmd/cli/library.go | 12 +++++++----- cmd/ctrld_library/main.go | 14 ++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index 584e2ee..06dffcb 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -182,7 +182,15 @@ func RunMobile(appConfig *AppConfig, appCallback *AppCallback, stopCh chan struc noConfigStart = false homedir = appConfig.HomeDir verbose = appConfig.Verbose - cdUID = appConfig.CdUID + if appConfig.ProvisionID != "" { + cdOrg = appConfig.ProvisionID + } + if appConfig.CustomHostname != "" { + customHostname = appConfig.CustomHostname + } + if appConfig.CdUID != "" { + cdUID = appConfig.CdUID + } cdUpstreamProto = appConfig.UpstreamProto logPath = appConfig.LogPath run(appCallback, stopCh) diff --git a/cmd/cli/library.go b/cmd/cli/library.go index d6bc9fd..649471b 100644 --- a/cmd/cli/library.go +++ b/cmd/cli/library.go @@ -20,11 +20,13 @@ type AppCallback struct { // AppConfig allows overwriting ctrld cli flags from mobile platforms. // This provides a clean interface for mobile apps to configure ctrld behavior type AppConfig struct { - CdUID string - HomeDir string - UpstreamProto string - Verbose int - LogPath string + CdUID string + ProvisionID string + CustomHostname string + HomeDir string + UpstreamProto string + Verbose int + LogPath string } // Network and HTTP configuration constants diff --git a/cmd/ctrld_library/main.go b/cmd/ctrld_library/main.go index e9cf450..6713568 100644 --- a/cmd/ctrld_library/main.go +++ b/cmd/ctrld_library/main.go @@ -28,15 +28,17 @@ type AppCallback interface { // Start configures utility with config.toml from provided directory. // This function will block until Stop is called // Check port availability prior to calling it. -func (c *Controller) Start(CdUID string, HomeDir string, UpstreamProto string, logLevel int, logPath string) { +func (c *Controller) Start(CdUID string, ProvisionID string, CustomHostname string, HomeDir string, UpstreamProto string, logLevel int, logPath string) { if c.stopCh == nil { c.stopCh = make(chan struct{}) c.Config = cli.AppConfig{ - CdUID: CdUID, - HomeDir: HomeDir, - UpstreamProto: UpstreamProto, - Verbose: logLevel, - LogPath: logPath, + CdUID: CdUID, + ProvisionID: ProvisionID, + CustomHostname: CustomHostname, + HomeDir: HomeDir, + UpstreamProto: UpstreamProto, + Verbose: logLevel, + LogPath: logPath, } appCallback := mapCallback(c.AppCallback) cli.RunMobile(&c.Config, &appCallback, c.stopCh)