Skip to content

Commit

Permalink
Allow multiple versions with the same tag
Browse files Browse the repository at this point in the history
Signed-off-by: phanle1010 <phan.le@suse.com>
  • Loading branch information
PhanLe1010 authored and yasker committed Sep 18, 2021
1 parent cfe11c1 commit 35e21e6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions upgraderesponder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ var (
)

type Server struct {
done chan struct{}
VersionMap map[string]*Version
TagVersionMap map[string]*Version
influxClient influxcli.Client
db *maxminddb.Reader
done chan struct{}
VersionMap map[string]*Version
TagVersionsMap map[string][]*Version
influxClient influxcli.Client
db *maxminddb.Reader
}

type Location struct {
Expand Down Expand Up @@ -87,9 +87,9 @@ func NewServer(done chan struct{}, configFile, influxURL, influxUser, influxPass
return nil, err
}
s := &Server{
done: done,
VersionMap: map[string]*Version{},
TagVersionMap: map[string]*Version{},
done: done,
VersionMap: map[string]*Version{},
TagVersionsMap: map[string][]*Version{},
}
if err := s.validateAndLoadResponseConfig(&config); err != nil {
return nil, err
Expand Down Expand Up @@ -176,14 +176,11 @@ func (s *Server) validateAndLoadResponseConfig(config *ResponseConfig) error {
return err
}
for _, l := range v.Tags {
if s.TagVersionMap[l] != nil {
return fmt.Errorf("invalid duplicate label %v", l)
}
s.TagVersionMap[l] = &config.Versions[i]
s.TagVersionsMap[l] = append(s.TagVersionsMap[l], &config.Versions[i])
}
s.VersionMap[v.Name] = &config.Versions[i]
}
if s.TagVersionMap[VersionTagLatest] == nil {
if len(s.TagVersionsMap[VersionTagLatest]) == 0 {
return fmt.Errorf("no latest label specified")
}
return nil
Expand Down

0 comments on commit 35e21e6

Please sign in to comment.