Adds region support as requested in #12 #13
+33
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces greater configurability and flexibility to the API endpoint and country selection logic throughout the CLI tool. The most significant changes are the introduction of environment variable overrides for the Vicohome API base URL and country code, and the refactoring of all HTTP requests to use these dynamic values. This makes the CLI more adaptable to different environments or regions without requiring code changes.
Configurability improvements:
Added a
GetBaseURL()function inpkg/auth/auth.go,cmd/devices/root.go, andcmd/events/root.goto allow the API base URL to be set via theVICOHOME_BASE_URLenvironment variable, defaulting to"https://api-us.vicohome.io"if not set. All HTTP requests in device and event commands now use this function to construct their URLs. [1] [2] [3] [4] [5] [6] [7] [8]Added a
GetCountry()function incmd/devices/list.goto allow the country code to be set via theVICOHOME_COUNTRYenvironment variable, defaulting to"US"if not set. The device list request now uses this function for theCountryNoparameter.Dependency and import updates:
ospackage imports in files where environment variable access is required. [1] [2] [3]These changes make the CLI more robust for multi-region or custom deployments and improve maintainability by centralizing configuration logic.