5
5
"encoding/base64"
6
6
"encoding/json"
7
7
"fmt"
8
- "github.com/intelops/kubviz/constants"
9
8
"log"
10
9
"os"
11
10
"regexp"
@@ -15,10 +14,12 @@ import (
15
14
"sync"
16
15
"time"
17
16
17
+ "github.com/intelops/kubviz/constants"
18
+
18
19
"github.com/intelops/kubviz/model"
19
20
"github.com/nats-io/nats.go"
20
21
21
- "github.com/docker/docker/api/types"
22
+ types "github.com/docker/docker/api/types/registry "
22
23
"github.com/genuinetools/reg/registry"
23
24
semver "github.com/hashicorp/go-version"
24
25
"github.com/pkg/errors"
@@ -137,7 +138,7 @@ func ParseImageName(imageName string) (string, string, string, error) {
137
138
matches := dockerImageNameRegex .FindStringSubmatch (imageName )
138
139
139
140
if len (matches ) != 5 {
140
- return "" , "" , "" , fmt .Errorf ("Expected 5 matches in regex, but found %d" , len (matches ))
141
+ return "" , "" , "" , fmt .Errorf ("expected 5 matches in regex, but found %d" , len (matches ))
141
142
}
142
143
143
144
hostname := matches [1 ]
@@ -184,9 +185,7 @@ func ListImages(config *rest.Config) ([]model.RunningImage, error) {
184
185
for _ , pod := range pods .Items {
185
186
for _ , initContainerStatus := range pod .Status .InitContainerStatuses {
186
187
pullable := initContainerStatus .ImageID
187
- if strings .HasPrefix (pullable , "docker-pullable://" ) {
188
- pullable = strings .TrimPrefix (pullable , "docker-pullable://" )
189
- }
188
+ pullable = strings .TrimPrefix (pullable , "docker-pullable://" )
190
189
runningImage := model.RunningImage {
191
190
Pod : pod .Name ,
192
191
Namespace : pod .Namespace ,
@@ -199,9 +198,8 @@ func ListImages(config *rest.Config) ([]model.RunningImage, error) {
199
198
200
199
for _ , containerStatus := range pod .Status .ContainerStatuses {
201
200
pullable := containerStatus .ImageID
202
- if strings .HasPrefix (pullable , "docker-pullable://" ) {
203
- pullable = strings .TrimPrefix (pullable , "docker-pullable://" )
204
- }
201
+ pullable = strings .TrimPrefix (pullable , "docker-pullable://" )
202
+
205
203
runningImage := model.RunningImage {
206
204
Pod : pod .Name ,
207
205
Namespace : pod .Namespace ,
@@ -393,8 +391,8 @@ func fetchTags(reg *registry.Registry, imageName string) ([]string, error) {
393
391
}
394
392
395
393
func parseTags (tags []string ) ([]* semver.Version , []string , error ) {
396
- semverTags := make ([]* semver.Version , 0 , 0 )
397
- nonSemverTags := make ([]string , 0 , 0 )
394
+ semverTags := make ([]* semver.Version , 0 )
395
+ nonSemverTags := make ([]string , 0 )
398
396
399
397
for _ , tag := range tags {
400
398
v , err := semver .NewVersion (tag )
@@ -449,12 +447,12 @@ func splitOutlierSemvers(allSemverTags []*semver.Version) ([]*semver.Version, []
449
447
return outliers , remaining , nil
450
448
}
451
449
452
- func homeDir () string {
453
- if h := os .Getenv ("HOME" ); h != "" {
454
- return h
455
- }
456
- return os .Getenv ("USERPROFILE" )
457
- }
450
+ // func homeDir() string {
451
+ // if h := os.Getenv("HOME"); h != "" {
452
+ // return h
453
+ // }
454
+ // return os.Getenv("USERPROFILE")
455
+ // }
458
456
459
457
type VersionTag struct {
460
458
Sort int `json:"sort"`
@@ -547,7 +545,7 @@ func (c SemverTagCollection) Unique() ([]*semver.Version, error) {
547
545
}
548
546
}
549
547
550
- result := make ([]* semver.Version , 0 , 0 )
548
+ result := make ([]* semver.Version , 0 )
551
549
for _ , u := range unique {
552
550
result = append (result , u )
553
551
}
0 commit comments