File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -84,20 +84,25 @@ func ParseReference(arg string) (*Reference, error) {
84
84
}
85
85
ret .Architecture = toks [1 ]
86
86
87
- // We try to optimize the search and help the user
87
+ // Now that we have the required informations in `ret` we can
88
+ // try to use core.GetPlatforms to optimize what the user typed
89
+ // (by replacing the PackageName and Architecture in ret with the content of core.GetPlatform())
88
90
platforms , _ := core .GetPlatforms (& rpc.PlatformListRequest {
89
91
Instance : instance .CreateAndInit (),
90
92
UpdatableOnly : false ,
91
- All : true ,
93
+ All : true , // this is true because we want also the installable platforms
92
94
})
95
+ var found = 0
93
96
for _ , platform := range platforms {
94
97
if strings .EqualFold (platform .GetId (), ret .PackageName + ":" + ret .Architecture ) {
95
98
toks = strings .Split (platform .GetId (), ":" )
96
- ret .PackageName = toks [0 ]
97
- ret .Architecture = toks [1 ]
98
- break // is it ok to stop at the first result?
99
+ found ++
99
100
}
100
101
}
101
-
102
+ // replace the returned Reference only if only one occurrence is found, otherwise leave it as is
103
+ if found == 1 {
104
+ ret .PackageName = toks [0 ]
105
+ ret .Architecture = toks [1 ]
106
+ }
102
107
return ret , nil
103
108
}
You can’t perform that action at this time.
0 commit comments