Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4ea2b8

Browse filesBrowse files
authored
Fix #115: cmk ignores the CLI profile arg when loading the cache file (#131)
* Fix problem 1 on issue #115 * Improvements
1 parent 74698cd commit c4ea2b8
Copy full SHA for c4ea2b8

3 files changed

+8-8Lines changed: 8 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cmk.go‎

Copy file name to clipboardExpand all lines: cmk.go
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func main() {
8686
if *profile != "" {
8787
cfg.LoadProfile(*profile)
8888
}
89+
config.LoadCache(cfg)
8990

9091
if *apiKey != "" && *secretKey != "" {
9192
request := cmd.NewRequest(nil, cfg, nil)
Collapse file

‎config/cache.go‎

Copy file name to clipboardExpand all lines: config/cache.go
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ func LoadCache(c *Config) interface{} {
8484
Debug("Trying to read API cache from:", cacheFile)
8585
cache, err := ioutil.ReadFile(cacheFile)
8686
if err != nil {
87-
if c.HasShell {
88-
fmt.Fprintf(os.Stderr, "Loaded in-built API cache. Failed to read API cache, please run 'sync'.\n")
89-
}
87+
fmt.Fprintf(os.Stderr, "Loaded in-built API cache. Failed to read API cache, please run 'sync'.\n")
9088
cache = []byte(preCache)
9189
}
9290
var data map[string]interface{}
Collapse file

‎config/config.go‎

Copy file name to clipboardExpand all lines: config/config.go
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func setActiveProfile(cfg *Config, profile *ServerProfile) {
200200
cfg.ActiveProfile.Client = newHTTPClient(cfg)
201201
}
202202

203-
func reloadConfig(cfg *Config) *Config {
203+
func reloadConfig(cfg *Config, loadCache bool) *Config {
204204
fileLock := flock.New(path.Join(getDefaultConfigDir(), "lock"))
205205
err := fileLock.Lock()
206206
if err != nil {
@@ -209,7 +209,9 @@ func reloadConfig(cfg *Config) *Config {
209209
}
210210
cfg = saveConfig(cfg)
211211
fileLock.Unlock()
212-
LoadCache(cfg)
212+
if loadCache {
213+
LoadCache(cfg)
214+
}
213215
return cfg
214216
}
215217

@@ -360,7 +362,7 @@ func (c *Config) UpdateConfig(key string, value string, update bool) {
360362
Debug("UpdateConfig key:", key, " value:", value, " update:", update)
361363

362364
if update {
363-
reloadConfig(c)
365+
reloadConfig(c, true)
364366
}
365367
}
366368

@@ -376,7 +378,6 @@ func NewConfig(configFilePath *string) *Config {
376378
os.Exit(1)
377379
}
378380
}
379-
cfg := reloadConfig(defaultConf)
380-
LoadCache(cfg)
381+
cfg := reloadConfig(defaultConf, false)
381382
return cfg
382383
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.