diff --git a/go.mod b/go.mod index ebac6ce5a..44c9df780 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( k8s.io/klog v1.0.0 k8s.io/klog/v2 v2.10.0 k8s.io/kubectl v0.22.1 - k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a + k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 sigs.k8s.io/controller-runtime v0.10.2 sigs.k8s.io/yaml v1.3.0 ) @@ -83,7 +83,6 @@ require ( github.com/containerd/containerd v1.5.2 // indirect github.com/danieljoos/wincred v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/deislabs/oras v0.8.1 // indirect github.com/docker/docker v20.10.3+incompatible // indirect github.com/emicklei/dot v0.15.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect @@ -115,7 +114,6 @@ require ( github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-version v1.4.0 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect github.com/hpcloud/tail v1.0.0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect @@ -127,7 +125,6 @@ require ( github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect github.com/klauspost/compress v1.13.1 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/magiconair/properties v1.8.1 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect @@ -135,7 +132,6 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/moby/locker v1.0.1 // indirect github.com/moby/spdystream v0.2.0 // indirect @@ -147,7 +143,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect github.com/openshift/library-go v0.0.0-20210923120925-caee30353c0d // indirect - github.com/pelletier/go-toml v1.8.1 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -160,11 +155,7 @@ require ( github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sirupsen/logrus v1.8.1 // indirect - github.com/spf13/cast v1.3.0 // indirect - github.com/spf13/jwalterweatherman v1.0.0 // indirect - github.com/spf13/viper v1.7.1 // indirect github.com/stretchr/testify v1.7.0 // indirect - github.com/subosito/gotenv v1.2.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect @@ -192,7 +183,6 @@ require ( google.golang.org/protobuf v1.26.0 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.51.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/go.sum b/go.sum index c0a746838..79eec237f 100644 --- a/go.sum +++ b/go.sum @@ -209,7 +209,6 @@ github.com/containerd/btrfs v0.0.0-20201111183144-404b9149801e/go.mod h1:jg2QkJc github.com/containerd/btrfs v0.0.0-20210316141732-918d888fb676/go.mod h1:zMcX3qkXTAi9GI50+0HOeuV8LU2ryCE/V2vG/ZBiTss= github.com/containerd/btrfs v1.0.0/go.mod h1:zMcX3qkXTAi9GI50+0HOeuV8LU2ryCE/V2vG/ZBiTss= github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601/go.mod h1:X9rLEHIqSf/wfK8NsPqxJmeZgW4pcfzdXITDrUSJ6uI= -github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f h1:tSNMc+rJDfmYntojat8lljbt1mgKNpTxUZJsSzJ9Y1s= github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo= github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo= @@ -229,7 +228,6 @@ github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57/go.mod h1: github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.4.0-beta.2.0.20200729163537-40b22ef07410/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.4.3 h1:ijQT13JedHSHrQGWFcGEwzcNKrAGIiZ+jSD5QQG07SY= github.com/containerd/containerd v1.4.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.5.0-beta.1/go.mod h1:5HfvG1V2FsKesEGQ17k5/T7V960Tmcumvqn8Mc+pCYQ= github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo/uBBoBORwEx6ardVcmKU= @@ -243,8 +241,8 @@ github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41/go.mod h1:Dq github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb/go.mod h1:Dq467ZllaHgAtVp4p1xUQWBrFXR9s/wyoTpG8zOJGkY= github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo= github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y= -github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e h1:6JKvHHt396/qabvMhnhUZvWaHZzfVfldxE60TK8YLhg= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= +github.com/containerd/continuity v0.1.0 h1:UFRRY5JemiAhPZrr/uE0n8fMTLcZsUvySPr1+D7pgr8= github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM= github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= @@ -345,28 +343,17 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= -github.com/deislabs/oras v0.8.1 h1:If674KraJVpujYR00rzdi0QAmW4BxzMJPVAZJKuhQ0c= github.com/deislabs/oras v0.8.1/go.mod h1:Mx0rMSbBNaNfY9hjpccEnxkOqJL6KGjtxNHPLC4G4As= github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/devfile/api/v2 v2.0.0-20210910153124-da620cd1a7a1/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4= github.com/devfile/api/v2 v2.0.0-20211021164004-dabee4e633ed/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= -github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c h1:sjghKUov/WT71dBreHYQcTgQctxHT/p4uAhUFdGQfSU= -github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf h1:FkwAOQtepscB5B0j++9S/eoicXj707MaP5HPIScz0sA= github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4= -github.com/devfile/library v1.1.1-0.20210910214722-7c5ff63711ec/go.mod h1:svPWwWb+BP15SXCHl0dyOeE4Sohrjl5a2BaOzc/riLc= github.com/devfile/library v1.2.1-0.20211104222135-49d635cb492f/go.mod h1:uFZZdTuRqA68FVe/JoJHP92CgINyQkyWnM2Qyiim+50= -github.com/devfile/library v1.2.1-0.20220217161036-0f5995513e92 h1:RIrd0pBAET9vLHEZGyaG1PSjp/lJXa+CZfuWiih2p6g= -github.com/devfile/library v1.2.1-0.20220217161036-0f5995513e92/go.mod h1:GSPfJaBg0+bBjBHbwBE5aerJLH6tWGQu2q2rHYd9czM= github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c h1:Puqg/NJ6pP1LPFxPYBX9c0Oh0Ttu5PVdNJL5WR/CRTk= github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c/go.mod h1:kpkIA9YI7gkfglRDsKJ3n5QgVyyBmnasr2U2djYwg6s= -github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f h1:fKNUmoOPh7yAs69uMRZWHvev+m3e7T4jBL/hOXZB9ys= -github.com/devfile/registry-support/index/generator v0.0.0-20211012185733-0a73f866043f/go.mod h1:bLGagbW2SFn7jo5+kUPlCMehIGqWkRtLKc5O0OyJMJM= github.com/devfile/registry-support/index/generator v0.0.0-20220222194908-7a90a4214f3e h1:3WAjUoyAmCBzUpx+sO0dSgkH74uSW1y886wGbojD2D8= github.com/devfile/registry-support/index/generator v0.0.0-20220222194908-7a90a4214f3e/go.mod h1:iRPBxs+ZjfLEduVXpCCIOzdD2588Zv9OCs/CcXMcCCY= -github.com/devfile/registry-support/registry-library v0.0.0-20211125162259-d7edf148d3e2 h1:Rwuc0bdx8xSZWdIwXjAxaKYnZIWHneJmDAAZ6a5jXzY= -github.com/devfile/registry-support/registry-library v0.0.0-20211125162259-d7edf148d3e2/go.mod h1:P9ivpg3NdJR7/atzW6Jo7Qs0NbrLjwxoknhQN+lFyAc= github.com/devfile/registry-support/registry-library v0.0.0-20220504150710-21de53798172 h1:aCgfXSj/gnJcjJAILy2e5Jk9q1THNkKnlKR/3xrTKuw= github.com/devfile/registry-support/registry-library v0.0.0-20220504150710-21de53798172/go.mod h1:FUf1Uzs3dm+/slhQ3OhN21RllX4bdk91+rU/tHa2X6A= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -674,7 +661,6 @@ github.com/google/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEi github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -743,7 +729,6 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -751,7 +736,6 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= @@ -872,7 +856,6 @@ github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -937,7 +920,6 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -950,6 +932,7 @@ github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8 github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mount v0.2.0/go.mod h1:aAivFE2LB3W4bACsUXChRHQ0qKWsetY4Y9V7sxOougM= github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= +github.com/moby/sys/mountinfo v0.4.1 h1:1O+1cHA1aujwEwwVMa2Xm2l+gIpUHyd3+D+d7LZh1kM= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= @@ -1087,7 +1070,6 @@ github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= -github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -1154,8 +1136,6 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/redhat-developer/alizer/go v0.0.0-20220215154256-33df7feef4ae h1:N2wsIYtziHQ51GNcJY5YcB0YldpR5BwPoTvby+l0vy8= -github.com/redhat-developer/alizer/go v0.0.0-20220215154256-33df7feef4ae/go.mod h1:EKkrP0Am7Xt/yg3dF8uH1SSoOcaZmBom8Iy6CJPPDok= github.com/redhat-developer/alizer/go v0.0.0-20220530162645-f27a60be88a1 h1:uhf+ll3f7uFvNGBndseVpiGEt6vLiw9vjCg2YH13uk4= github.com/redhat-developer/alizer/go v0.0.0-20220530162645-f27a60be88a1/go.mod h1:EKkrP0Am7Xt/yg3dF8uH1SSoOcaZmBom8Iy6CJPPDok= github.com/redhat-developer/service-binding-operator v1.0.1-0.20211222115357-5b7bbba3bfb3 h1:hj+Y8vIzfQzzGx0az0MbIqDcW0+MZMc2rht8LuKt8uA= @@ -1210,7 +1190,6 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= @@ -1220,7 +1199,6 @@ github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -1231,7 +1209,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= @@ -1253,7 +1230,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1430,7 +1406,6 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= @@ -1896,7 +1871,6 @@ gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKW gopkg.in/imdario/mergo.v0 v0.3.7/go.mod h1:9qPP6AGrlC1G2PTNXko614FwGZvorN7MiBU0Eppok+U= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= @@ -2045,8 +2019,9 @@ k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a h1:8dYfu/Fc9Gz2rNJKB9IQRGgQOh2clmRzNIPPY1xLY5g= k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc= +k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/pkg/devfile/adapters/kubernetes/component/adapter.go b/pkg/devfile/adapters/kubernetes/component/adapter.go index dd6fb14fe..68148e701 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter.go @@ -3,7 +3,6 @@ package component import ( "fmt" "io" - "time" "k8s.io/utils/pointer" @@ -53,7 +52,7 @@ func (a *Adapter) getPod(refresh bool) (*corev1.Pod, error) { podSelector := fmt.Sprintf("component=%s", a.ComponentName) // Wait for Pod to be in running state otherwise we can't sync data to it. - pod, err := a.kubeClient.WaitAndGetPodWithEvents(podSelector, corev1.PodRunning, time.Duration(a.prefClient.GetPushTimeout())*time.Second) + pod, err := a.kubeClient.WaitAndGetPodWithEvents(podSelector, corev1.PodRunning, a.prefClient.GetPushTimeout()) if err != nil { return nil, fmt.Errorf("error while waiting for pod %s: %w", podSelector, err) } diff --git a/pkg/devfile/adapters/kubernetes/component/adapter_test.go b/pkg/devfile/adapters/kubernetes/component/adapter_test.go index 4a0fc5973..a88a9e66c 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter_test.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter_test.go @@ -5,6 +5,7 @@ import ( "errors" "reflect" "testing" + "time" "github.com/devfile/library/pkg/devfile/parser/data" "github.com/golang/mock/gomock" @@ -441,7 +442,7 @@ func TestWaitAndGetComponentPod(t *testing.T) { ctrl := gomock.NewController(t) prefClient := preference.NewMockClient(ctrl) - prefClient.EXPECT().GetPushTimeout().Return(10) + prefClient.EXPECT().GetPushTimeout().Return(100 * time.Second) componentAdapter := New(adapterCtx, fkclient, prefClient) _, err := componentAdapter.getPod(false) diff --git a/pkg/kclient/pods_test.go b/pkg/kclient/pods_test.go index a8644b040..ff935f173 100644 --- a/pkg/kclient/pods_test.go +++ b/pkg/kclient/pods_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/redhat-developer/odo/pkg/preference" "k8s.io/apimachinery/pkg/runtime" + "github.com/redhat-developer/odo/pkg/preference" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -81,7 +82,7 @@ func TestWaitAndGetPodWithEvents(t *testing.T) { podSelector := fmt.Sprintf("deploymentconfig=%s", tt.podName) - pod, err := fakeClient.WaitAndGetPodWithEvents(podSelector, corev1.PodRunning, preference.DefaultPushTimeout*time.Second) + pod, err := fakeClient.WaitAndGetPodWithEvents(podSelector, corev1.PodRunning, preference.DefaultPushTimeout) if !tt.wantErr == (err != nil) { t.Errorf("client.WaitAndGetPod(string) unexpected error %v, wantErr %v", err, tt.wantErr) diff --git a/pkg/odo/cli/preference/set.go b/pkg/odo/cli/preference/set.go index 3c08f6910..55cecbcd8 100644 --- a/pkg/odo/cli/preference/set.go +++ b/pkg/odo/cli/preference/set.go @@ -13,9 +13,10 @@ import ( "github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset" "github.com/redhat-developer/odo/pkg/preference" - "github.com/redhat-developer/odo/pkg/odo/genericclioptions" "github.com/spf13/cobra" ktemplates "k8s.io/kubectl/pkg/util/templates" + + "github.com/redhat-developer/odo/pkg/odo/genericclioptions" ) const setCommandName = "set" @@ -79,7 +80,7 @@ func (o *SetOptions) Run(ctx context.Context) (err error) { return err } - log.Info("Global preference was successfully updated") + log.Successf("Value of '%s' preference was set to '%s'", o.paramName, o.paramValue) return nil } @@ -98,23 +99,12 @@ func NewCmdSet(name, fullName string) *cobra.Command { properties := prefClient.NewPreferenceList() for _, property := range properties.Items { value := property.Default - if value == "" { - value = "foobar" - } exampleString += fmt.Sprintf("\n %s %s %v", fullName, property.Name, value) } return "\n" + exampleString }(setExample, fullName), - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 2 { - return fmt.Errorf("please provide a parameter name and value") - } else if len(args) > 2 { - return fmt.Errorf("only one value per parameter is allowed") - } else { - return nil - } - - }, Run: func(cmd *cobra.Command, args []string) { + Args: cobra.ExactArgs(2), + Run: func(cmd *cobra.Command, args []string) { genericclioptions.GenericRun(o, cmd, args) }, } diff --git a/pkg/odo/cli/preference/unset.go b/pkg/odo/cli/preference/unset.go index 52dc59e01..a305a6a48 100644 --- a/pkg/odo/cli/preference/unset.go +++ b/pkg/odo/cli/preference/unset.go @@ -2,7 +2,6 @@ package preference import ( "context" - "errors" "fmt" "strings" @@ -12,9 +11,10 @@ import ( "github.com/redhat-developer/odo/pkg/odo/genericclioptions" "github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset" - "github.com/redhat-developer/odo/pkg/preference" "github.com/spf13/cobra" ktemplates "k8s.io/kubectl/pkg/util/templates" + + "github.com/redhat-developer/odo/pkg/preference" ) const unsetCommandName = "unset" @@ -33,7 +33,7 @@ type UnsetOptions struct { // Clients clientset *clientset.Clientset - //Parameters + // Parameters paramName string // Flags @@ -71,7 +71,7 @@ func (o *UnsetOptions) Run(ctx context.Context) (err error) { return nil } } else { - return errors.New("preference already unset, cannot unset a preference which is not set") + return fmt.Errorf("value of '%s' is already unset", o.paramName) } } @@ -80,7 +80,7 @@ func (o *UnsetOptions) Run(ctx context.Context) (err error) { return err } - log.Info("Global preference was successfully updated") + log.Successf("Value of '%s' preference was removed from preferences. Its default value will be used.", o.paramName) return nil } @@ -94,19 +94,15 @@ func NewCmdUnset(name, fullName string) *cobra.Command { Long: fmt.Sprintf(unsetLongDesc, preference.FormatSupportedParameters()), Example: func(exampleString, fullName string) string { // Just show one example of how to unset a value. - exampleString += fmt.Sprintf("\n %s %s", fullName, preference.GetSupportedParameters()[0]) - return "\n" + exampleString - }(unsetExample, fullName), - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return fmt.Errorf("please provide a parameter name") - } else if len(args) > 1 { - return fmt.Errorf("only one parameter is allowed") - } else { - return nil + parameters := preference.GetSupportedParameters() + for _, param := range parameters { + exampleString += fmt.Sprintf("\n %s %s", fullName, param) } - }, Run: func(cmd *cobra.Command, args []string) { + return "\n" + exampleString + }(unsetExample, fullName), + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { genericclioptions.GenericRun(o, cmd, args) }, } diff --git a/pkg/odo/cli/preference/unset_test.go b/pkg/odo/cli/preference/unset_test.go index cba1b72cf..c5adcb963 100644 --- a/pkg/odo/cli/preference/unset_test.go +++ b/pkg/odo/cli/preference/unset_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/golang/mock/gomock" + "github.com/redhat-developer/odo/pkg/odo/cmdline" "github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset" "github.com/redhat-developer/odo/pkg/preference" @@ -27,7 +28,7 @@ func TestUnsetForce(t *testing.T) { name: "no force and parameter not exists", forceFlag: false, exists: false, - expectedRunErr: "preference already unset", + expectedRunErr: "is already unset", }, } for _, tt := range tests { diff --git a/pkg/odo/cli/preference/view_test.go b/pkg/odo/cli/preference/view_test.go index 35abe60da..32027e41e 100644 --- a/pkg/odo/cli/preference/view_test.go +++ b/pkg/odo/cli/preference/view_test.go @@ -3,6 +3,7 @@ package preference import ( "context" "testing" + "time" "github.com/golang/mock/gomock" @@ -36,10 +37,11 @@ func TestView(t *testing.T) { return } + timeValue := 10 * time.Second prefClient.EXPECT().UpdateNotification().Return(pointer.Bool(false)) - prefClient.EXPECT().Timeout().Return(pointer.Int(10)) - prefClient.EXPECT().RegistryCacheTime().Return(pointer.Int(240)) - prefClient.EXPECT().PushTimeout().Return(pointer.Int(10)) + prefClient.EXPECT().Timeout().Return(&timeValue) + prefClient.EXPECT().RegistryCacheTime().Return(&timeValue) + prefClient.EXPECT().PushTimeout().Return(&timeValue) prefClient.EXPECT().EphemeralSourceVolume().Return(pointer.Bool(false)) prefClient.EXPECT().ConsentTelemetry().Return(pointer.Bool(false)) diff --git a/pkg/odo/cli/version/version.go b/pkg/odo/cli/version/version.go index 0634ff55a..e1f1f1ff3 100644 --- a/pkg/odo/cli/version/version.go +++ b/pkg/odo/cli/version/version.go @@ -14,10 +14,11 @@ import ( "github.com/redhat-developer/odo/pkg/preference" odoversion "github.com/redhat-developer/odo/pkg/version" - "github.com/redhat-developer/odo/pkg/odo/util" "github.com/spf13/cobra" "k8s.io/klog" ktemplates "k8s.io/kubectl/pkg/util/templates" + + "github.com/redhat-developer/odo/pkg/odo/util" ) // RecommendedCommandName is the recommended version command name @@ -63,11 +64,11 @@ func (o *VersionOptions) Complete(cmdline cmdline.Cmdline, args []string) (err e // checking the value of timeout in preference var timeout time.Duration if o.clientset.PreferenceClient != nil { - timeout = time.Duration(o.clientset.PreferenceClient.GetTimeout()) * time.Second + timeout = o.clientset.PreferenceClient.GetTimeout() } else { // the default timeout will be used // when the value is not readable from preference - timeout = preference.DefaultTimeout * time.Second + timeout = preference.DefaultTimeout } o.serverInfo, _ = client.GetServerVersion(timeout) } diff --git a/pkg/preference/errors.go b/pkg/preference/errors.go new file mode 100644 index 000000000..e2fcb24a6 --- /dev/null +++ b/pkg/preference/errors.go @@ -0,0 +1,11 @@ +package preference + +type MinimumDurationValueError struct{} + +func NewMinimumDurationValueError() MinimumDurationValueError { + return MinimumDurationValueError{} +} + +func (v MinimumDurationValueError) Error() string { + return "value must be a positive Duration (e.g. 4s, 5m, 1h); minimum value: 1s" +} diff --git a/pkg/preference/implem.go b/pkg/preference/implem.go index f6b58a846..c4ed73533 100644 --- a/pkg/preference/implem.go +++ b/pkg/preference/implem.go @@ -1,13 +1,13 @@ package preference import ( - "errors" "fmt" "os" "os/user" "path/filepath" "strconv" "strings" + "time" "github.com/redhat-developer/odo/pkg/log" "github.com/redhat-developer/odo/pkg/odo/cli/ui" @@ -17,6 +17,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" + kpointer "k8s.io/utils/pointer" ) // odoSettings holds all odo specific configurations @@ -25,17 +26,17 @@ type odoSettings struct { // Controls if an update notification is shown or not UpdateNotification *bool `yaml:"UpdateNotification,omitempty"` - // Timeout for OpenShift server connection check - Timeout *int `yaml:"Timeout,omitempty"` + // Timeout for server connection check + Timeout *time.Duration `yaml:"Timeout,omitempty"` - // PushTimeout for OpenShift pod timeout check - PushTimeout *int `yaml:"PushTimeout,omitempty"` + // PushTimeout for pod timeout check + PushTimeout *time.Duration `yaml:"PushTimeout,omitempty"` // RegistryList for telling odo to connect to all the registries in the registry list RegistryList *[]Registry `yaml:"RegistryList,omitempty"` // RegistryCacheTime how long odo should cache information from registry - RegistryCacheTime *int `yaml:"RegistryCacheTime,omitempty"` + RegistryCacheTime *time.Duration `yaml:"RegistryCacheTime,omitempty"` // Ephemeral if true creates odo emptyDir to store odo source code Ephemeral *bool `yaml:"Ephemeral,omitempty"` @@ -130,6 +131,22 @@ func newPreferenceInfo() (*preferenceInfo, error) { return nil, err } + // TODO: This code block about logging warnings should be removed once users completely shift to odo v3. + // The warning will be printed more than once, and it can be annoying, but it should ensure that the user will change these values. + var requiresChange []string + if c.OdoSettings.Timeout != nil && *c.OdoSettings.Timeout < minimumDurationValue { + requiresChange = append(requiresChange, TimeoutSetting) + } + if c.OdoSettings.PushTimeout != nil && *c.OdoSettings.PushTimeout < minimumDurationValue { + requiresChange = append(requiresChange, PushTimeoutSetting) + } + if c.OdoSettings.RegistryCacheTime != nil && *c.OdoSettings.RegistryCacheTime < minimumDurationValue { + requiresChange = append(requiresChange, RegistryCacheTimeSetting) + } + if len(requiresChange) != 0 { + log.Warningf("Please change the preference value for %s, the value does not comply with the minimum value of %s; e.g. of acceptable formats: 4s, 5m, 1h", strings.Join(requiresChange, ", "), minimumDurationValue) + } + // Handle user has preference file but doesn't use dynamic registry before if c.OdoSettings.RegistryList == nil { c.OdoSettings.RegistryList = &defaultRegistryList @@ -253,32 +270,23 @@ func (c *preferenceInfo) SetConfiguration(parameter string, value string) error switch p { case "timeout": - typedval, err := strconv.Atoi(value) + typedval, err := parseDuration(value, parameter) if err != nil { - return fmt.Errorf("unable to set %q to %q", parameter, value) - } - if typedval < 0 { - return errors.New("cannot set timeout to less than 0") + return err } c.OdoSettings.Timeout = &typedval case "pushtimeout": - typedval, err := strconv.Atoi(value) + typedval, err := parseDuration(value, parameter) if err != nil { - return fmt.Errorf("unable to set %q to %q, value must be an integer", parameter, value) - } - if typedval < 0 { - return errors.New("cannot set timeout to less than 0") + return err } c.OdoSettings.PushTimeout = &typedval case "registrycachetime": - typedval, err := strconv.Atoi(value) + typedval, err := parseDuration(value, parameter) if err != nil { - return fmt.Errorf("unable to set %q to %q, value must be an integer", parameter, value) - } - if typedval < 0 { - return errors.New("cannot set timeout to less than 0") + return err } c.OdoSettings.RegistryCacheTime = &typedval @@ -314,6 +322,20 @@ func (c *preferenceInfo) SetConfiguration(parameter string, value string) error return nil } +// parseDuration parses the value set for a parameter; +// if the value is for e.g. "4m", it is parsed by the time pkg and converted to an appropriate time.Duration +// it returns an error if one occurred, or if the parsed value is less than minimumDurationValue +func parseDuration(value, parameter string) (time.Duration, error) { + typedval, err := time.ParseDuration(value) + if err != nil { + return typedval, fmt.Errorf("unable to set %q to %q; cause: %w\n%s", parameter, value, err, NewMinimumDurationValueError().Error()) + } + if typedval < minimumDurationValue { + return typedval, fmt.Errorf("unable to set %q to %q; cause: %w", parameter, value, NewMinimumDurationValueError()) + } + return typedval, nil +} + // DeleteConfiguration deletes odo preference from the odo preference file func (c *preferenceInfo) DeleteConfiguration(parameter string) error { if p, ok := asSupportedParameter(parameter); ok { @@ -340,46 +362,46 @@ func (c *preferenceInfo) IsSet(parameter string) bool { // GetTimeout returns the value of Timeout from config // and if absent then returns default -func (c *preferenceInfo) GetTimeout() int { - // default timeout value is 1 - return util.GetIntOrDefault(c.OdoSettings.Timeout, DefaultTimeout) +func (c *preferenceInfo) GetTimeout() time.Duration { + // default timeout value is 1s + return kpointer.DurationDeref(c.OdoSettings.Timeout, DefaultTimeout) } // GetPushTimeout gets the value set by PushTimeout -func (c *preferenceInfo) GetPushTimeout() int { - // default timeout value is 1 - return util.GetIntOrDefault(c.OdoSettings.PushTimeout, DefaultPushTimeout) +func (c *preferenceInfo) GetPushTimeout() time.Duration { + // default timeout value is 240s + return kpointer.DurationDeref(c.OdoSettings.PushTimeout, DefaultPushTimeout) } // GetRegistryCacheTime gets the value set by RegistryCacheTime -func (c *preferenceInfo) GetRegistryCacheTime() int { - return util.GetIntOrDefault(c.OdoSettings.RegistryCacheTime, DefaultRegistryCacheTime) +func (c *preferenceInfo) GetRegistryCacheTime() time.Duration { + return kpointer.DurationDeref(c.OdoSettings.RegistryCacheTime, DefaultRegistryCacheTime) } // GetUpdateNotification returns the value of UpdateNotification from preferences // and if absent then returns default func (c *preferenceInfo) GetUpdateNotification() bool { - return util.GetBoolOrDefault(c.OdoSettings.UpdateNotification, true) + return kpointer.BoolDeref(c.OdoSettings.UpdateNotification, true) } // GetEphemeralSourceVolume returns the value of ephemeral from preferences // and if absent then returns default func (c *preferenceInfo) GetEphemeralSourceVolume() bool { - return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSetting) + return kpointer.BoolDeref(c.OdoSettings.Ephemeral, DefaultEphemeralSetting) } // GetConsentTelemetry returns the value of ConsentTelemetry from preferences // and if absent then returns default // default value: false, consent telemetry is disabled by default func (c *preferenceInfo) GetConsentTelemetry() bool { - return util.GetBoolOrDefault(c.OdoSettings.ConsentTelemetry, DefaultConsentTelemetrySetting) + return kpointer.BoolDeref(c.OdoSettings.ConsentTelemetry, DefaultConsentTelemetrySetting) } // GetEphemeral returns the value of Ephemeral from preferences // and if absent then returns default // default value: true, ephemeral is enabled by default func (c *preferenceInfo) GetEphemeral() bool { - return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSetting) + return kpointer.BoolDeref(c.OdoSettings.Ephemeral, DefaultEphemeralSetting) } func (c *preferenceInfo) UpdateNotification() *bool { @@ -390,15 +412,15 @@ func (c *preferenceInfo) Ephemeral() *bool { return c.OdoSettings.Ephemeral } -func (c *preferenceInfo) Timeout() *int { +func (c *preferenceInfo) Timeout() *time.Duration { return c.OdoSettings.Timeout } -func (c *preferenceInfo) PushTimeout() *int { +func (c *preferenceInfo) PushTimeout() *time.Duration { return c.OdoSettings.PushTimeout } -func (c *preferenceInfo) RegistryCacheTime() *int { +func (c *preferenceInfo) RegistryCacheTime() *time.Duration { return c.OdoSettings.RegistryCacheTime } diff --git a/pkg/preference/implem_test.go b/pkg/preference/implem_test.go index 1de28ed78..78f387df7 100644 --- a/pkg/preference/implem_test.go +++ b/pkg/preference/implem_test.go @@ -7,6 +7,7 @@ import ( "reflect" "strconv" "testing" + "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -77,31 +78,21 @@ func TestGetPushTimeout(t *testing.T) { } defer tempConfigFile.Close() os.Setenv(GlobalConfigEnvName, tempConfigFile.Name()) - zeroValue := 0 - nonzeroValue := 5 + + nonzeroValue := 5 * time.Second + tests := []struct { name string existingConfig Preference - want int + want time.Duration }{ { - name: "Case 1: Validating default value from test case", + name: "Validating default value from test case", existingConfig: Preference{}, want: 240, }, - { - name: "Case 2: Validating value 0 from configuration", - existingConfig: Preference{ - OdoSettings: odoSettings{ - PushTimeout: &zeroValue, - }, - }, - want: 0, - }, - - { - name: "Case 3: Validating value 5 from configuration", + name: "Validating value 5 from configuration", existingConfig: Preference{ OdoSettings: odoSettings{ PushTimeout: &nonzeroValue, @@ -119,7 +110,7 @@ func TestGetPushTimeout(t *testing.T) { cfg.Preference = tt.existingConfig output := cfg.GetPushTimeout() - if output != tt.want { + if output != (tt.want * time.Second) { t.Errorf("GetPushTimeout returned unexpected value\ngot: %d \nexpected: %d\n", output, tt.want) } }) @@ -133,21 +124,21 @@ func TestGetTimeout(t *testing.T) { } defer tempConfigFile.Close() os.Setenv(GlobalConfigEnvName, tempConfigFile.Name()) - zeroValue := 0 - nonzeroValue := 5 + zeroValue := 0 * time.Second + nonzeroValue := 5 * time.Second tests := []struct { name string existingConfig Preference - want int + want time.Duration }{ { - name: "Case 1: validating value 1 from config in default case", + name: "validating value 1 from config in default case", existingConfig: Preference{}, want: 1, }, { - name: "Case 2: validating value 0 from config", + name: "validating value 0 from config", existingConfig: Preference{ OdoSettings: odoSettings{ Timeout: &zeroValue, @@ -157,7 +148,7 @@ func TestGetTimeout(t *testing.T) { }, { - name: "Case 3: validating value 5 from config", + name: "validating value 5 from config", existingConfig: Preference{ OdoSettings: odoSettings{ Timeout: &nonzeroValue, @@ -175,7 +166,7 @@ func TestGetTimeout(t *testing.T) { cfg.Preference = tt.existingConfig output := cfg.GetTimeout() - if output != tt.want { + if output != (tt.want * time.Second) { t.Errorf("GetTimeout returned unexpected value\ngot: %d \nexpected: %d\n", output, tt.want) } }) @@ -183,7 +174,6 @@ func TestGetTimeout(t *testing.T) { } func TestSetConfiguration(t *testing.T) { - tempConfigFile, err := ioutil.TempFile("", "odoconfig") if err != nil { t.Fatal(err) @@ -192,7 +182,7 @@ func TestSetConfiguration(t *testing.T) { os.Setenv(GlobalConfigEnvName, tempConfigFile.Name()) trueValue := true falseValue := false - zeroValue := 0 + minValue := minimumDurationValue tests := []struct { name string @@ -204,7 +194,7 @@ func TestSetConfiguration(t *testing.T) { }{ // update notification { - name: fmt.Sprintf("Case 1: %s set nil to true", UpdateNotificationSetting), + name: fmt.Sprintf("%s set nil to true", UpdateNotificationSetting), parameter: UpdateNotificationSetting, value: "true", existingConfig: Preference{}, @@ -212,7 +202,7 @@ func TestSetConfiguration(t *testing.T) { wantErr: false, }, { - name: fmt.Sprintf("Case 2: %s set true to false", UpdateNotificationSetting), + name: fmt.Sprintf("%s set true to false", UpdateNotificationSetting), parameter: UpdateNotificationSetting, value: "false", existingConfig: Preference{ @@ -224,7 +214,7 @@ func TestSetConfiguration(t *testing.T) { wantErr: false, }, { - name: fmt.Sprintf("Case 3: %s set false to true", UpdateNotificationSetting), + name: fmt.Sprintf("%s set false to true", UpdateNotificationSetting), parameter: UpdateNotificationSetting, value: "true", existingConfig: Preference{ @@ -237,7 +227,7 @@ func TestSetConfiguration(t *testing.T) { }, { - name: fmt.Sprintf("Case 4: %s invalid value", UpdateNotificationSetting), + name: fmt.Sprintf("%s invalid value", UpdateNotificationSetting), parameter: UpdateNotificationSetting, value: "invalid_value", existingConfig: Preference{}, @@ -245,108 +235,107 @@ func TestSetConfiguration(t *testing.T) { }, // time out { - name: fmt.Sprintf("Case 5: %s set to 5 from 0", TimeoutSetting), + name: fmt.Sprintf("%s set to 5 from 0", TimeoutSetting), parameter: TimeoutSetting, - value: "5", + value: "5s", existingConfig: Preference{ OdoSettings: odoSettings{ - Timeout: &zeroValue, + Timeout: &minValue, }, }, - want: 5, + want: 5 * time.Second, wantErr: false, }, { - name: fmt.Sprintf("Case 6: %s set to 300", TimeoutSetting), + name: fmt.Sprintf("%s set to 300", TimeoutSetting), parameter: TimeoutSetting, - value: "300", + value: "5m", existingConfig: Preference{}, - want: 300, + want: 5 * time.Second, wantErr: false, }, { - name: fmt.Sprintf("Case 7: %s set to 0", TimeoutSetting), + name: fmt.Sprintf("%s set to 0", TimeoutSetting), parameter: TimeoutSetting, - value: "0", - existingConfig: Preference{}, - want: 0, - wantErr: false, - }, - { - name: fmt.Sprintf("Case 8: %s set to -1", TimeoutSetting), - parameter: TimeoutSetting, - value: "-1", + value: "0s", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 9: %s invalid value", TimeoutSetting), + name: fmt.Sprintf("%s invalid value", TimeoutSetting), parameter: TimeoutSetting, value: "this", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 10: %s set to 300 with mixed case in parameter name", TimeoutSetting), + name: fmt.Sprintf("%s set to 300 with mixed case in parameter name", TimeoutSetting), parameter: "TimeOut", - value: "300", + value: "5m", existingConfig: Preference{}, - want: 300, + want: 5 * time.Minute, wantErr: false, }, // invalid parameter { - name: "Case 11: invalid parameter", + name: "invalid parameter", parameter: "invalid_parameter", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 12: %s set to 0", TimeoutSetting), + name: fmt.Sprintf("%s set to 0", TimeoutSetting), parameter: TimeoutSetting, - value: "0", + value: "0s", existingConfig: Preference{}, - want: 0, - wantErr: false, + wantErr: true, }, { - name: fmt.Sprintf("Case 13: %s invalid value", TimeoutSetting), + name: fmt.Sprintf("%s invalid value", TimeoutSetting), parameter: TimeoutSetting, value: "invalid", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 14: %s set to 99 with mixed case in parameter name", TimeoutSetting), + name: fmt.Sprintf("%s negative value", TimeoutSetting), + parameter: TimeoutSetting, + value: "-5s", + existingConfig: Preference{}, + wantErr: true, + }, + { + name: fmt.Sprintf("%s set to 99 with mixed case in parameter name", TimeoutSetting), parameter: "PushTimeout", - value: "99", + value: "99s", existingConfig: Preference{}, - want: 99, + want: 99 * time.Second, wantErr: false, }, { - name: "Case 15: set RegistryCacheTime to 1", + name: "set RegistryCacheTime to 1 minutes", parameter: "RegistryCacheTime", - value: "1", + value: "1m", existingConfig: Preference{}, + want: 1 * time.Minute, wantErr: false, }, { - name: "Case 16: set RegistryCacheTime to non int value", + name: "set RegistryCacheTime to non int value", parameter: "RegistryCacheTime", value: "a", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 17: set %s to non bool value", ConsentTelemetrySetting), + name: fmt.Sprintf("set %s to non bool value", ConsentTelemetrySetting), parameter: ConsentTelemetrySetting, value: "123", existingConfig: Preference{}, wantErr: true, }, { - name: fmt.Sprintf("Case 18: set %s from nil to true", ConsentTelemetrySetting), + name: fmt.Sprintf("set %s from nil to true", ConsentTelemetrySetting), parameter: ConsentTelemetrySetting, value: "true", existingConfig: Preference{}, @@ -354,7 +343,7 @@ func TestSetConfiguration(t *testing.T) { want: true, }, { - name: fmt.Sprintf("Case 19: set %s from true to false", ConsentTelemetrySetting), + name: fmt.Sprintf("set %s from true to false", ConsentTelemetrySetting), parameter: ConsentTelemetrySetting, value: "false", existingConfig: Preference{ @@ -428,12 +417,12 @@ func TestConsentTelemetry(t *testing.T) { want bool }{ { - name: fmt.Sprintf("Case 1: %s nil", ConsentTelemetrySetting), + name: fmt.Sprintf("%s nil", ConsentTelemetrySetting), existingConfig: Preference{}, want: false, }, { - name: fmt.Sprintf("Case 2: %s true", ConsentTelemetrySetting), + name: fmt.Sprintf("%s true", ConsentTelemetrySetting), existingConfig: Preference{ OdoSettings: odoSettings{ ConsentTelemetry: &trueValue, @@ -442,7 +431,7 @@ func TestConsentTelemetry(t *testing.T) { want: true, }, { - name: fmt.Sprintf("Case 3: %s false", ConsentTelemetrySetting), + name: fmt.Sprintf("%s false", ConsentTelemetrySetting), existingConfig: Preference{ OdoSettings: odoSettings{ ConsentTelemetry: &falseValue, @@ -484,12 +473,12 @@ func TestGetupdateNotification(t *testing.T) { want bool }{ { - name: fmt.Sprintf("Case 1: %s nil", UpdateNotificationSetting), + name: fmt.Sprintf("%s nil", UpdateNotificationSetting), existingConfig: Preference{}, want: true, }, { - name: fmt.Sprintf("Case 2: %s true", UpdateNotificationSetting), + name: fmt.Sprintf("%s true", UpdateNotificationSetting), existingConfig: Preference{ OdoSettings: odoSettings{ UpdateNotification: &trueValue, @@ -498,7 +487,7 @@ func TestGetupdateNotification(t *testing.T) { want: true, }, { - name: fmt.Sprintf("Case 3: %s false", UpdateNotificationSetting), + name: fmt.Sprintf("%s false", UpdateNotificationSetting), existingConfig: Preference{ OdoSettings: odoSettings{ UpdateNotification: &falseValue, @@ -609,7 +598,7 @@ func TestHandleWithoutRegistryExist(t *testing.T) { want []Registry }{ { - name: "Case 1: Add registry", + name: "Add registry", registryList: []Registry{}, operation: "add", registryName: "testName", @@ -622,7 +611,7 @@ func TestHandleWithoutRegistryExist(t *testing.T) { }, }, { - name: "Case 2: Update registry", + name: "Update registry", registryList: []Registry{}, operation: "update", registryName: "testName", @@ -630,7 +619,7 @@ func TestHandleWithoutRegistryExist(t *testing.T) { want: nil, }, { - name: "Case 3: Delete registry", + name: "Delete registry", registryList: []Registry{}, operation: "delete", registryName: "testName", @@ -665,7 +654,7 @@ func TestHandleWithRegistryExist(t *testing.T) { want []Registry }{ { - name: "Case 1: Add registry", + name: "Add registry", index: 0, registryList: []Registry{ { @@ -680,7 +669,7 @@ func TestHandleWithRegistryExist(t *testing.T) { want: nil, }, { - name: "Case 2: update registry", + name: "update registry", index: 0, registryList: []Registry{ { @@ -700,7 +689,7 @@ func TestHandleWithRegistryExist(t *testing.T) { }, }, { - name: "Case 3: Delete registry", + name: "Delete registry", index: 0, registryList: []Registry{ { @@ -743,12 +732,12 @@ func TestGetConsentTelemetry(t *testing.T) { existingConfig Preference want bool }{{ - name: fmt.Sprintf("Case 1: %s nil", ConsentTelemetrySetting), + name: fmt.Sprintf("%s nil", ConsentTelemetrySetting), existingConfig: Preference{}, want: false, }, { - name: fmt.Sprintf("Case 2: %s true", ConsentTelemetrySetting), + name: fmt.Sprintf("%s true", ConsentTelemetrySetting), existingConfig: Preference{ OdoSettings: odoSettings{ ConsentTelemetry: &trueValue, @@ -757,7 +746,7 @@ func TestGetConsentTelemetry(t *testing.T) { want: true, }, { - name: fmt.Sprintf("Case 3: %s false", ConsentTelemetrySetting), + name: fmt.Sprintf("%s false", ConsentTelemetrySetting), existingConfig: Preference{ OdoSettings: odoSettings{ ConsentTelemetry: &falseValue, diff --git a/pkg/preference/mock.go b/pkg/preference/mock.go index 765739533..55f18e1b7 100644 --- a/pkg/preference/mock.go +++ b/pkg/preference/mock.go @@ -5,161 +5,35 @@ package preference import ( - reflect "reflect" - gomock "github.com/golang/mock/gomock" + reflect "reflect" + time "time" ) -// MockClient is a mock of Client interface. +// MockClient is a mock of Client interface type MockClient struct { ctrl *gomock.Controller recorder *MockClientMockRecorder } -// MockClientMockRecorder is the mock recorder for MockClient. +// MockClientMockRecorder is the mock recorder for MockClient type MockClientMockRecorder struct { mock *MockClient } -// NewMockClient creates a new mock instance. +// NewMockClient creates a new mock instance func NewMockClient(ctrl *gomock.Controller) *MockClient { mock := &MockClient{ctrl: ctrl} mock.recorder = &MockClientMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use. +// EXPECT returns an object that allows the caller to indicate expected use func (m *MockClient) EXPECT() *MockClientMockRecorder { return m.recorder } -// ConsentTelemetry mocks base method. -func (m *MockClient) ConsentTelemetry() *bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ConsentTelemetry") - ret0, _ := ret[0].(*bool) - return ret0 -} - -// ConsentTelemetry indicates an expected call of ConsentTelemetry. -func (mr *MockClientMockRecorder) ConsentTelemetry() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsentTelemetry", reflect.TypeOf((*MockClient)(nil).ConsentTelemetry)) -} - -// DeleteConfiguration mocks base method. -func (m *MockClient) DeleteConfiguration(parameter string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteConfiguration", parameter) - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteConfiguration indicates an expected call of DeleteConfiguration. -func (mr *MockClientMockRecorder) DeleteConfiguration(parameter interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConfiguration", reflect.TypeOf((*MockClient)(nil).DeleteConfiguration), parameter) -} - -// EphemeralSourceVolume mocks base method. -func (m *MockClient) EphemeralSourceVolume() *bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "EphemeralSourceVolume") - ret0, _ := ret[0].(*bool) - return ret0 -} - -// EphemeralSourceVolume indicates an expected call of EphemeralSourceVolume. -func (mr *MockClientMockRecorder) EphemeralSourceVolume() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).EphemeralSourceVolume)) -} - -// GetConsentTelemetry mocks base method. -func (m *MockClient) GetConsentTelemetry() bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetConsentTelemetry") - ret0, _ := ret[0].(bool) - return ret0 -} - -// GetConsentTelemetry indicates an expected call of GetConsentTelemetry. -func (mr *MockClientMockRecorder) GetConsentTelemetry() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsentTelemetry", reflect.TypeOf((*MockClient)(nil).GetConsentTelemetry)) -} - -// GetEphemeralSourceVolume mocks base method. -func (m *MockClient) GetEphemeralSourceVolume() bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetEphemeralSourceVolume") - ret0, _ := ret[0].(bool) - return ret0 -} - -// GetEphemeralSourceVolume indicates an expected call of GetEphemeralSourceVolume. -func (mr *MockClientMockRecorder) GetEphemeralSourceVolume() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).GetEphemeralSourceVolume)) -} - -// GetPushTimeout mocks base method. -func (m *MockClient) GetPushTimeout() int { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPushTimeout") - ret0, _ := ret[0].(int) - return ret0 -} - -// GetPushTimeout indicates an expected call of GetPushTimeout. -func (mr *MockClientMockRecorder) GetPushTimeout() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPushTimeout", reflect.TypeOf((*MockClient)(nil).GetPushTimeout)) -} - -// GetRegistryCacheTime mocks base method. -func (m *MockClient) GetRegistryCacheTime() int { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRegistryCacheTime") - ret0, _ := ret[0].(int) - return ret0 -} - -// GetRegistryCacheTime indicates an expected call of GetRegistryCacheTime. -func (mr *MockClientMockRecorder) GetRegistryCacheTime() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRegistryCacheTime", reflect.TypeOf((*MockClient)(nil).GetRegistryCacheTime)) -} - -// GetTimeout mocks base method. -func (m *MockClient) GetTimeout() int { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTimeout") - ret0, _ := ret[0].(int) - return ret0 -} - -// GetTimeout indicates an expected call of GetTimeout. -func (mr *MockClientMockRecorder) GetTimeout() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTimeout", reflect.TypeOf((*MockClient)(nil).GetTimeout)) -} - -// GetUpdateNotification mocks base method. -func (m *MockClient) GetUpdateNotification() bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetUpdateNotification") - ret0, _ := ret[0].(bool) - return ret0 -} - -// GetUpdateNotification indicates an expected call of GetUpdateNotification. -func (mr *MockClientMockRecorder) GetUpdateNotification() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUpdateNotification", reflect.TypeOf((*MockClient)(nil).GetUpdateNotification)) -} - -// IsSet mocks base method. +// IsSet mocks base method func (m *MockClient) IsSet(parameter string) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsSet", parameter) @@ -167,97 +41,13 @@ func (m *MockClient) IsSet(parameter string) bool { return ret0 } -// IsSet indicates an expected call of IsSet. +// IsSet indicates an expected call of IsSet func (mr *MockClientMockRecorder) IsSet(parameter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSet", reflect.TypeOf((*MockClient)(nil).IsSet), parameter) } -// NewPreferenceList mocks base method. -func (m *MockClient) NewPreferenceList() PreferenceList { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "NewPreferenceList") - ret0, _ := ret[0].(PreferenceList) - return ret0 -} - -// NewPreferenceList indicates an expected call of NewPreferenceList. -func (mr *MockClientMockRecorder) NewPreferenceList() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewPreferenceList", reflect.TypeOf((*MockClient)(nil).NewPreferenceList)) -} - -// PushTimeout mocks base method. -func (m *MockClient) PushTimeout() *int { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PushTimeout") - ret0, _ := ret[0].(*int) - return ret0 -} - -// PushTimeout indicates an expected call of PushTimeout. -func (mr *MockClientMockRecorder) PushTimeout() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PushTimeout", reflect.TypeOf((*MockClient)(nil).PushTimeout)) -} - -// RegistryCacheTime mocks base method. -func (m *MockClient) RegistryCacheTime() *int { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegistryCacheTime") - ret0, _ := ret[0].(*int) - return ret0 -} - -// RegistryCacheTime indicates an expected call of RegistryCacheTime. -func (mr *MockClientMockRecorder) RegistryCacheTime() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryCacheTime", reflect.TypeOf((*MockClient)(nil).RegistryCacheTime)) -} - -// RegistryHandler mocks base method. -func (m *MockClient) RegistryHandler(operation, registryName, registryURL string, forceFlag, isSecure bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegistryHandler", operation, registryName, registryURL, forceFlag, isSecure) - ret0, _ := ret[0].(error) - return ret0 -} - -// RegistryHandler indicates an expected call of RegistryHandler. -func (mr *MockClientMockRecorder) RegistryHandler(operation, registryName, registryURL, forceFlag, isSecure interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryHandler", reflect.TypeOf((*MockClient)(nil).RegistryHandler), operation, registryName, registryURL, forceFlag, isSecure) -} - -// RegistryList mocks base method. -func (m *MockClient) RegistryList() *[]Registry { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegistryList") - ret0, _ := ret[0].(*[]Registry) - return ret0 -} - -// RegistryList indicates an expected call of RegistryList. -func (mr *MockClientMockRecorder) RegistryList() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryList", reflect.TypeOf((*MockClient)(nil).RegistryList)) -} - -// RegistryNameExists mocks base method. -func (m *MockClient) RegistryNameExists(name string) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegistryNameExists", name) - ret0, _ := ret[0].(bool) - return ret0 -} - -// RegistryNameExists indicates an expected call of RegistryNameExists. -func (mr *MockClientMockRecorder) RegistryNameExists(name interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryNameExists", reflect.TypeOf((*MockClient)(nil).RegistryNameExists), name) -} - -// SetConfiguration mocks base method. +// SetConfiguration mocks base method func (m *MockClient) SetConfiguration(parameter, value string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetConfiguration", parameter, value) @@ -265,27 +55,125 @@ func (m *MockClient) SetConfiguration(parameter, value string) error { return ret0 } -// SetConfiguration indicates an expected call of SetConfiguration. +// SetConfiguration indicates an expected call of SetConfiguration func (mr *MockClientMockRecorder) SetConfiguration(parameter, value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetConfiguration", reflect.TypeOf((*MockClient)(nil).SetConfiguration), parameter, value) } -// Timeout mocks base method. -func (m *MockClient) Timeout() *int { +// DeleteConfiguration mocks base method +func (m *MockClient) DeleteConfiguration(parameter string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Timeout") - ret0, _ := ret[0].(*int) + ret := m.ctrl.Call(m, "DeleteConfiguration", parameter) + ret0, _ := ret[0].(error) return ret0 } -// Timeout indicates an expected call of Timeout. -func (mr *MockClientMockRecorder) Timeout() *gomock.Call { +// DeleteConfiguration indicates an expected call of DeleteConfiguration +func (mr *MockClientMockRecorder) DeleteConfiguration(parameter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Timeout", reflect.TypeOf((*MockClient)(nil).Timeout)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConfiguration", reflect.TypeOf((*MockClient)(nil).DeleteConfiguration), parameter) } -// UpdateNotification mocks base method. +// GetUpdateNotification mocks base method +func (m *MockClient) GetUpdateNotification() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUpdateNotification") + ret0, _ := ret[0].(bool) + return ret0 +} + +// GetUpdateNotification indicates an expected call of GetUpdateNotification +func (mr *MockClientMockRecorder) GetUpdateNotification() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUpdateNotification", reflect.TypeOf((*MockClient)(nil).GetUpdateNotification)) +} + +// GetTimeout mocks base method +func (m *MockClient) GetTimeout() time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTimeout") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// GetTimeout indicates an expected call of GetTimeout +func (mr *MockClientMockRecorder) GetTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTimeout", reflect.TypeOf((*MockClient)(nil).GetTimeout)) +} + +// GetPushTimeout mocks base method +func (m *MockClient) GetPushTimeout() time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPushTimeout") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// GetPushTimeout indicates an expected call of GetPushTimeout +func (mr *MockClientMockRecorder) GetPushTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPushTimeout", reflect.TypeOf((*MockClient)(nil).GetPushTimeout)) +} + +// GetEphemeralSourceVolume mocks base method +func (m *MockClient) GetEphemeralSourceVolume() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEphemeralSourceVolume") + ret0, _ := ret[0].(bool) + return ret0 +} + +// GetEphemeralSourceVolume indicates an expected call of GetEphemeralSourceVolume +func (mr *MockClientMockRecorder) GetEphemeralSourceVolume() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).GetEphemeralSourceVolume)) +} + +// GetConsentTelemetry mocks base method +func (m *MockClient) GetConsentTelemetry() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsentTelemetry") + ret0, _ := ret[0].(bool) + return ret0 +} + +// GetConsentTelemetry indicates an expected call of GetConsentTelemetry +func (mr *MockClientMockRecorder) GetConsentTelemetry() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsentTelemetry", reflect.TypeOf((*MockClient)(nil).GetConsentTelemetry)) +} + +// GetRegistryCacheTime mocks base method +func (m *MockClient) GetRegistryCacheTime() time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRegistryCacheTime") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// GetRegistryCacheTime indicates an expected call of GetRegistryCacheTime +func (mr *MockClientMockRecorder) GetRegistryCacheTime() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRegistryCacheTime", reflect.TypeOf((*MockClient)(nil).GetRegistryCacheTime)) +} + +// RegistryHandler mocks base method +func (m *MockClient) RegistryHandler(operation, registryName, registryURL string, forceFlag, isSecure bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RegistryHandler", operation, registryName, registryURL, forceFlag, isSecure) + ret0, _ := ret[0].(error) + return ret0 +} + +// RegistryHandler indicates an expected call of RegistryHandler +func (mr *MockClientMockRecorder) RegistryHandler(operation, registryName, registryURL, forceFlag, isSecure interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryHandler", reflect.TypeOf((*MockClient)(nil).RegistryHandler), operation, registryName, registryURL, forceFlag, isSecure) +} + +// UpdateNotification mocks base method func (m *MockClient) UpdateNotification() *bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateNotification") @@ -293,8 +181,120 @@ func (m *MockClient) UpdateNotification() *bool { return ret0 } -// UpdateNotification indicates an expected call of UpdateNotification. +// UpdateNotification indicates an expected call of UpdateNotification func (mr *MockClientMockRecorder) UpdateNotification() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateNotification", reflect.TypeOf((*MockClient)(nil).UpdateNotification)) } + +// Timeout mocks base method +func (m *MockClient) Timeout() *time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Timeout") + ret0, _ := ret[0].(*time.Duration) + return ret0 +} + +// Timeout indicates an expected call of Timeout +func (mr *MockClientMockRecorder) Timeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Timeout", reflect.TypeOf((*MockClient)(nil).Timeout)) +} + +// PushTimeout mocks base method +func (m *MockClient) PushTimeout() *time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PushTimeout") + ret0, _ := ret[0].(*time.Duration) + return ret0 +} + +// PushTimeout indicates an expected call of PushTimeout +func (mr *MockClientMockRecorder) PushTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PushTimeout", reflect.TypeOf((*MockClient)(nil).PushTimeout)) +} + +// RegistryCacheTime mocks base method +func (m *MockClient) RegistryCacheTime() *time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RegistryCacheTime") + ret0, _ := ret[0].(*time.Duration) + return ret0 +} + +// RegistryCacheTime indicates an expected call of RegistryCacheTime +func (mr *MockClientMockRecorder) RegistryCacheTime() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryCacheTime", reflect.TypeOf((*MockClient)(nil).RegistryCacheTime)) +} + +// EphemeralSourceVolume mocks base method +func (m *MockClient) EphemeralSourceVolume() *bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EphemeralSourceVolume") + ret0, _ := ret[0].(*bool) + return ret0 +} + +// EphemeralSourceVolume indicates an expected call of EphemeralSourceVolume +func (mr *MockClientMockRecorder) EphemeralSourceVolume() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).EphemeralSourceVolume)) +} + +// ConsentTelemetry mocks base method +func (m *MockClient) ConsentTelemetry() *bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConsentTelemetry") + ret0, _ := ret[0].(*bool) + return ret0 +} + +// ConsentTelemetry indicates an expected call of ConsentTelemetry +func (mr *MockClientMockRecorder) ConsentTelemetry() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsentTelemetry", reflect.TypeOf((*MockClient)(nil).ConsentTelemetry)) +} + +// RegistryList mocks base method +func (m *MockClient) RegistryList() *[]Registry { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RegistryList") + ret0, _ := ret[0].(*[]Registry) + return ret0 +} + +// RegistryList indicates an expected call of RegistryList +func (mr *MockClientMockRecorder) RegistryList() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryList", reflect.TypeOf((*MockClient)(nil).RegistryList)) +} + +// RegistryNameExists mocks base method +func (m *MockClient) RegistryNameExists(name string) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RegistryNameExists", name) + ret0, _ := ret[0].(bool) + return ret0 +} + +// RegistryNameExists indicates an expected call of RegistryNameExists +func (mr *MockClientMockRecorder) RegistryNameExists(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryNameExists", reflect.TypeOf((*MockClient)(nil).RegistryNameExists), name) +} + +// NewPreferenceList mocks base method +func (m *MockClient) NewPreferenceList() PreferenceList { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewPreferenceList") + ret0, _ := ret[0].(PreferenceList) + return ret0 +} + +// NewPreferenceList indicates an expected call of NewPreferenceList +func (mr *MockClientMockRecorder) NewPreferenceList() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewPreferenceList", reflect.TypeOf((*MockClient)(nil).NewPreferenceList)) +} diff --git a/pkg/preference/preference.go b/pkg/preference/preference.go index c3da90f8f..8357bb481 100644 --- a/pkg/preference/preference.go +++ b/pkg/preference/preference.go @@ -1,22 +1,26 @@ package preference +import ( + "time" +) + type Client interface { IsSet(parameter string) bool SetConfiguration(parameter string, value string) error DeleteConfiguration(parameter string) error GetUpdateNotification() bool - GetTimeout() int - GetPushTimeout() int + GetTimeout() time.Duration + GetPushTimeout() time.Duration GetEphemeralSourceVolume() bool GetConsentTelemetry() bool - GetRegistryCacheTime() int + GetRegistryCacheTime() time.Duration RegistryHandler(operation string, registryName string, registryURL string, forceFlag bool, isSecure bool) error UpdateNotification() *bool - Timeout() *int - PushTimeout() *int - RegistryCacheTime() *int + Timeout() *time.Duration + PushTimeout() *time.Duration + RegistryCacheTime() *time.Duration EphemeralSourceVolume() *bool ConsentTelemetry() *bool RegistryList() *[]Registry diff --git a/pkg/preference/variables.go b/pkg/preference/variables.go index 67a8065ac..dcbcbf93b 100644 --- a/pkg/preference/variables.go +++ b/pkg/preference/variables.go @@ -3,6 +3,7 @@ package preference import ( "fmt" "os" + "time" "github.com/redhat-developer/odo/pkg/util" ) @@ -13,11 +14,14 @@ const ( preferenceKind = "Preference" preferenceAPIVersion = "odo.dev/v1alpha1" - //DefaultTimeout for openshift server connection check (in seconds) - DefaultTimeout = 1 + // minimumDurationValue is the minimum acceptable value for preferences that accept time.Duration + minimumDurationValue = 1 * time.Second + + // DefaultTimeout for cluster server connection check (in seconds) + DefaultTimeout = 1 * time.Second // DefaultPushTimeout is the default timeout for pods (in seconds) - DefaultPushTimeout = 240 + DefaultPushTimeout = 240 * time.Second // UpdateNotificationSetting is the name of the setting controlling update notification UpdateNotificationSetting = "UpdateNotification" @@ -44,7 +48,7 @@ const ( OldDefaultDevfileRegistryURL = "https://github.com/odo-devfiles/registry" // DefaultRegistryCacheTime is time (in minutes) for how long odo will cache information from Devfile registry - DefaultRegistryCacheTime = 15 + DefaultRegistryCacheTime = 15 * time.Minute // EphemeralSetting specifies if ephemeral volumes needs to be used as source volume. EphemeralSetting = "Ephemeral" @@ -60,13 +64,13 @@ const ( ) // TimeoutSettingDescription is human-readable description for the timeout setting -var TimeoutSettingDescription = fmt.Sprintf("Timeout (in seconds) for OpenShift server connection check (Default: %d)", DefaultTimeout) +var TimeoutSettingDescription = fmt.Sprintf("Timeout (in Duration) for cluster server connection check (Default: %s)", DefaultTimeout) // PushTimeoutSettingDescription adds a description for PushTimeout -var PushTimeoutSettingDescription = fmt.Sprintf("PushTimeout (in seconds) for waiting for a Pod to come up (Default: %d)", DefaultPushTimeout) +var PushTimeoutSettingDescription = fmt.Sprintf("PushTimeout (in Duration) for waiting for a Pod to come up (Default: %s)", DefaultPushTimeout) // RegistryCacheTimeSettingDescription adds a description for RegistryCacheTime -var RegistryCacheTimeSettingDescription = fmt.Sprintf("For how long (in minutes) odo will cache information from the Devfile registry (Default: %d)", DefaultRegistryCacheTime) +var RegistryCacheTimeSettingDescription = fmt.Sprintf("For how long (in Duration) odo will cache information from the Devfile registry (Default: %s)", DefaultRegistryCacheTime) // EphemeralSettingDescription adds a description for EphemeralSourceVolume var EphemeralSettingDescription = fmt.Sprintf("If true, odo will create an emptyDir volume to store source code (Default: %t)", DefaultEphemeralSetting) diff --git a/pkg/util/defaults.go b/pkg/util/defaults.go deleted file mode 100644 index b60190f77..000000000 --- a/pkg/util/defaults.go +++ /dev/null @@ -1,15 +0,0 @@ -package util - -func GetIntOrDefault(ptr *int, defaultValue int) int { - if ptr == nil { - return defaultValue - } - return *ptr -} - -func GetBoolOrDefault(ptr *bool, defaultValue bool) bool { - if ptr == nil { - return defaultValue - } - return *ptr -} diff --git a/tests/helper/helper_filesystem.go b/tests/helper/helper_filesystem.go index be1150a3d..6d91aafb4 100644 --- a/tests/helper/helper_filesystem.go +++ b/tests/helper/helper_filesystem.go @@ -43,7 +43,7 @@ func DeleteDir(dir string) { fmt.Fprintf(GinkgoWriter, "Unable to delete %s on attempt #%d, trying again...\n", dir, attempts) return err - }, 16, time.Duration(2)*time.Minute) + }, 16, 2*time.Minute) Expect(err).NotTo(HaveOccurred()) if errorReportedAtLeastOnce { diff --git a/tests/integration/cmd_pref_config_test.go b/tests/integration/cmd_pref_config_test.go index 3fd700d45..d73e9464f 100644 --- a/tests/integration/cmd_pref_config_test.go +++ b/tests/integration/cmd_pref_config_test.go @@ -6,6 +6,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/redhat-developer/odo/tests/helper" ) @@ -71,11 +72,11 @@ var _ = Describe("odo preference and config command tests", func() { name, value, updateValue, invalidValue string }{ {"UpdateNotification", "false", "true", "foo"}, - {"Timeout", "5", "6", "foo"}, + {"Timeout", "5s", "6s", "foo"}, // !! Do not test ConsentTelemetry with true because it sends out the telemetry data and messes up the statistics !! {"ConsentTelemetry", "false", "false", "foo"}, - {"PushTimeout", "4", "6", "foo"}, - {"RegistryCacheTime", "4", "6", "foo"}, + {"PushTimeout", "4s", "6s", "foo"}, + {"RegistryCacheTime", "4m", "6m", "foo"}, {"Ephemeral", "false", "true", "foo"}, } @@ -97,6 +98,36 @@ var _ = Describe("odo preference and config command tests", func() { os.RemoveAll(filepath.Join(globalConfPath, ".odo")) }) }) + When("when preference.yaml contains an int value for Timeout", func() { + BeforeEach(func() { + preference := ` +kind: Preference +apiversion: odo.dev/v1alpha1 +OdoSettings: + UpdateNotification: true + RegistryList: + - Name: DefaultDevfileRegistry + URL: https://registry.devfile.io + secure: false + ConsentTelemetry: true + Timeout: 10 +` + preferencePath := filepath.Join(commonVar.Context, "preference.yaml") + err := helper.CreateFileWithContent(preferencePath, preference) + Expect(err).To(BeNil()) + os.Setenv("GLOBALODOCONFIG", preferencePath) + }) + It("should show warning about incompatible Timeout value when viewing preferences", func() { + errOut := helper.Cmd("odo", "preference", "view").ShouldPass().Err() + Expect(helper.GetPreferenceValue("Timeout")).To(ContainSubstring("10ns")) + Expect(errOut).To(ContainSubstring("Please change the preference value for Timeout")) + }) + }) + + It("should fail to set an incompatible format for a preference that accepts duration", func() { + errOut := helper.Cmd("odo", "preference", "set", "RegistryCacheTime", "1d").ShouldFail().Err() + Expect(errOut).To(ContainSubstring("unable to set \"registrycachetime\" to \"1d\"")) + }) Context("When no ConsentTelemetry preference value is set", func() { var _ = JustBeforeEach(func() { @@ -113,7 +144,7 @@ var _ = Describe("odo preference and config command tests", func() { output := helper.Cmd("odo", "preference", "view").ShouldPass().Out() Expect(output).ToNot(ContainSubstring(promptMessageSubString)) - output = helper.Cmd("odo", "preference", "set", "timeout", "5", "-f").ShouldPass().Out() + output = helper.Cmd("odo", "preference", "set", "timeout", "5s", "-f").ShouldPass().Out() Expect(output).ToNot(ContainSubstring(promptMessageSubString)) output = helper.Cmd("odo", "preference", "unset", "timeout", "-f").ShouldPass().Out() diff --git a/vendor/k8s.io/utils/pointer/pointer.go b/vendor/k8s.io/utils/pointer/pointer.go index 2cab2c580..f5802d2e8 100644 --- a/vendor/k8s.io/utils/pointer/pointer.go +++ b/vendor/k8s.io/utils/pointer/pointer.go @@ -19,6 +19,7 @@ package pointer import ( "fmt" "reflect" + "time" ) // AllPtrFieldsNil tests whether all pointer fields in a struct are nil. This is useful when, @@ -184,7 +185,7 @@ func StringEqual(a, b *string) bool { return *a == *b } -// Float32 returns a pointer to the a float32. +// Float32 returns a pointer to a float32. func Float32(i float32) *float32 { return &i } @@ -214,7 +215,7 @@ func Float32Equal(a, b *float32) bool { return *a == *b } -// Float64 returns a pointer to the a float64. +// Float64 returns a pointer to a float64. func Float64(i float64) *float64 { return &i } @@ -243,3 +244,29 @@ func Float64Equal(a, b *float64) bool { } return *a == *b } + +// Duration returns a pointer to a time.Duration. +func Duration(d time.Duration) *time.Duration { + return &d +} + +// DurationDeref dereferences the time.Duration ptr and returns it if not nil, or else +// returns def. +func DurationDeref(ptr *time.Duration, def time.Duration) time.Duration { + if ptr != nil { + return *ptr + } + return def +} + +// DurationEqual returns true if both arguments are nil or both arguments +// dereference to the same value. +func DurationEqual(a, b *time.Duration) bool { + if (a == nil) != (b == nil) { + return false + } + if a == nil { + return true + } + return *a == *b +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 90a4463ed..005baaf71 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -116,8 +116,6 @@ github.com/danieljoos/wincred # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/deislabs/oras v0.8.1 -## explicit; go 1.13 # github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf ## explicit; go 1.13 github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2 @@ -341,8 +339,6 @@ github.com/hashicorp/go-multierror # github.com/hashicorp/go-version v1.4.0 ## explicit github.com/hashicorp/go-version -# github.com/hashicorp/hcl v1.0.0 -## explicit # github.com/hinshun/vt10x v0.0.0-20220127042424-3ca73d0126d7 ## explicit; go 1.14 github.com/hinshun/vt10x @@ -410,8 +406,6 @@ github.com/kylelemons/godebug/pretty # github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de ## explicit github.com/liggitt/tabwriter -# github.com/magiconair/properties v1.8.1 -## explicit # github.com/mailru/easyjson v0.7.6 ## explicit; go 1.12 github.com/mailru/easyjson/buffer @@ -438,8 +432,6 @@ github.com/mitchellh/go-homedir # github.com/mitchellh/go-wordwrap v1.0.0 ## explicit github.com/mitchellh/go-wordwrap -# github.com/mitchellh/mapstructure v1.1.2 -## explicit # github.com/mitchellh/reflectwalk v1.0.1 ## explicit github.com/mitchellh/reflectwalk @@ -587,8 +579,6 @@ github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientse # github.com/pborman/uuid v1.2.0 ## explicit github.com/pborman/uuid -# github.com/pelletier/go-toml v1.8.1 -## explicit; go 1.12 # github.com/peterbourgon/diskv v2.0.1+incompatible ## explicit github.com/peterbourgon/diskv @@ -693,23 +683,15 @@ github.com/sirupsen/logrus ## explicit github.com/spf13/afero github.com/spf13/afero/mem -# github.com/spf13/cast v1.3.0 -## explicit # github.com/spf13/cobra v1.1.3 ## explicit; go 1.12 github.com/spf13/cobra -# github.com/spf13/jwalterweatherman v1.0.0 -## explicit # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# github.com/spf13/viper v1.7.1 -## explicit; go 1.12 # github.com/stretchr/testify v1.7.0 ## explicit; go 1.13 github.com/stretchr/testify/assert -# github.com/subosito/gotenv v1.2.0 -## explicit # github.com/tidwall/gjson v1.9.3 ## explicit; go 1.12 github.com/tidwall/gjson @@ -933,8 +915,6 @@ gopkg.in/fsnotify.v1 # gopkg.in/inf.v0 v0.9.1 ## explicit gopkg.in/inf.v0 -# gopkg.in/ini.v1 v1.51.0 -## explicit # gopkg.in/segmentio/analytics-go.v3 v3.1.0 ## explicit gopkg.in/segmentio/analytics-go.v3 @@ -1283,7 +1263,7 @@ k8s.io/kubectl/pkg/util/openapi/validation k8s.io/kubectl/pkg/util/templates k8s.io/kubectl/pkg/util/term k8s.io/kubectl/pkg/validation -# k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a +# k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 ## explicit; go 1.12 k8s.io/utils/buffer k8s.io/utils/exec