Skip to content

Commit

Permalink
adc: better version detection for flexhub
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Mar 17, 2019
1 parent ead8866 commit e4958a5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions adc/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ func Ping(ctx context.Context, addr string, conf PingConfig) (*PingHubInfo, erro
return nil, err
}

fixVersion := func() {
if hub.Application != "" {
return
}
if strings.HasPrefix(hub.Version, "FlexHub") {
i := strings.LastIndex(hub.Version, "Beta ")
if i > 0 {
i += 4
} else {
i = strings.LastIndex(hub.Version, " ")
}
if i > 0 {
hub.Application, hub.Version = hub.Version[:i], hub.Version[i+1:]
}
}
}

// next, we expect a INF from the hub
const (
hubInfo = iota
Expand Down Expand Up @@ -165,6 +182,7 @@ func Ping(ctx context.Context, addr string, conf PingConfig) (*PingHubInfo, erro
if err := Unmarshal(cmd.Data, &hub.HubInfo); err != nil {
return &hub, err
}
fixVersion()
stage = optStatus
case optStatus:
// optionally wait for status command
Expand Down Expand Up @@ -225,11 +243,7 @@ func Ping(ctx context.Context, addr string, conf PingConfig) (*PingHubInfo, erro
if strings.HasPrefix(u.Version, "FlexHub") {
hub.Version = u.Version
hub.Application = u.Application
if hub.Application == "" {
if i := strings.LastIndex(hub.Version, " "); i > 0 {
hub.Application, hub.Version = hub.Version[:i], hub.Version[i+1:]
}
}
fixVersion()
continue
}
}
Expand Down

0 comments on commit e4958a5

Please sign in to comment.