Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Refactor logic around version extraction to be a little clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Jul 28, 2019
1 parent 967d654 commit 75bc69c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/legacy/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ func ImportExistingEtcd(baseDir string, etcdNodeConfiguration *protoetcd.EtcdNod
// Extract version from image
{
tokens := strings.Split(etcdContainer.Image, ":")
if len(tokens) != 2 && len(tokens) != 3 {
if len(tokens) == 2 {
state.EtcdVersion = tokens[1]
} else if len(tokens) == 3 {
// This is valid when pulling from proxies/mirrors with ports
// localhost:8000/etcd:3.3.3
state.EtcdVersion = tokens[2]
} else {
return nil, fmt.Errorf("unexpected etcd image %q", etcdContainer.Image)
}
state.EtcdVersion = tokens[1]
}

etcdName := strings.TrimSpace(etcdContainer.FindEnv("ETCD_NAME"))
Expand Down

0 comments on commit 75bc69c

Please sign in to comment.