Skip to content

Commit 29ccf15

Browse files
committed
Better handling of private images
1 parent c0180a6 commit 29ccf15

File tree

7 files changed

+530
-20
lines changed

7 files changed

+530
-20
lines changed

cmd/outdated/cli/header.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func erroredImage(image outdated.RunningImage, checkResult *outdated.CheckResult
155155
tagColumnSpacer = fmt.Sprintf("%s ", tagColumnSpacer)
156156
}
157157

158-
return fmt.Sprintf("%s%s%s%s%s", truncatedImageName, imageColumnSpacer, truncatedTagName, tagColumnSpacer, checkResult.CheckError)
158+
message := "Unable to get image data"
159+
if checkResult != nil {
160+
message = checkResult.CheckError
161+
}
162+
return fmt.Sprintf("%s%s%s%s%s", truncatedImageName, imageColumnSpacer, truncatedTagName, tagColumnSpacer, message)
159163

160164
}

cmd/outdated/cli/root.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func RootCmd() *cobra.Command {
5656
finishedCh <- true
5757
}()
5858

59-
images, err := o.ListImages(v.GetString("kubeconfig"), foundImageName)
59+
images, err := o.ListImages(v.GetString("kubeconfig"), foundImageName, v.GetStringSlice("ignore-ns"))
6060
if err != nil {
6161
log.Error(err)
6262
log.Info("")
@@ -72,16 +72,13 @@ func RootCmd() *cobra.Command {
7272
log.StartImageLine(runningImage(image, imageColumnWidth, tagColumnWidth))
7373
checkResult, err := o.ParseImage(image.Image, image.PullableImage)
7474
if err != nil {
75-
log.Error(err)
76-
log.Info("")
77-
os.Exit(1)
78-
return nil
79-
}
80-
81-
if checkResult.VersionsBehind != -1 {
82-
log.FinalizeImageLine(checkResult.VersionsBehind, completedImage(image, checkResult, imageColumnWidth, tagColumnWidth))
83-
} else {
8475
log.FinalizeImageLineWithError(erroredImage(image, checkResult, imageColumnWidth, tagColumnWidth))
76+
} else {
77+
if checkResult.VersionsBehind != -1 {
78+
log.FinalizeImageLine(checkResult.VersionsBehind, completedImage(image, checkResult, imageColumnWidth, tagColumnWidth))
79+
} else {
80+
log.FinalizeImageLineWithError(erroredImage(image, checkResult, imageColumnWidth, tagColumnWidth))
81+
}
8582
}
8683
}
8784

@@ -94,7 +91,7 @@ func RootCmd() *cobra.Command {
9491
cobra.OnInitialize(initConfig)
9592

9693
cmd.Flags().String("kubeconfig", path.Join(homeDir(), ".kube", "config"), "path to the kubeconfig to use")
97-
94+
cmd.Flags().StringSlice("ignore-ns", []string{}, "optional list of namespaces to exclude from searching")
9895
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
9996
return cmd
10097
}

go.mod

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ require (
66
github.com/Masterminds/goutils v1.1.0 // indirect
77
github.com/Masterminds/semver v1.4.2
88
github.com/Masterminds/sprig v2.20.0+incompatible // indirect
9+
github.com/Microsoft/go-winio v0.4.12 // indirect
910
github.com/andrewchambers/go-jqpipe v0.0.0-20180509223707-2d54cef8cd94 // indirect
1011
github.com/blang/semver v3.5.1+incompatible
12+
github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect
1113
github.com/docker/distribution v2.7.1+incompatible // indirect
1214
github.com/docker/docker v1.13.1
1315
github.com/docker/go-connections v0.4.0 // indirect
@@ -18,27 +20,32 @@ require (
1820
github.com/genuinetools/reg v0.16.0
1921
github.com/gin-gonic/gin v1.4.0
2022
github.com/gizak/termui/v3 v3.1.0
21-
github.com/golang/snappy v0.0.1 // indirect
2223
github.com/google/uuid v1.1.1 // indirect
24+
github.com/gopherjs/gopherjs v0.0.0-20190328170749-bb2674552d8f // indirect
25+
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
2326
github.com/hashicorp/go-getter v1.3.0
2427
github.com/hashicorp/go-multierror v1.0.0
2528
github.com/hashicorp/go-version v1.1.0
2629
github.com/huandu/xstrings v1.2.0 // indirect
2730
github.com/manifoldco/promptui v0.3.2 // indirect
2831
github.com/mholt/archiver v3.1.1+incompatible
32+
github.com/minio/minio v0.0.0-20190813204106-bf9b619d8656
2933
github.com/nwaples/rardecode v1.0.0 // indirect
3034
github.com/onsi/gomega v1.5.0
3135
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
32-
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
36+
github.com/pborman/uuid v1.2.0 // indirect
3337
github.com/pkg/errors v0.8.1
38+
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
3439
github.com/spf13/cobra v0.0.3
3540
github.com/spf13/viper v1.4.0
3641
github.com/stretchr/testify v1.3.0
3742
github.com/tj/go-spin v1.1.0
3843
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
3944
github.com/xo/dburl v0.0.0-20190203050942-98997a05b24f // indirect
40-
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
45+
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
46+
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
4147
gopkg.in/yaml.v2 v2.2.2
48+
gotest.tools v2.2.0+incompatible // indirect
4249
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
4350
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
4451
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d

0 commit comments

Comments
 (0)