diff --git a/docs/cmd/tkn_hub_reinstall_task.md b/docs/cmd/tkn_hub_reinstall_task.md index a840b7054f..3cb483786f 100644 --- a/docs/cmd/tkn_hub_reinstall_task.md +++ b/docs/cmd/tkn_hub_reinstall_task.md @@ -22,7 +22,7 @@ Reinstall a Task of name 'foo': or Reinstall a Task of name 'foo' of version '0.3' from Catalog 'Tekton': - + tkn hub reinstall task foo --version 0.3 --from tekton diff --git a/go.mod b/go.mod index 5bc665ece8..fa8b5effdc 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/golang/snappy v0.0.4 github.com/google/go-cmp v0.5.7 github.com/google/go-containerregistry v0.8.1-0.20220216220642-00c59d91847c - github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 + github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b github.com/hashicorp/errwrap v1.1.0 github.com/hashicorp/go-hclog v1.0.0 github.com/hashicorp/go-immutable-radix v1.3.1 @@ -42,7 +42,7 @@ require ( github.com/spf13/cobra v1.3.0 github.com/spf13/pflag v1.0.5 github.com/tektoncd/chains v0.6.2-0.20211214203153-0c28d2682758 - github.com/tektoncd/hub/api v0.0.0-20220128080824-5941f280d06a + github.com/tektoncd/hub v1.6.1-0.20220304075515-3ebdb197f089 github.com/tektoncd/pipeline v0.33.1 github.com/tektoncd/plumbing v0.0.0-20211012143332-c7cc43d9bc0c github.com/tektoncd/triggers v0.19.0 diff --git a/go.sum b/go.sum index 2b060e82c0..e2936da0ff 100644 --- a/go.sum +++ b/go.sum @@ -101,7 +101,6 @@ contrib.go.opencensus.io/exporter/aws v0.0.0-20200617204711-c478e41e60e9/go.mod contrib.go.opencensus.io/exporter/ocagent v0.5.0/go.mod h1:ImxhfLRpxoYiSq891pBrLVhN+qmP8BTVvdH2YLs7Gl0= contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d h1:LblfooH1lKOpp1hIhukktmSAxFkqMPFk9KR6iZ0MJNI= contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d/go.mod h1:IshRmMJBhDfFj5Y67nVhMYTTIze91RUeT73ipWKs/GY= -contrib.go.opencensus.io/exporter/prometheus v0.2.1-0.20200609204449-6bcf6f8577f0/go.mod h1:MjHoxkI7Ny27toPeFkRbXbzVjzIGkwOAptrAy8Mxtm8= contrib.go.opencensus.io/exporter/prometheus v0.3.0/go.mod h1:rpCPVQKhiyH8oomWgm34ZmgIdZa8OVYO5WAIygPbBBE= contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= @@ -117,7 +116,6 @@ cuelang.org/go v0.4.0/go.mod h1:tz/edkPi+T37AZcb5GlPY+WJkL6KiDlDVupKwL3vvjs= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -git.maze.io/go/duration v0.0.0-20160924141736-faac084b6075/go.mod h1:y9MVD7vG8A7scVb2MvTVxN0z+DHTzxnWgOisOnFe5kc= github.com/AdaLogics/go-fuzz-headers v0.0.0-20211102141018-f7be0cbad29c/go.mod h1:WpB7kf89yJUETZxQnP1kgYPNwlT2jjdDYUCoxVggM3g= github.com/AlecAivazis/survey/v2 v2.2.12 h1:5a07y93zA6SZ09gOa9wLVLznF5zTJMQ+pJ3cZK4IuO8= github.com/AlecAivazis/survey/v2 v2.2.12/go.mod h1:6d4saEvBsfSHXeN1a5OA5m2+HJ2LuVokllnC77pAIKI= @@ -492,7 +490,6 @@ github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6 github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -964,7 +961,6 @@ github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= -github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= github.com/go-openapi/validate v0.19.12/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= @@ -1020,7 +1016,6 @@ github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSC github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.2.2/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gobuffalo/flect v0.2.4/go.mod h1:1ZyCLIbg0YD7sDkzvFdPoOydPtD8y9JQnrOROolUcM8= github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= @@ -1079,7 +1074,6 @@ github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0L github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -1328,14 +1322,13 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.2/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-gateway v1.14.8/go.mod h1:NZE8t6vs6TnwLL/ITkaK8W3ecMLGAbh2jXTclvpiwYo= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/h2non/gock v1.0.9/go.mod h1:CZMcB0Lg5IWnr9bF79pPMg9WeV6WumxQiUJ1UvdO1iE= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= -github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw= -github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE= +github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= +github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= @@ -1661,7 +1654,6 @@ github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= -github.com/mailru/easyjson v0.7.1-0.20191009090205-6c0755d89d1e/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -1966,7 +1958,6 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= -github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -1996,7 +1987,6 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.19.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= @@ -2012,7 +2002,6 @@ github.com/prometheus/procfs v0.0.0-20190522114515-bc1a522cf7b1/go.mod h1:TjEm7z github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/prometheus/procfs v0.0.6/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -2022,7 +2011,6 @@ github.com/prometheus/procfs v0.7.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.1/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/statsd_exporter v0.15.0/go.mod h1:Dv8HnkoLQkeEjkIE4/2ndAA7WL1zHKK7WMqFQqu72rw= github.com/prometheus/statsd_exporter v0.20.0/go.mod h1:YL3FWCG8JBBtaUSxAg4Gz2ZYu22bS84XM89ZQXXTWmQ= github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= @@ -2234,14 +2222,12 @@ github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= github.com/tektoncd/chains v0.6.2-0.20211214203153-0c28d2682758 h1:mGUgS3rQSyv21ydTZE3XUZVxlx9A4oq6thMm4dFvZQQ= github.com/tektoncd/chains v0.6.2-0.20211214203153-0c28d2682758/go.mod h1:l+mZRAvsdEMmlfAjHL7Kbb3ZRATek2IpXhcLg6hx8Qk= -github.com/tektoncd/hub/api v0.0.0-20220128080824-5941f280d06a h1:nsMMdohnmZjVw2goxfyCAHRNTSuHyZBJ2+Kd0eVkXho= -github.com/tektoncd/hub/api v0.0.0-20220128080824-5941f280d06a/go.mod h1:ckgU0iLL6PdwTnma9GkNYfmMVCXdzI8X6vh6GeJrDeM= -github.com/tektoncd/pipeline v0.24.1/go.mod h1:ChFD/vfu14VOtCVlLWdtlvOwXfBfVotULoNV6yz+CKY= +github.com/tektoncd/hub v1.6.1-0.20220304075515-3ebdb197f089 h1:VXndyRkoEOccq0GR3b1DMUjKlrzy5zS8+AdF1rq4K/4= +github.com/tektoncd/hub v1.6.1-0.20220304075515-3ebdb197f089/go.mod h1:c3lL6qU1nFD9TCCrFuEnygB3KcfNn5Tbi27nZ3H6nxA= github.com/tektoncd/pipeline v0.27.1-0.20210830150214-8afd1563782d/go.mod h1:U6p87Pzl8b7Lid1HrMabDFDnKstf6ZmkSLKgPiAkQxY= github.com/tektoncd/pipeline v0.33.0/go.mod h1:FAxcjW5FRSBUDmNVXxv1Lq4YlT6Qjgh85TC9JKcxdX4= github.com/tektoncd/pipeline v0.33.1 h1:h6v0cu14yoJE4ARE7iHUBLx07dU8mp6Q1vvy5hsZoKs= github.com/tektoncd/pipeline v0.33.1/go.mod h1:5Re8byhcUd3afN6m6IKn0SfNvbJCRmQRyEOl7fz0OXo= -github.com/tektoncd/plumbing v0.0.0-20210420200944-17170d5e7bc9/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= github.com/tektoncd/plumbing v0.0.0-20210514044347-f8a9689d5bd5/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= github.com/tektoncd/plumbing v0.0.0-20210902122415-a65b22d5f63b/go.mod h1:b9esRuV1absBvaPzKkjYdKXjC5Tgs8/vh1sz++RiTdc= github.com/tektoncd/plumbing v0.0.0-20211012143332-c7cc43d9bc0c h1:i3re03DILlc68sXwIKLKecnHZ3ictZSlPwC4cumvOzo= @@ -2436,7 +2422,6 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4-0.20200608061201-1901b56b9515/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= @@ -2666,7 +2651,6 @@ golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210326220855-61e056675ecf/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20210331060903-cb1fcc7394e5/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= @@ -2781,12 +2765,10 @@ golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191029155521-f43be2a4598c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2915,7 +2897,6 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -3065,7 +3046,6 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.1.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= @@ -3199,7 +3179,6 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210325224202-eed09b1b5210/go.mod h1:f2Bd7+2PlaVKmvKQ52aspJZXIDaRQBVdOOBfJ5i8OEs= -google.golang.org/genproto v0.0.0-20210330181207-2295ebbda0c6/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210331142528-b7513248f0ba/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210413151531-c14fb6ef47c3/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= @@ -3319,7 +3298,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/evanphx/json-patch.v4 v4.9.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.0/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= @@ -3328,7 +3306,6 @@ gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXa gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/h2non/gentleman.v1 v1.0.4/go.mod h1:JYuHVdFzS4MKOXe0o+chKJ4hCe6tqKKw9XH9YP6WFrg= -gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/h2non/gock.v1 v1.0.16 h1:F11k+OafeuFENsjei5t2vMTSTs9L62AdyTe4E1cgdG8= gopkg.in/h2non/gock.v1 v1.0.16/go.mod h1:XVuDAssexPLwgxCLMvDTWNU5eqklsydR6I5phZ9oPB8= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= @@ -3405,7 +3382,6 @@ honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.2.1/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= k8s.io/api v0.22.5 h1:xk7C+rMjF/EGELiD560jdmwzrB788mfcHiNbMQLIVI8= k8s.io/api v0.22.5/go.mod h1:mEhXyLaSD1qTOf40rRiKXkc+2iCem09rWLlFwhCEiAs= -k8s.io/apiextensions-apiserver v0.19.7/go.mod h1:XJNNtjISNNePDEUClHt/igzMpQcmjVVh88QH+PKztPU= k8s.io/apiextensions-apiserver v0.20.7/go.mod h1:rBGJeRYoDJi1jJFHPA4QWXV6YX/5scZfSdkuMSgWoyA= k8s.io/apiextensions-apiserver v0.21.4/go.mod h1:OoC8LhI9LnV+wKjZkXIBbLUwtnOGJiTRE33qctH5CIk= k8s.io/apiextensions-apiserver v0.22.1/go.mod h1:HeGmorjtRmRLE+Q8dJu6AYRoZccvCMsghwS8XTUYb2c= @@ -3446,7 +3422,6 @@ k8s.io/cri-api v0.20.6/go.mod h1:ew44AjNXwyn1s0U4xCKGodU7J1HzBeZ1MpGrpa5r8Yc= k8s.io/csi-translation-lib v0.19.7/go.mod h1:WghizPQuzuygr2WdpgN2EjcNpDD2V4EAbxFXsgHgSBk= k8s.io/csi-translation-lib v0.21.0/go.mod h1:edq+UMpgqEx3roTuGF/03uIuSOsI986jtu65+ytLlkA= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20201203183100-97869a43a9d9/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= @@ -3484,7 +3459,6 @@ k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ knative.dev/caching v0.0.0-20210803185815-4e553d2275a0/go.mod h1:Vs+HND39+KKaIQp9M3m3Jmt4YtznpitDQ3n53gxbDYQ= knative.dev/eventing v0.25.0 h1:lBKgQFGvyeUyvf+HOyuxFd5cXx+SMqnzqtPi2hXiCi4= knative.dev/eventing v0.25.0/go.mod h1:8jIsrnSONPgv+m63OTzpwZQJiQASYl77C3llCyYlBMU= -knative.dev/hack v0.0.0-20210325223819-b6ab329907d3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20210622141627-e28525d8d260/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20210806075220-815cd312d65c/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20211122162614-813559cefdda/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= @@ -3492,7 +3466,6 @@ knative.dev/hack v0.0.0-20220128200847-51a42b2eb63e/go.mod h1:PHt8x8yX5Z9pPquBEf knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0= knative.dev/networking v0.0.0-20210803181815-acdfd41c575c h1:7G6TQr7ZyIHx35Dn5zuNKUDhlly3KkFxgrKLXeKmjj8= knative.dev/networking v0.0.0-20210803181815-acdfd41c575c/go.mod h1:UA9m1M3rGssy63gVwjSh7CYoWTKZNO8cnY9QsIu7tyo= -knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg= knative.dev/pkg v0.0.0-20210803160015-21eb4c167cc5/go.mod h1:RPk5txNA3apR9X40D4MpUOP9/VqOG8CrtABWfOwGVS4= knative.dev/pkg v0.0.0-20210827184538-2bd91f75571c/go.mod h1:jMSqkNMsrzuy+XR4Yr/BMy7SDVbUOl3KKB6+5MR+ZU8= knative.dev/pkg v0.0.0-20211123135150-787aec59e70a/go.mod h1:fZUlVceKtVNyFU6LokWGk2a9QFQXeSTtnbKOjjkQ690= diff --git a/hack/update-deps.sh b/hack/update-deps.sh index 459b22f99a..4ea69c596a 100755 --- a/hack/update-deps.sh +++ b/hack/update-deps.sh @@ -32,7 +32,7 @@ FLOATING_DEPS=( "github.com/tektoncd/pipeline@master" "github.com/tektoncd/triggers@master" "github.com/tektoncd/plumbing@master" - "github.com/tektoncd/hub/api@master" + "github.com/tektoncd/hub@master" ) # Parse flags to determine any we should pass to dep. diff --git a/vendor/github.com/hako/durafmt/README.md b/vendor/github.com/hako/durafmt/README.md index a7777fffe6..45448f514f 100644 --- a/vendor/github.com/hako/durafmt/README.md +++ b/vendor/github.com/hako/durafmt/README.md @@ -34,7 +34,6 @@ package main import ( "fmt" - "github.com/hako/durafmt" ) @@ -57,7 +56,6 @@ package main import ( "fmt" - "github.com/hako/durafmt" ) @@ -79,7 +77,6 @@ package main import ( "fmt" "time" - "github.com/hako/durafmt" ) @@ -100,7 +97,6 @@ package main import ( "fmt" "time" - "github.com/hako/durafmt" ) @@ -111,6 +107,38 @@ func main() { } ``` +#### Custom Units + +Like `durafmt.Units{}` and `durafmt.Durafmt.Format(units)` to stringify duration with custom units. + +```go +package main + +import ( + "fmt" + "time" + "github.com/hako/durafmt" +) + +func main() { + timeduration := (354 * time.Hour) + (22 * time.Minute) + (1 * time.Second) + (100*time.Microsecond) + duration := durafmt.Parse(timeduration) + // units in portuguese + units, err := durafmt.DefaultUnitsCoder.Decode("ano,semana,dia,hora,minuto,segundo,milissegundo,microssegundo") + if err != nil { + panic(err) + } + fmt.Println(duration.Format(units)) // 2 semanas 18 horas 22 minutos 1 segundo 100 microssegundos + + // custom plural (singular:plural) + units, err = durafmt.DefaultUnitsCoder.Decode("ano,semana:SEMANAS,dia,hora,minuto,segundo,milissegundo,microssegundo") + if err != nil { + panic(err) + } + fmt.Println(duration.Format(units)) // 2 SEMANAS 18 horas 22 minutos 1 segundo 100 microssegundos +} +``` + # Contributing Contributions are welcome! Fork this repo, add your changes and submit a PR. @@ -123,4 +151,4 @@ When contributing, running `go test; go vet; golint` or `golangci-lint` is recom # License -MIT \ No newline at end of file +MIT diff --git a/vendor/github.com/hako/durafmt/durafmt.go b/vendor/github.com/hako/durafmt/durafmt.go index 6203a634ad..128726ed26 100644 --- a/vendor/github.com/hako/durafmt/durafmt.go +++ b/vendor/github.com/hako/durafmt/durafmt.go @@ -11,15 +11,22 @@ import ( ) var ( - units = []string{"years", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds"} + units, _ = DefaultUnitsCoder.Decode("year,week,day,hour,minute,second,millisecond,microsecond") unitsShort = []string{"y", "w", "d", "h", "m", "s", "ms", "µs"} ) // Durafmt holds the parsed duration and the original input duration. type Durafmt struct { - duration time.Duration - input string // Used as reference. - limitN int // Non-zero to limit only first N elements to output. + duration time.Duration + input string // Used as reference. + limitN int // Non-zero to limit only first N elements to output. + limitUnit string // Non-empty to limit max unit +} + +// LimitToUnit sets the output format, you will not have unit bigger than the UNIT specified. UNIT = "" means no restriction. +func (d *Durafmt) LimitToUnit(unit string) *Durafmt { + d.limitUnit = unit + return d } // LimitFirstN sets the output format, outputing only first N elements. n == 0 means no limit. @@ -28,17 +35,21 @@ func (d *Durafmt) LimitFirstN(n int) *Durafmt { return d } +func (d *Durafmt) Duration() time.Duration { + return d.duration +} + // Parse creates a new *Durafmt struct, returns error if input is invalid. func Parse(dinput time.Duration) *Durafmt { input := dinput.String() - return &Durafmt{dinput, input, 0} + return &Durafmt{dinput, input, 0, ""} } // ParseShort creates a new *Durafmt struct, short form, returns error if input is invalid. // It's shortcut for `Parse(dur).LimitFirstN(1)` func ParseShort(dinput time.Duration) *Durafmt { input := dinput.String() - return &Durafmt{dinput, input, 1} + return &Durafmt{dinput, input, 1, ""} } // ParseString creates a new *Durafmt struct from a string. @@ -51,7 +62,7 @@ func ParseString(input string) (*Durafmt, error) { if err != nil { return nil, err } - return &Durafmt{duration, input, 0}, nil + return &Durafmt{duration, input, 0, ""}, nil } // ParseStringShort creates a new *Durafmt struct from a string, short form @@ -65,11 +76,16 @@ func ParseStringShort(input string) (*Durafmt, error) { if err != nil { return nil, err } - return &Durafmt{duration, input, 1}, nil + return &Durafmt{duration, input, 1, ""}, nil } -// String parses d *Durafmt into a human readable duration. +// String parses d *Durafmt into a human readable duration with default units. func (d *Durafmt) String() string { + return d.Format(units) +} + +// Format parses d *Durafmt into a human readable duration with units. +func (d *Durafmt) Format(units Units) string { var duration string // Check for minus durations. @@ -78,55 +94,212 @@ func (d *Durafmt) String() string { d.duration = -d.duration } + var microseconds int64 + var milliseconds int64 + var seconds int64 + var minutes int64 + var hours int64 + var days int64 + var weeks int64 + var years int64 + var shouldConvert = false + + remainingSecondsToConvert := int64(d.duration / time.Microsecond) + // Convert duration. - seconds := int64(d.duration.Seconds()) % 60 - minutes := int64(d.duration.Minutes()) % 60 - hours := int64(d.duration.Hours()) % 24 - days := int64(d.duration/(24*time.Hour)) % 365 % 7 + if d.limitUnit == "" { + shouldConvert = true + } - // Edge case between 364 and 365 days. - // We need to calculate weeks from what is left from years - leftYearDays := int64(d.duration/(24*time.Hour)) % 365 - weeks := leftYearDays / 7 - if leftYearDays >= 364 && leftYearDays < 365 { - weeks = 52 + if d.limitUnit == "years" || shouldConvert { + years = remainingSecondsToConvert / (365 * 24 * 3600 * 1000000) + remainingSecondsToConvert -= years * 365 * 24 * 3600 * 1000000 + shouldConvert = true } - years := int64(d.duration/(24*time.Hour)) / 365 - milliseconds := int64(d.duration/time.Millisecond) - - (seconds * 1000) - (minutes * 60000) - (hours * 3600000) - - (days * 86400000) - (weeks * 604800000) - (years * 31536000000) + if d.limitUnit == "weeks" || shouldConvert { + weeks = remainingSecondsToConvert / (7 * 24 * 3600 * 1000000) + remainingSecondsToConvert -= weeks * 7 * 24 * 3600 * 1000000 + shouldConvert = true + } - microseconds := int64(d.duration/time.Microsecond) - - (milliseconds * 1000) - (seconds * 1000000) - (minutes * 60000000) - (hours * 3600000000) - - (days * 86400000000) - (weeks * 604800000000) - (years * 31536000000000) + if d.limitUnit == "days" || shouldConvert { + days = remainingSecondsToConvert / (24 * 3600 * 1000000) + remainingSecondsToConvert -= days * 24 * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "hours" || shouldConvert { + hours = remainingSecondsToConvert / (3600 * 1000000) + remainingSecondsToConvert -= hours * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "minutes" || shouldConvert { + minutes = remainingSecondsToConvert / (60 * 1000000) + remainingSecondsToConvert -= minutes * 60 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "seconds" || shouldConvert { + seconds = remainingSecondsToConvert / 1000000 + remainingSecondsToConvert -= seconds * 1000000 + shouldConvert = true + } + + if d.limitUnit == "milliseconds" || shouldConvert { + milliseconds = remainingSecondsToConvert / 1000 + remainingSecondsToConvert -= milliseconds * 1000 + } + + microseconds = remainingSecondsToConvert // Create a map of the converted duration time. - durationMap := map[string]int64{ - "microseconds": microseconds, - "milliseconds": milliseconds, - "seconds": seconds, - "minutes": minutes, - "hours": hours, - "days": days, - "weeks": weeks, - "years": years, + durationMap := []int64{ + microseconds, + milliseconds, + seconds, + minutes, + hours, + days, + weeks, + years, } // Construct duration string. - for i := range units { - u := units[i] - v := durationMap[u] + for i, u := range units.Units() { + v := durationMap[7-i] strval := strconv.FormatInt(v, 10) switch { // add to the duration string if v > 1. case v > 1: - duration += strval + " " + u + " " + duration += strval + " " + u.Plural + " " // remove the plural 's', if v is 1. case v == 1: - duration += strval + " " + strings.TrimRight(u, "s") + " " + duration += strval + " " + u.Singular + " " // omit any value with 0s or 0. case d.duration.String() == "0" || d.duration.String() == "0s": + pattern := fmt.Sprintf("^-?0%s$", unitsShort[i]) + isMatch, err := regexp.MatchString(pattern, d.input) + if err != nil { + return "" + } + if isMatch { + duration += strval + " " + u.Plural + } + + // omit any value with 0. + case v == 0: + continue + } + } + // trim any remaining spaces. + duration = strings.TrimSpace(duration) + + // if more than 2 spaces present return the first 2 strings + // if short version is requested + if d.limitN > 0 { + parts := strings.Split(duration, " ") + if len(parts) > d.limitN*2 { + duration = strings.Join(parts[:d.limitN*2], " ") + } + } + + return duration +} + +func (d *Durafmt) InternationalString() string { + var duration string + + // Check for minus durations. + if string(d.input[0]) == "-" { + duration += "-" + d.duration = -d.duration + } + + var microseconds int64 + var milliseconds int64 + var seconds int64 + var minutes int64 + var hours int64 + var days int64 + var weeks int64 + var years int64 + var shouldConvert = false + + remainingSecondsToConvert := int64(d.duration / time.Microsecond) + + // Convert duration. + if d.limitUnit == "" { + shouldConvert = true + } + + if d.limitUnit == "years" || shouldConvert { + years = remainingSecondsToConvert / (365 * 24 * 3600 * 1000000) + remainingSecondsToConvert -= years * 365 * 24 * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "weeks" || shouldConvert { + weeks = remainingSecondsToConvert / (7 * 24 * 3600 * 1000000) + remainingSecondsToConvert -= weeks * 7 * 24 * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "days" || shouldConvert { + days = remainingSecondsToConvert / (24 * 3600 * 1000000) + remainingSecondsToConvert -= days * 24 * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "hours" || shouldConvert { + hours = remainingSecondsToConvert / (3600 * 1000000) + remainingSecondsToConvert -= hours * 3600 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "minutes" || shouldConvert { + minutes = remainingSecondsToConvert / (60 * 1000000) + remainingSecondsToConvert -= minutes * 60 * 1000000 + shouldConvert = true + } + + if d.limitUnit == "seconds" || shouldConvert { + seconds = remainingSecondsToConvert / 1000000 + remainingSecondsToConvert -= seconds * 1000000 + shouldConvert = true + } + + if d.limitUnit == "milliseconds" || shouldConvert { + milliseconds = remainingSecondsToConvert / 1000 + remainingSecondsToConvert -= milliseconds * 1000 + } + + microseconds = remainingSecondsToConvert + + // Create a map of the converted duration time. + durationMap := map[string]int64{ + "µs": microseconds, + "ms": milliseconds, + "s": seconds, + "m": minutes, + "h": hours, + "d": days, + "w": weeks, + "y": years, + } + + // Construct duration string. + for i := range units.Units() { + u := unitsShort[i] + v := durationMap[u] + strval := strconv.FormatInt(v, 10) + switch { + // add to the duration string if v > 0. + case v > 0: + duration += strval + " " + u + " " + // omit any value with 0. + case d.duration.String() == "0": pattern := fmt.Sprintf("^-?0%s$", unitsShort[i]) isMatch, err := regexp.MatchString(pattern, d.input) if err != nil { diff --git a/vendor/github.com/hako/durafmt/go.mod b/vendor/github.com/hako/durafmt/go.mod new file mode 100644 index 0000000000..72a9f5b714 --- /dev/null +++ b/vendor/github.com/hako/durafmt/go.mod @@ -0,0 +1,3 @@ +module github.com/hako/durafmt + +go 1.11 diff --git a/vendor/github.com/hako/durafmt/unit.go b/vendor/github.com/hako/durafmt/unit.go new file mode 100644 index 0000000000..041f0b1b59 --- /dev/null +++ b/vendor/github.com/hako/durafmt/unit.go @@ -0,0 +1,108 @@ +package durafmt + +import ( + "fmt" + "strings" +) + +// DefaultUnitsCoder default units coder using `":"` as PluralSep and `","` as UnitsSep +var DefaultUnitsCoder = UnitsCoder{":", ","} + +// Unit the pair of singular and plural units +type Unit struct { + Singular, Plural string +} + +// Units duration units +type Units struct { + Year, Week, Day, Hour, Minute, + Second, Millisecond, Microsecond Unit +} + +// Units return a slice of units +func (u Units) Units() []Unit { + return []Unit{u.Year, u.Week, u.Day, u.Hour, u.Minute, + u.Second, u.Millisecond, u.Microsecond} +} + +// UnitsCoder the units encoder and decoder +type UnitsCoder struct { + // PluralSep char to sep singular and plural pair. + // Example with char `":"`: `"year:year"` (english) or `"mês:meses"` (portuguese) + PluralSep, + // UnitsSep char to sep units (singular and plural pairs). + // Example with char `","`: `"year:year,week:weeks"` (english) or `"mês:meses,semana:semanas"` (portuguese) + UnitsSep string +} + +// Encode encodes input Units to string +// Examples with `UnitsCoder{PluralSep: ":", UnitsSep = ","}` +// - singular and plural pair units: `"year:wers,week:weeks,day:days,hour:hours,minute:minutes,second:seconds,millisecond:millliseconds,microsecond:microsseconds"` +func (coder UnitsCoder) Encode(units Units) string { + var pairs = make([]string, 8) + for i, u := range units.Units() { + pairs[i] = u.Singular + coder.PluralSep + u.Plural + } + return strings.Join(pairs, coder.UnitsSep) +} + +// Decode decodes input string to Units. +// The input must follow the following formats: +// - Unit format (singular and plural pair) +// - must singular (the plural receives 's' character as suffix) +// - singular and plural: separated by `PluralSep` char +// Example with char `":"`: `"year:year"` (english) or `"mês:meses"` (portuguese) +// - Units format (pairs of Year, Week, Day, Hour, Minute, +// Second, Millisecond and Microsecond units) separated by `UnitsSep` char +// - Examples with `UnitsCoder{PluralSep: ":", UnitsSep = ","}` +// - must singular units: `"year,week,day,hour,minute,second,millisecond,microsecond"` +// - mixed units: `"year,week:weeks,day,hour,minute:minutes,second,millisecond,microsecond"` +// - singular and plural pair units: `"year:wers,week:weeks,day:days,hour:hours,minute:minutes,second:seconds,millisecond:millliseconds,microsecond:microsseconds"` +func (coder UnitsCoder) Decode(s string) (units Units, err error) { + parts := strings.Split(s, coder.UnitsSep) + if len(parts) != 8 { + err = fmt.Errorf("bad parts length") + return units, err + } + + var parse = func(name, part string, u *Unit) bool { + ps := strings.Split(part, coder.PluralSep) + switch len(ps) { + case 1: + // create plural form with sigular + 's' suffix + u.Singular, u.Plural = ps[0], ps[0]+"s" + case 2: + u.Singular, u.Plural = ps[0], ps[1] + default: + err = fmt.Errorf("bad unit %q pair length", name) + return false + } + return true + } + + if !parse("Year", parts[0], &units.Year) { + return units, err + } + if !parse("Week", parts[1], &units.Week) { + return units, err + } + if !parse("Day", parts[2], &units.Day) { + return units, err + } + if !parse("Hour", parts[3], &units.Hour) { + return units, err + } + if !parse("Minute", parts[4], &units.Minute) { + return units, err + } + if !parse("Second", parts[5], &units.Second) { + return units, err + } + if !parse("Millisecond", parts[6], &units.Millisecond) { + return units, err + } + if !parse("Microsecond", parts[7], &units.Microsecond) { + return units, err + } + return units, err +} diff --git a/vendor/github.com/tektoncd/hub/api/LICENSE b/vendor/github.com/tektoncd/hub/LICENSE similarity index 100% rename from vendor/github.com/tektoncd/hub/api/LICENSE rename to vendor/github.com/tektoncd/hub/LICENSE diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/downgrade/downgrade.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/downgrade/downgrade.go index a3feed70ec..90f9369fe5 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/downgrade/downgrade.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/downgrade/downgrade.go @@ -35,15 +35,16 @@ const ( ) type options struct { - cli app.CLI - version string - kind string - args []string - kc kube.Config - cs kube.ClientSet - hubRes hub.ResourceVersionResult - hubResVersions *hub.ResVersions - resource *unstructured.Unstructured + cli app.CLI + version string + kind string + args []string + kc kube.Config + cs kube.ClientSet + hubRes hub.ResourceResult + hubResVerResult hub.ResourceVersionResult + hubResVersions *hub.ResVersions + resource *unstructured.Unstructured } var cmdExamples string = ` @@ -133,14 +134,14 @@ func (opts *options) run() error { existingVersion := opts.resVersion() hubClient := opts.cli.Hub() - opts.hubRes = hubClient.GetResourceVersions(hub.ResourceOption{ + opts.hubResVerResult = hubClient.GetResourceVersions(hub.ResourceOption{ Name: opts.name(), Catalog: catalog, Kind: opts.kind, Version: existingVersion, }) - opts.hubResVersions, err = opts.hubRes.ResourceVersions() + opts.hubResVersions, err = opts.hubResVerResult.ResourceVersions() if err != nil { return err } @@ -150,7 +151,14 @@ func (opts *options) run() error { return err } - manifest, err := opts.hubRes.VersionManifest(opts.version) + opts.hubRes = hubClient.GetResourceYaml(hub.ResourceOption{ + Name: opts.name(), + Catalog: catalog, + Kind: opts.kind, + Version: opts.version, + }) + + manifest, err := opts.hubRes.ResourceYaml() if err != nil { return err } @@ -158,7 +166,7 @@ func (opts *options) run() error { out := opts.cli.Stream().Out var errors []error - opts.resource, errors = resInstaller.Downgrade(manifest, catalog, opts.cs.Namespace()) + opts.resource, errors = resInstaller.Downgrade([]byte(manifest), catalog, opts.cs.Namespace()) if len(errors) != 0 { resourcePipelineMinVersion := opts.resource.GetAnnotations()[installer.ResourceMinVersion] diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/get.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/get.go index a96dec3a72..7c2bc1d422 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/get.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/get.go @@ -106,15 +106,20 @@ func (opts *options) run() error { return err } - resource := opts.hubClient.GetResource(hub.ResourceOption{ + resource := opts.hubClient.GetResourceYaml(hub.ResourceOption{ Name: name, Catalog: opts.from, Kind: opts.kind, Version: opts.version, }) + data, err := resource.ResourceYaml() + if err != nil { + return err + } + out := opts.cli.Stream().Out - return printer.New(out).Raw(resource.Manifest()) + return printer.New(out).Raw([]byte(data), nil) } func (opts *options) validate() error { diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/task.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/task.go index 9ddfa2d2ec..d6455a48de 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/task.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/get/task.go @@ -15,7 +15,7 @@ package get import ( - "bytes" + "strings" "github.com/spf13/cobra" "github.com/tektoncd/hub/api/pkg/cli/hub" @@ -66,14 +66,14 @@ func (opts *taskOptions) run() error { return err } - resource := opts.hubClient.GetResource(hub.ResourceOption{ + resource := opts.hubClient.GetResourceYaml(hub.ResourceOption{ Name: name, Catalog: opts.from, Kind: opts.kind, Version: opts.version, }) - data, err := resource.Manifest() + data, err := resource.ResourceYaml() if err != nil { return err } @@ -83,9 +83,9 @@ func (opts *taskOptions) run() error { } out := opts.cli.Stream().Out - return printer.New(out).Raw(data, nil) + return printer.New(out).Raw([]byte(data), nil) } -func taskToClusterTask(data []byte) []byte { - return bytes.Replace(data, []byte("kind: Task"), []byte("kind: ClusterTask"), 1) +func taskToClusterTask(data string) string { + return strings.ReplaceAll(data, "kind: Task", "kind: ClusterTask") } diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/install/install.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/install/install.go index a5dd617fa8..2e3746dee4 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/install/install.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/install/install.go @@ -114,14 +114,28 @@ func (opts *options) run() error { } hubClient := opts.cli.Hub() - opts.hubRes = hubClient.GetResource(hub.ResourceOption{ + + if opts.version == "" { + version, err := hubClient.GetResourceVersionslist(hub.ResourceOption{ + Name: opts.name(), + Catalog: opts.from, + Kind: opts.kind, + }) + if err != nil { + return err + } + // Get the latest version of the resource + opts.version = version[0] + } + + opts.hubRes = hubClient.GetResourceYaml(hub.ResourceOption{ Name: opts.name(), Catalog: opts.from, Kind: opts.kind, Version: opts.version, }) - manifest, err := opts.hubRes.Manifest() + manifest, err := opts.hubRes.ResourceYaml() if err != nil { return opts.isResourceNotFoundError(err) } @@ -139,7 +153,7 @@ func (opts *options) run() error { resourceInstaller := installer.New(opts.cs) var errors []error - opts.resource, errors = resourceInstaller.Install(manifest, opts.from, opts.cs.Namespace()) + opts.resource, errors = resourceInstaller.Install([]byte(manifest), opts.from, opts.cs.Namespace()) if len(errors) != 0 { resourcePipelineMinVersion, err := opts.hubRes.MinPipelinesVersion() diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/reinstall/reinstall.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/reinstall/reinstall.go index f313cef1f6..6b87bdb16c 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/reinstall/reinstall.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/reinstall/reinstall.go @@ -54,7 +54,7 @@ Reinstall a %S of name 'foo': or Reinstall a %S of name 'foo' of version '0.3' from Catalog 'Tekton': - + tkn hub reinstall %s foo --version 0.3 --from tekton ` @@ -131,14 +131,15 @@ func (opts *options) run() error { } hubClient := opts.cli.Hub() - opts.hubRes = hubClient.GetResource(hub.ResourceOption{ + + opts.hubRes = hubClient.GetResourceYaml(hub.ResourceOption{ Name: opts.name(), Catalog: opts.resCatalog(), Kind: opts.kind, Version: opts.resVersion(), }) - manifest, err := opts.hubRes.Manifest() + manifest, err := opts.hubRes.ResourceYaml() if err != nil { return opts.isResourceNotFoundError(err) } @@ -146,7 +147,7 @@ func (opts *options) run() error { out := opts.cli.Stream().Out var errors []error - opts.resource, errors = resInstaller.Update(manifest, opts.from, opts.cs.Namespace()) + opts.resource, errors = resInstaller.Update([]byte(manifest), opts.from, opts.cs.Namespace()) if len(errors) != 0 { resourcePipelineMinVersion, vErr := opts.hubRes.MinPipelinesVersion() if vErr != nil { diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/upgrade/upgrade.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/upgrade/upgrade.go index 6303f48eeb..a72f9d16c8 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/upgrade/upgrade.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/cmd/upgrade/upgrade.go @@ -131,14 +131,28 @@ func (opts *options) run() error { catalog := opts.resCatalog() hubClient := opts.cli.Hub() - opts.hubRes = hubClient.GetResource(hub.ResourceOption{ + + if opts.version == "" { + version, err := hubClient.GetResourceVersionslist(hub.ResourceOption{ + Name: opts.name(), + Catalog: catalog, + Kind: opts.kind, + }) + if err != nil { + return err + } + // Get the latest version of the resource + opts.version = version[0] + } + + opts.hubRes = hubClient.GetResourceYaml(hub.ResourceOption{ Name: opts.name(), Catalog: catalog, Kind: opts.kind, Version: opts.version, }) - manifest, err := opts.hubRes.Manifest() + manifest, err := opts.hubRes.ResourceYaml() if err != nil { return err } @@ -146,7 +160,7 @@ func (opts *options) run() error { out := opts.cli.Stream().Out var errors []error - opts.resource, errors = resInstaller.Upgrade(manifest, catalog, opts.cs.Namespace()) + opts.resource, errors = resInstaller.Upgrade([]byte(manifest), catalog, opts.cs.Namespace()) if len(errors) != 0 { resourcePipelineMinVersion, vErr := opts.hubRes.MinPipelinesVersion() diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource.go index 957a5eb9e5..a479ae9748 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource.go @@ -37,12 +37,16 @@ type ResourceOption struct { // ResourceResult defines API response type ResourceResult struct { data []byte + yaml []byte status int + yamlStatus int + yamlErr error err error version string set bool resourceData *ResourceData resourceWithVersionData *ResourceWithVersionData + ResourceContent *ResourceContent } type ResourceVersionOptions struct { @@ -60,10 +64,14 @@ type resVersionResponse = rclient.ByCatalogKindNameVersionResponseBody // ResourceData is the response of API when finding a resource type ResourceData = rclient.ResourceDataResponseBody +type ResourceContent = rclient.ResourceContentResponseBody + // ResourceWithVersionData is the response of API when finding a resource // with a specific version type ResourceWithVersionData = rclient.ResourceVersionDataResponseBody +type resourceYaml = rclient.ByCatalogKindNameVersionYamlResponseBody + // GetResource queries the data using Hub Endpoint func (c *client) GetResource(opt ResourceOption) ResourceResult { data, status, err := c.Get(opt.Endpoint()) @@ -77,6 +85,24 @@ func (c *client) GetResource(opt ResourceOption) ResourceResult { } } +// GetResource queries the data using Hub Endpoint +func (c *client) GetResourceYaml(opt ResourceOption) ResourceResult { + + yaml, yamlStatus, yamlErr := c.Get(fmt.Sprintf("/v1/resource/%s/%s/%s/%s/yaml", opt.Catalog, opt.Kind, opt.Name, opt.Version)) + data, status, err := c.Get(opt.Endpoint()) + + return ResourceResult{ + data: data, + yaml: yaml, + version: opt.Version, + status: status, + err: err, + yamlStatus: yamlStatus, + yamlErr: yamlErr, + set: false, + } +} + // Endpoint computes the endpoint url using input provided func (opt ResourceOption) Endpoint() string { if opt.Version != "" { @@ -111,6 +137,7 @@ func (rr *ResourceResult) unmarshalData() error { return err } rr.resourceData = res.Data + rr.set = true return nil } @@ -169,6 +196,29 @@ func (rr *ResourceResult) Resource() (interface{}, error) { return *rr.resourceData, nil } +// Resource returns the resource found +func (rr *ResourceResult) ResourceYaml() (string, error) { + + if rr.yamlErr != nil { + return "", rr.err + } + if rr.set { + return "", nil + } + + if rr.yamlStatus == http.StatusNotFound { + return "", fmt.Errorf("No Resource Found") + } + + res := resourceYaml{} + if err := json.Unmarshal(rr.yaml, &res); err != nil { + return "", err + } + rr.ResourceContent = res.Data + + return *rr.ResourceContent.Yaml, nil +} + // ResourceVersion returns the resource version found func (rr *ResourceResult) ResourceVersion() (string, error) { if err := rr.unmarshalData(); err != nil { diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource_version.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource_version.go index 39253a3014..88d07085d5 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource_version.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/get_resource_version.go @@ -17,7 +17,6 @@ package hub import ( "encoding/json" "fmt" - "net/http" "strconv" rclient "github.com/tektoncd/hub/api/v1/gen/http/resource/client" @@ -92,33 +91,3 @@ func (rvr *ResourceVersionResult) ResourceVersions() (*ResVersions, error) { return rvr.versions, nil } - -// VersionManifest gets the resource from catalog for the resource's version passed -func (rvr *ResourceVersionResult) VersionManifest(version string) ([]byte, error) { - - if err := rvr.unmarshalData(); err != nil { - return nil, err - } - - var rawURL string - for _, v := range rvr.versions.Versions { - if version == *v.Version { - rawURL = *v.RawURL - break - } - } - if rawURL == "" { - return nil, fmt.Errorf("resource version (v%s) not found", version) - } - - data, status, err := httpGet(rawURL) - if err != nil { - return nil, err - } - - if status != http.StatusOK { - return nil, fmt.Errorf("failed to fetch resource from catalog") - } - - return data, nil -} diff --git a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/hub.go b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/hub.go index 71e425678d..26e63b31d6 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/hub.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/cli/hub/hub.go @@ -37,6 +37,7 @@ type Client interface { GetCatalogsList() ([]string, error) Search(opt SearchOption) SearchResult GetResource(opt ResourceOption) ResourceResult + GetResourceYaml(opt ResourceOption) ResourceResult GetResourcesList(opt SearchOption) ([]string, error) GetResourceVersions(opt ResourceOption) ResourceVersionResult GetResourceVersionslist(opt ResourceOption) ([]string, error) diff --git a/vendor/github.com/tektoncd/hub/api/pkg/git/fetch_spec.go b/vendor/github.com/tektoncd/hub/api/pkg/git/fetch_spec.go index 27bdfd651b..45d4b11446 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/git/fetch_spec.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/git/fetch_spec.go @@ -15,28 +15,30 @@ package git import ( - "net/url" "path/filepath" "strings" ) // FetchSpec describes how to initialize and fetch from a Git repository. type FetchSpec struct { - URL string - Revision string - Path string - Depth uint - SSLVerify bool + URL string + SSHUrl string + Revision string + Path string + Depth uint + SSLVerify bool + CatalogName string } func (f *FetchSpec) sanitize() { f.URL = strings.TrimSpace(f.URL) + f.SSHUrl = strings.TrimSpace(f.SSHUrl) f.Path = strings.TrimSpace(f.Path) f.Revision = strings.TrimSpace(f.Revision) + f.CatalogName = strings.TrimSpace(f.CatalogName) } func (f *FetchSpec) clonePath() string { f.sanitize() - u, _ := url.Parse(f.URL) - return filepath.Join(f.Path, u.Host, u.Path+"@"+f.Revision) + return filepath.Join(f.Path, f.CatalogName) } diff --git a/vendor/github.com/tektoncd/hub/api/pkg/git/git.go b/vendor/github.com/tektoncd/hub/api/pkg/git/git.go index 5c5e9a7c47..56225cd1a3 100644 --- a/vendor/github.com/tektoncd/hub/api/pkg/git/git.go +++ b/vendor/github.com/tektoncd/hub/api/pkg/git/git.go @@ -74,7 +74,14 @@ func (c *client) Fetch(spec FetchSpec) (Repo, error) { } func (c *client) initRepo(spec FetchSpec) (*LocalRepo, error) { - log := c.log.With("name", "repo").With("url", spec.URL) + + cloneUrl := spec.URL + + if spec.SSHUrl != "" { + cloneUrl = spec.SSHUrl + } + + log := c.log.With("name", "repo").With("url", cloneUrl) clonePath := spec.clonePath() repo := &LocalRepo{path: clonePath} @@ -95,7 +102,7 @@ func (c *client) initRepo(spec FetchSpec) (*LocalRepo, error) { return nil, fmt.Errorf("failed to change directory with path %s; err: %w", spec.Path, err) } - if _, err := git(log, "", "remote", "add", "origin", spec.URL); err != nil { + if _, err := git(log, "", "remote", "add", "origin", cloneUrl); err != nil { return nil, err } diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/cli.go b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/cli.go index 5bbb778c21..b07d964794 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/cli.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/cli.go @@ -182,6 +182,76 @@ func BuildByCatalogKindNameVersionPayload(resourceByCatalogKindNameVersionCatalo return v, nil } +// BuildByCatalogKindNameVersionReadmePayload builds the payload for the +// resource ByCatalogKindNameVersionReadme endpoint from CLI flags. +func BuildByCatalogKindNameVersionReadmePayload(resourceByCatalogKindNameVersionReadmeCatalog string, resourceByCatalogKindNameVersionReadmeKind string, resourceByCatalogKindNameVersionReadmeName string, resourceByCatalogKindNameVersionReadmeVersion string) (*resource.ByCatalogKindNameVersionReadmePayload, error) { + var err error + var catalog string + { + catalog = resourceByCatalogKindNameVersionReadmeCatalog + } + var kind string + { + kind = resourceByCatalogKindNameVersionReadmeKind + if !(kind == "task" || kind == "pipeline") { + err = goa.MergeErrors(err, goa.InvalidEnumValueError("kind", kind, []interface{}{"task", "pipeline"})) + } + if err != nil { + return nil, err + } + } + var name string + { + name = resourceByCatalogKindNameVersionReadmeName + } + var version string + { + version = resourceByCatalogKindNameVersionReadmeVersion + } + v := &resource.ByCatalogKindNameVersionReadmePayload{} + v.Catalog = catalog + v.Kind = kind + v.Name = name + v.Version = version + + return v, nil +} + +// BuildByCatalogKindNameVersionYamlPayload builds the payload for the resource +// ByCatalogKindNameVersionYaml endpoint from CLI flags. +func BuildByCatalogKindNameVersionYamlPayload(resourceByCatalogKindNameVersionYamlCatalog string, resourceByCatalogKindNameVersionYamlKind string, resourceByCatalogKindNameVersionYamlName string, resourceByCatalogKindNameVersionYamlVersion string) (*resource.ByCatalogKindNameVersionYamlPayload, error) { + var err error + var catalog string + { + catalog = resourceByCatalogKindNameVersionYamlCatalog + } + var kind string + { + kind = resourceByCatalogKindNameVersionYamlKind + if !(kind == "task" || kind == "pipeline") { + err = goa.MergeErrors(err, goa.InvalidEnumValueError("kind", kind, []interface{}{"task", "pipeline"})) + } + if err != nil { + return nil, err + } + } + var name string + { + name = resourceByCatalogKindNameVersionYamlName + } + var version string + { + version = resourceByCatalogKindNameVersionYamlVersion + } + v := &resource.ByCatalogKindNameVersionYamlPayload{} + v.Catalog = catalog + v.Kind = kind + v.Name = name + v.Version = version + + return v, nil +} + // BuildByVersionIDPayload builds the payload for the resource ByVersionId // endpoint from CLI flags. func BuildByVersionIDPayload(resourceByVersionIDVersionID string) (*resource.ByVersionIDPayload, error) { diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/client.go b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/client.go index e43b48ec18..31d58b1244 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/client.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/client.go @@ -31,6 +31,14 @@ type Client struct { // the ByCatalogKindNameVersion endpoint. ByCatalogKindNameVersionDoer goahttp.Doer + // ByCatalogKindNameVersionReadme Doer is the HTTP client used to make requests + // to the ByCatalogKindNameVersionReadme endpoint. + ByCatalogKindNameVersionReadmeDoer goahttp.Doer + + // ByCatalogKindNameVersionYaml Doer is the HTTP client used to make requests + // to the ByCatalogKindNameVersionYaml endpoint. + ByCatalogKindNameVersionYamlDoer goahttp.Doer + // ByVersionID Doer is the HTTP client used to make requests to the ByVersionId // endpoint. ByVersionIDDoer goahttp.Doer @@ -65,19 +73,21 @@ func NewClient( restoreBody bool, ) *Client { return &Client{ - QueryDoer: doer, - ListDoer: doer, - VersionsByIDDoer: doer, - ByCatalogKindNameVersionDoer: doer, - ByVersionIDDoer: doer, - ByCatalogKindNameDoer: doer, - ByIDDoer: doer, - CORSDoer: doer, - RestoreResponseBody: restoreBody, - scheme: scheme, - host: host, - decoder: dec, - encoder: enc, + QueryDoer: doer, + ListDoer: doer, + VersionsByIDDoer: doer, + ByCatalogKindNameVersionDoer: doer, + ByCatalogKindNameVersionReadmeDoer: doer, + ByCatalogKindNameVersionYamlDoer: doer, + ByVersionIDDoer: doer, + ByCatalogKindNameDoer: doer, + ByIDDoer: doer, + CORSDoer: doer, + RestoreResponseBody: restoreBody, + scheme: scheme, + host: host, + decoder: dec, + encoder: enc, } } @@ -167,6 +177,44 @@ func (c *Client) ByCatalogKindNameVersion() goa.Endpoint { } } +// ByCatalogKindNameVersionReadme returns an endpoint that makes HTTP requests +// to the resource service ByCatalogKindNameVersionReadme server. +func (c *Client) ByCatalogKindNameVersionReadme() goa.Endpoint { + var ( + decodeResponse = DecodeByCatalogKindNameVersionReadmeResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v interface{}) (interface{}, error) { + req, err := c.BuildByCatalogKindNameVersionReadmeRequest(ctx, v) + if err != nil { + return nil, err + } + resp, err := c.ByCatalogKindNameVersionReadmeDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("resource", "ByCatalogKindNameVersionReadme", err) + } + return decodeResponse(resp) + } +} + +// ByCatalogKindNameVersionYaml returns an endpoint that makes HTTP requests to +// the resource service ByCatalogKindNameVersionYaml server. +func (c *Client) ByCatalogKindNameVersionYaml() goa.Endpoint { + var ( + decodeResponse = DecodeByCatalogKindNameVersionYamlResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v interface{}) (interface{}, error) { + req, err := c.BuildByCatalogKindNameVersionYamlRequest(ctx, v) + if err != nil { + return nil, err + } + resp, err := c.ByCatalogKindNameVersionYamlDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("resource", "ByCatalogKindNameVersionYaml", err) + } + return decodeResponse(resp) + } +} + // ByVersionID returns an endpoint that makes HTTP requests to the resource // service ByVersionId server. func (c *Client) ByVersionID() goa.Endpoint { diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/encode_decode.go b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/encode_decode.go index 73567e923f..53ff2256d4 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/encode_decode.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/encode_decode.go @@ -450,6 +450,219 @@ func DecodeByCatalogKindNameVersionResponse(decoder func(*http.Response) goahttp } } +// BuildByCatalogKindNameVersionReadmeRequest instantiates a HTTP request +// object with method and path set to call the "resource" service +// "ByCatalogKindNameVersionReadme" endpoint +func (c *Client) BuildByCatalogKindNameVersionReadmeRequest(ctx context.Context, v interface{}) (*http.Request, error) { + var ( + catalog string + kind string + name string + version string + ) + { + p, ok := v.(*resource.ByCatalogKindNameVersionReadmePayload) + if !ok { + return nil, goahttp.ErrInvalidType("resource", "ByCatalogKindNameVersionReadme", "*resource.ByCatalogKindNameVersionReadmePayload", v) + } + catalog = p.Catalog + kind = p.Kind + name = p.Name + version = p.Version + } + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: ByCatalogKindNameVersionReadmeResourcePath(catalog, kind, name, version)} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("resource", "ByCatalogKindNameVersionReadme", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// DecodeByCatalogKindNameVersionReadmeResponse returns a decoder for responses +// returned by the resource ByCatalogKindNameVersionReadme endpoint. +// restoreBody controls whether the response body should be restored after +// having been read. +// DecodeByCatalogKindNameVersionReadmeResponse may return the following errors: +// - "internal-error" (type *goa.ServiceError): http.StatusInternalServerError +// - "not-found" (type *goa.ServiceError): http.StatusNotFound +// - error: internal error +func DecodeByCatalogKindNameVersionReadmeResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (interface{}, error) { + return func(resp *http.Response) (interface{}, error) { + if restoreBody { + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body ByCatalogKindNameVersionReadmeResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionReadme", err) + } + p := NewByCatalogKindNameVersionReadmeResourceVersionReadmeOK(&body) + view := "default" + vres := &resourceviews.ResourceVersionReadme{Projected: p, View: view} + if err = resourceviews.ValidateResourceVersionReadme(vres); err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionReadme", err) + } + res := resource.NewResourceVersionReadme(vres) + return res, nil + case http.StatusInternalServerError: + var ( + body ByCatalogKindNameVersionReadmeInternalErrorResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionReadme", err) + } + err = ValidateByCatalogKindNameVersionReadmeInternalErrorResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionReadme", err) + } + return nil, NewByCatalogKindNameVersionReadmeInternalError(&body) + case http.StatusNotFound: + var ( + body ByCatalogKindNameVersionReadmeNotFoundResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionReadme", err) + } + err = ValidateByCatalogKindNameVersionReadmeNotFoundResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionReadme", err) + } + return nil, NewByCatalogKindNameVersionReadmeNotFound(&body) + default: + body, _ := ioutil.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("resource", "ByCatalogKindNameVersionReadme", resp.StatusCode, string(body)) + } + } +} + +// BuildByCatalogKindNameVersionYamlRequest instantiates a HTTP request object +// with method and path set to call the "resource" service +// "ByCatalogKindNameVersionYaml" endpoint +func (c *Client) BuildByCatalogKindNameVersionYamlRequest(ctx context.Context, v interface{}) (*http.Request, error) { + var ( + catalog string + kind string + name string + version string + ) + { + p, ok := v.(*resource.ByCatalogKindNameVersionYamlPayload) + if !ok { + return nil, goahttp.ErrInvalidType("resource", "ByCatalogKindNameVersionYaml", "*resource.ByCatalogKindNameVersionYamlPayload", v) + } + catalog = p.Catalog + kind = p.Kind + name = p.Name + version = p.Version + } + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: ByCatalogKindNameVersionYamlResourcePath(catalog, kind, name, version)} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("resource", "ByCatalogKindNameVersionYaml", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// DecodeByCatalogKindNameVersionYamlResponse returns a decoder for responses +// returned by the resource ByCatalogKindNameVersionYaml endpoint. restoreBody +// controls whether the response body should be restored after having been read. +// DecodeByCatalogKindNameVersionYamlResponse may return the following errors: +// - "internal-error" (type *goa.ServiceError): http.StatusInternalServerError +// - "not-found" (type *goa.ServiceError): http.StatusNotFound +// - error: internal error +func DecodeByCatalogKindNameVersionYamlResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (interface{}, error) { + return func(resp *http.Response) (interface{}, error) { + if restoreBody { + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body ByCatalogKindNameVersionYamlResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionYaml", err) + } + p := NewByCatalogKindNameVersionYamlResourceVersionYamlOK(&body) + view := "default" + vres := &resourceviews.ResourceVersionYaml{Projected: p, View: view} + if err = resourceviews.ValidateResourceVersionYaml(vres); err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionYaml", err) + } + res := resource.NewResourceVersionYaml(vres) + return res, nil + case http.StatusInternalServerError: + var ( + body ByCatalogKindNameVersionYamlInternalErrorResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionYaml", err) + } + err = ValidateByCatalogKindNameVersionYamlInternalErrorResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionYaml", err) + } + return nil, NewByCatalogKindNameVersionYamlInternalError(&body) + case http.StatusNotFound: + var ( + body ByCatalogKindNameVersionYamlNotFoundResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("resource", "ByCatalogKindNameVersionYaml", err) + } + err = ValidateByCatalogKindNameVersionYamlNotFoundResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("resource", "ByCatalogKindNameVersionYaml", err) + } + return nil, NewByCatalogKindNameVersionYamlNotFound(&body) + default: + body, _ := ioutil.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("resource", "ByCatalogKindNameVersionYaml", resp.StatusCode, string(body)) + } + } +} + // BuildByVersionIDRequest instantiates a HTTP request object with method and // path set to call the "resource" service "ByVersionId" endpoint func (c *Client) BuildByVersionIDRequest(ctx context.Context, v interface{}) (*http.Request, error) { @@ -885,3 +1098,15 @@ func unmarshalVersionsResponseBodyToResourceviewsVersionsView(v *VersionsRespons return res } + +// unmarshalResourceContentResponseBodyToResourceviewsResourceContentView +// builds a value of type *resourceviews.ResourceContentView from a value of +// type *ResourceContentResponseBody. +func unmarshalResourceContentResponseBodyToResourceviewsResourceContentView(v *ResourceContentResponseBody) *resourceviews.ResourceContentView { + res := &resourceviews.ResourceContentView{ + Readme: v.Readme, + Yaml: v.Yaml, + } + + return res +} diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/paths.go b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/paths.go index 394ffe59d8..fffc6c8694 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/paths.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/paths.go @@ -31,6 +31,16 @@ func ByCatalogKindNameVersionResourcePath(catalog string, kind string, name stri return fmt.Sprintf("/v1/resource/%v/%v/%v/%v", catalog, kind, name, version) } +// ByCatalogKindNameVersionReadmeResourcePath returns the URL path to the resource service ByCatalogKindNameVersionReadme HTTP endpoint. +func ByCatalogKindNameVersionReadmeResourcePath(catalog string, kind string, name string, version string) string { + return fmt.Sprintf("/v1/resource/%v/%v/%v/%v/readme", catalog, kind, name, version) +} + +// ByCatalogKindNameVersionYamlResourcePath returns the URL path to the resource service ByCatalogKindNameVersionYaml HTTP endpoint. +func ByCatalogKindNameVersionYamlResourcePath(catalog string, kind string, name string, version string) string { + return fmt.Sprintf("/v1/resource/%v/%v/%v/%v/yaml", catalog, kind, name, version) +} + // ByVersionIDResourcePath returns the URL path to the resource service ByVersionId HTTP endpoint. func ByVersionIDResourcePath(versionID uint) string { return fmt.Sprintf("/v1/resource/version/%v", versionID) diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/types.go b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/types.go index c0542f41ef..152bb1f153 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/types.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/http/resource/client/types.go @@ -36,6 +36,18 @@ type ByCatalogKindNameVersionResponseBody struct { Data *ResourceVersionDataResponseBody `form:"data,omitempty" json:"data,omitempty" xml:"data,omitempty"` } +// ByCatalogKindNameVersionReadmeResponseBody is the type of the "resource" +// service "ByCatalogKindNameVersionReadme" endpoint HTTP response body. +type ByCatalogKindNameVersionReadmeResponseBody struct { + Data *ResourceContentResponseBody `form:"data,omitempty" json:"data,omitempty" xml:"data,omitempty"` +} + +// ByCatalogKindNameVersionYamlResponseBody is the type of the "resource" +// service "ByCatalogKindNameVersionYaml" endpoint HTTP response body. +type ByCatalogKindNameVersionYamlResponseBody struct { + Data *ResourceContentResponseBody `form:"data,omitempty" json:"data,omitempty" xml:"data,omitempty"` +} + // ByVersionIDResponseBody is the type of the "resource" service "ByVersionId" // endpoint HTTP response body. type ByVersionIDResponseBody struct { @@ -200,6 +212,82 @@ type ByCatalogKindNameVersionNotFoundResponseBody struct { Fault *bool `form:"fault,omitempty" json:"fault,omitempty" xml:"fault,omitempty"` } +// ByCatalogKindNameVersionReadmeInternalErrorResponseBody is the type of the +// "resource" service "ByCatalogKindNameVersionReadme" endpoint HTTP response +// body for the "internal-error" error. +type ByCatalogKindNameVersionReadmeInternalErrorResponseBody struct { + // Name is the name of this class of errors. + Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"` + // ID is a unique identifier for this particular occurrence of the problem. + ID *string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"` + // Message is a human-readable explanation specific to this occurrence of the + // problem. + Message *string `form:"message,omitempty" json:"message,omitempty" xml:"message,omitempty"` + // Is the error temporary? + Temporary *bool `form:"temporary,omitempty" json:"temporary,omitempty" xml:"temporary,omitempty"` + // Is the error a timeout? + Timeout *bool `form:"timeout,omitempty" json:"timeout,omitempty" xml:"timeout,omitempty"` + // Is the error a server-side fault? + Fault *bool `form:"fault,omitempty" json:"fault,omitempty" xml:"fault,omitempty"` +} + +// ByCatalogKindNameVersionReadmeNotFoundResponseBody is the type of the +// "resource" service "ByCatalogKindNameVersionReadme" endpoint HTTP response +// body for the "not-found" error. +type ByCatalogKindNameVersionReadmeNotFoundResponseBody struct { + // Name is the name of this class of errors. + Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"` + // ID is a unique identifier for this particular occurrence of the problem. + ID *string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"` + // Message is a human-readable explanation specific to this occurrence of the + // problem. + Message *string `form:"message,omitempty" json:"message,omitempty" xml:"message,omitempty"` + // Is the error temporary? + Temporary *bool `form:"temporary,omitempty" json:"temporary,omitempty" xml:"temporary,omitempty"` + // Is the error a timeout? + Timeout *bool `form:"timeout,omitempty" json:"timeout,omitempty" xml:"timeout,omitempty"` + // Is the error a server-side fault? + Fault *bool `form:"fault,omitempty" json:"fault,omitempty" xml:"fault,omitempty"` +} + +// ByCatalogKindNameVersionYamlInternalErrorResponseBody is the type of the +// "resource" service "ByCatalogKindNameVersionYaml" endpoint HTTP response +// body for the "internal-error" error. +type ByCatalogKindNameVersionYamlInternalErrorResponseBody struct { + // Name is the name of this class of errors. + Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"` + // ID is a unique identifier for this particular occurrence of the problem. + ID *string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"` + // Message is a human-readable explanation specific to this occurrence of the + // problem. + Message *string `form:"message,omitempty" json:"message,omitempty" xml:"message,omitempty"` + // Is the error temporary? + Temporary *bool `form:"temporary,omitempty" json:"temporary,omitempty" xml:"temporary,omitempty"` + // Is the error a timeout? + Timeout *bool `form:"timeout,omitempty" json:"timeout,omitempty" xml:"timeout,omitempty"` + // Is the error a server-side fault? + Fault *bool `form:"fault,omitempty" json:"fault,omitempty" xml:"fault,omitempty"` +} + +// ByCatalogKindNameVersionYamlNotFoundResponseBody is the type of the +// "resource" service "ByCatalogKindNameVersionYaml" endpoint HTTP response +// body for the "not-found" error. +type ByCatalogKindNameVersionYamlNotFoundResponseBody struct { + // Name is the name of this class of errors. + Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"` + // ID is a unique identifier for this particular occurrence of the problem. + ID *string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"` + // Message is a human-readable explanation specific to this occurrence of the + // problem. + Message *string `form:"message,omitempty" json:"message,omitempty" xml:"message,omitempty"` + // Is the error temporary? + Temporary *bool `form:"temporary,omitempty" json:"temporary,omitempty" xml:"temporary,omitempty"` + // Is the error a timeout? + Timeout *bool `form:"timeout,omitempty" json:"timeout,omitempty" xml:"timeout,omitempty"` + // Is the error a server-side fault? + Fault *bool `form:"fault,omitempty" json:"fault,omitempty" xml:"fault,omitempty"` +} + // ByVersionIDInternalErrorResponseBody is the type of the "resource" service // "ByVersionId" endpoint HTTP response body for the "internal-error" error. type ByVersionIDInternalErrorResponseBody struct { @@ -414,6 +502,14 @@ type VersionsResponseBody struct { Versions []*ResourceVersionDataResponseBody `form:"versions,omitempty" json:"versions,omitempty" xml:"versions,omitempty"` } +// ResourceContentResponseBody is used to define fields on response body types. +type ResourceContentResponseBody struct { + // Readme + Readme *string `form:"readme,omitempty" json:"readme,omitempty" xml:"readme,omitempty"` + // Yaml + Yaml *string `form:"yaml,omitempty" json:"yaml,omitempty" xml:"yaml,omitempty"` +} + // NewQueryResourcesOK builds a "resource" service "Query" endpoint result from // a HTTP "OK" response. func NewQueryResourcesOK(body *QueryResponseBody) *resourceviews.ResourcesView { @@ -575,6 +671,86 @@ func NewByCatalogKindNameVersionNotFound(body *ByCatalogKindNameVersionNotFoundR return v } +// NewByCatalogKindNameVersionReadmeResourceVersionReadmeOK builds a "resource" +// service "ByCatalogKindNameVersionReadme" endpoint result from a HTTP "OK" +// response. +func NewByCatalogKindNameVersionReadmeResourceVersionReadmeOK(body *ByCatalogKindNameVersionReadmeResponseBody) *resourceviews.ResourceVersionReadmeView { + v := &resourceviews.ResourceVersionReadmeView{} + v.Data = unmarshalResourceContentResponseBodyToResourceviewsResourceContentView(body.Data) + + return v +} + +// NewByCatalogKindNameVersionReadmeInternalError builds a resource service +// ByCatalogKindNameVersionReadme endpoint internal-error error. +func NewByCatalogKindNameVersionReadmeInternalError(body *ByCatalogKindNameVersionReadmeInternalErrorResponseBody) *goa.ServiceError { + v := &goa.ServiceError{ + Name: *body.Name, + ID: *body.ID, + Message: *body.Message, + Temporary: *body.Temporary, + Timeout: *body.Timeout, + Fault: *body.Fault, + } + + return v +} + +// NewByCatalogKindNameVersionReadmeNotFound builds a resource service +// ByCatalogKindNameVersionReadme endpoint not-found error. +func NewByCatalogKindNameVersionReadmeNotFound(body *ByCatalogKindNameVersionReadmeNotFoundResponseBody) *goa.ServiceError { + v := &goa.ServiceError{ + Name: *body.Name, + ID: *body.ID, + Message: *body.Message, + Temporary: *body.Temporary, + Timeout: *body.Timeout, + Fault: *body.Fault, + } + + return v +} + +// NewByCatalogKindNameVersionYamlResourceVersionYamlOK builds a "resource" +// service "ByCatalogKindNameVersionYaml" endpoint result from a HTTP "OK" +// response. +func NewByCatalogKindNameVersionYamlResourceVersionYamlOK(body *ByCatalogKindNameVersionYamlResponseBody) *resourceviews.ResourceVersionYamlView { + v := &resourceviews.ResourceVersionYamlView{} + v.Data = unmarshalResourceContentResponseBodyToResourceviewsResourceContentView(body.Data) + + return v +} + +// NewByCatalogKindNameVersionYamlInternalError builds a resource service +// ByCatalogKindNameVersionYaml endpoint internal-error error. +func NewByCatalogKindNameVersionYamlInternalError(body *ByCatalogKindNameVersionYamlInternalErrorResponseBody) *goa.ServiceError { + v := &goa.ServiceError{ + Name: *body.Name, + ID: *body.ID, + Message: *body.Message, + Temporary: *body.Temporary, + Timeout: *body.Timeout, + Fault: *body.Fault, + } + + return v +} + +// NewByCatalogKindNameVersionYamlNotFound builds a resource service +// ByCatalogKindNameVersionYaml endpoint not-found error. +func NewByCatalogKindNameVersionYamlNotFound(body *ByCatalogKindNameVersionYamlNotFoundResponseBody) *goa.ServiceError { + v := &goa.ServiceError{ + Name: *body.Name, + ID: *body.ID, + Message: *body.Message, + Temporary: *body.Temporary, + Timeout: *body.Timeout, + Fault: *body.Fault, + } + + return v +} + // NewByVersionIDResourceVersionOK builds a "resource" service "ByVersionId" // endpoint result from a HTTP "OK" response. func NewByVersionIDResourceVersionOK(body *ByVersionIDResponseBody) *resourceviews.ResourceVersionView { @@ -883,6 +1059,104 @@ func ValidateByCatalogKindNameVersionNotFoundResponseBody(body *ByCatalogKindNam return } +// ValidateByCatalogKindNameVersionReadmeInternalErrorResponseBody runs the +// validations defined on +// ByCatalogKindNameVersionReadme_internal-error_Response_Body +func ValidateByCatalogKindNameVersionReadmeInternalErrorResponseBody(body *ByCatalogKindNameVersionReadmeInternalErrorResponseBody) (err error) { + if body.Name == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("name", "body")) + } + if body.ID == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("id", "body")) + } + if body.Message == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("message", "body")) + } + if body.Temporary == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("temporary", "body")) + } + if body.Timeout == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("timeout", "body")) + } + if body.Fault == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("fault", "body")) + } + return +} + +// ValidateByCatalogKindNameVersionReadmeNotFoundResponseBody runs the +// validations defined on ByCatalogKindNameVersionReadme_not-found_Response_Body +func ValidateByCatalogKindNameVersionReadmeNotFoundResponseBody(body *ByCatalogKindNameVersionReadmeNotFoundResponseBody) (err error) { + if body.Name == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("name", "body")) + } + if body.ID == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("id", "body")) + } + if body.Message == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("message", "body")) + } + if body.Temporary == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("temporary", "body")) + } + if body.Timeout == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("timeout", "body")) + } + if body.Fault == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("fault", "body")) + } + return +} + +// ValidateByCatalogKindNameVersionYamlInternalErrorResponseBody runs the +// validations defined on +// ByCatalogKindNameVersionYaml_internal-error_Response_Body +func ValidateByCatalogKindNameVersionYamlInternalErrorResponseBody(body *ByCatalogKindNameVersionYamlInternalErrorResponseBody) (err error) { + if body.Name == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("name", "body")) + } + if body.ID == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("id", "body")) + } + if body.Message == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("message", "body")) + } + if body.Temporary == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("temporary", "body")) + } + if body.Timeout == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("timeout", "body")) + } + if body.Fault == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("fault", "body")) + } + return +} + +// ValidateByCatalogKindNameVersionYamlNotFoundResponseBody runs the +// validations defined on ByCatalogKindNameVersionYaml_not-found_Response_Body +func ValidateByCatalogKindNameVersionYamlNotFoundResponseBody(body *ByCatalogKindNameVersionYamlNotFoundResponseBody) (err error) { + if body.Name == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("name", "body")) + } + if body.ID == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("id", "body")) + } + if body.Message == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("message", "body")) + } + if body.Temporary == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("temporary", "body")) + } + if body.Timeout == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("timeout", "body")) + } + if body.Fault == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("fault", "body")) + } + return +} + // ValidateByVersionIDInternalErrorResponseBody runs the validations defined on // ByVersionId_internal-error_Response_Body func ValidateByVersionIDInternalErrorResponseBody(body *ByVersionIDInternalErrorResponseBody) (err error) { diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/client.go b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/client.go index 15fd839f30..ff6d0e110d 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/client.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/client.go @@ -15,25 +15,29 @@ import ( // Client is the "resource" service client. type Client struct { - QueryEndpoint goa.Endpoint - ListEndpoint goa.Endpoint - VersionsByIDEndpoint goa.Endpoint - ByCatalogKindNameVersionEndpoint goa.Endpoint - ByVersionIDEndpoint goa.Endpoint - ByCatalogKindNameEndpoint goa.Endpoint - ByIDEndpoint goa.Endpoint + QueryEndpoint goa.Endpoint + ListEndpoint goa.Endpoint + VersionsByIDEndpoint goa.Endpoint + ByCatalogKindNameVersionEndpoint goa.Endpoint + ByCatalogKindNameVersionReadmeEndpoint goa.Endpoint + ByCatalogKindNameVersionYamlEndpoint goa.Endpoint + ByVersionIDEndpoint goa.Endpoint + ByCatalogKindNameEndpoint goa.Endpoint + ByIDEndpoint goa.Endpoint } // NewClient initializes a "resource" service client given the endpoints. -func NewClient(query, list, versionsByID, byCatalogKindNameVersion, byVersionID, byCatalogKindName, byID goa.Endpoint) *Client { +func NewClient(query, list, versionsByID, byCatalogKindNameVersion, byCatalogKindNameVersionReadme, byCatalogKindNameVersionYaml, byVersionID, byCatalogKindName, byID goa.Endpoint) *Client { return &Client{ - QueryEndpoint: query, - ListEndpoint: list, - VersionsByIDEndpoint: versionsByID, - ByCatalogKindNameVersionEndpoint: byCatalogKindNameVersion, - ByVersionIDEndpoint: byVersionID, - ByCatalogKindNameEndpoint: byCatalogKindName, - ByIDEndpoint: byID, + QueryEndpoint: query, + ListEndpoint: list, + VersionsByIDEndpoint: versionsByID, + ByCatalogKindNameVersionEndpoint: byCatalogKindNameVersion, + ByCatalogKindNameVersionReadmeEndpoint: byCatalogKindNameVersionReadme, + ByCatalogKindNameVersionYamlEndpoint: byCatalogKindNameVersionYaml, + ByVersionIDEndpoint: byVersionID, + ByCatalogKindNameEndpoint: byCatalogKindName, + ByIDEndpoint: byID, } } @@ -78,6 +82,28 @@ func (c *Client) ByCatalogKindNameVersion(ctx context.Context, p *ByCatalogKindN return ires.(*ResourceVersion), nil } +// ByCatalogKindNameVersionReadme calls the "ByCatalogKindNameVersionReadme" +// endpoint of the "resource" service. +func (c *Client) ByCatalogKindNameVersionReadme(ctx context.Context, p *ByCatalogKindNameVersionReadmePayload) (res *ResourceVersionReadme, err error) { + var ires interface{} + ires, err = c.ByCatalogKindNameVersionReadmeEndpoint(ctx, p) + if err != nil { + return + } + return ires.(*ResourceVersionReadme), nil +} + +// ByCatalogKindNameVersionYaml calls the "ByCatalogKindNameVersionYaml" +// endpoint of the "resource" service. +func (c *Client) ByCatalogKindNameVersionYaml(ctx context.Context, p *ByCatalogKindNameVersionYamlPayload) (res *ResourceVersionYaml, err error) { + var ires interface{} + ires, err = c.ByCatalogKindNameVersionYamlEndpoint(ctx, p) + if err != nil { + return + } + return ires.(*ResourceVersionYaml), nil +} + // ByVersionID calls the "ByVersionId" endpoint of the "resource" service. func (c *Client) ByVersionID(ctx context.Context, p *ByVersionIDPayload) (res *ResourceVersion, err error) { var ires interface{} diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/endpoints.go b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/endpoints.go index 949f8ca989..1a76a54d98 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/endpoints.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/endpoints.go @@ -15,25 +15,29 @@ import ( // Endpoints wraps the "resource" service endpoints. type Endpoints struct { - Query goa.Endpoint - List goa.Endpoint - VersionsByID goa.Endpoint - ByCatalogKindNameVersion goa.Endpoint - ByVersionID goa.Endpoint - ByCatalogKindName goa.Endpoint - ByID goa.Endpoint + Query goa.Endpoint + List goa.Endpoint + VersionsByID goa.Endpoint + ByCatalogKindNameVersion goa.Endpoint + ByCatalogKindNameVersionReadme goa.Endpoint + ByCatalogKindNameVersionYaml goa.Endpoint + ByVersionID goa.Endpoint + ByCatalogKindName goa.Endpoint + ByID goa.Endpoint } // NewEndpoints wraps the methods of the "resource" service with endpoints. func NewEndpoints(s Service) *Endpoints { return &Endpoints{ - Query: NewQueryEndpoint(s), - List: NewListEndpoint(s), - VersionsByID: NewVersionsByIDEndpoint(s), - ByCatalogKindNameVersion: NewByCatalogKindNameVersionEndpoint(s), - ByVersionID: NewByVersionIDEndpoint(s), - ByCatalogKindName: NewByCatalogKindNameEndpoint(s), - ByID: NewByIDEndpoint(s), + Query: NewQueryEndpoint(s), + List: NewListEndpoint(s), + VersionsByID: NewVersionsByIDEndpoint(s), + ByCatalogKindNameVersion: NewByCatalogKindNameVersionEndpoint(s), + ByCatalogKindNameVersionReadme: NewByCatalogKindNameVersionReadmeEndpoint(s), + ByCatalogKindNameVersionYaml: NewByCatalogKindNameVersionYamlEndpoint(s), + ByVersionID: NewByVersionIDEndpoint(s), + ByCatalogKindName: NewByCatalogKindNameEndpoint(s), + ByID: NewByIDEndpoint(s), } } @@ -43,6 +47,8 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { e.List = m(e.List) e.VersionsByID = m(e.VersionsByID) e.ByCatalogKindNameVersion = m(e.ByCatalogKindNameVersion) + e.ByCatalogKindNameVersionReadme = m(e.ByCatalogKindNameVersionReadme) + e.ByCatalogKindNameVersionYaml = m(e.ByCatalogKindNameVersionYaml) e.ByVersionID = m(e.ByVersionID) e.ByCatalogKindName = m(e.ByCatalogKindName) e.ByID = m(e.ByID) @@ -104,6 +110,34 @@ func NewByCatalogKindNameVersionEndpoint(s Service) goa.Endpoint { } } +// NewByCatalogKindNameVersionReadmeEndpoint returns an endpoint function that +// calls the method "ByCatalogKindNameVersionReadme" of service "resource". +func NewByCatalogKindNameVersionReadmeEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req interface{}) (interface{}, error) { + p := req.(*ByCatalogKindNameVersionReadmePayload) + res, err := s.ByCatalogKindNameVersionReadme(ctx, p) + if err != nil { + return nil, err + } + vres := NewViewedResourceVersionReadme(res, "default") + return vres, nil + } +} + +// NewByCatalogKindNameVersionYamlEndpoint returns an endpoint function that +// calls the method "ByCatalogKindNameVersionYaml" of service "resource". +func NewByCatalogKindNameVersionYamlEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req interface{}) (interface{}, error) { + p := req.(*ByCatalogKindNameVersionYamlPayload) + res, err := s.ByCatalogKindNameVersionYaml(ctx, p) + if err != nil { + return nil, err + } + vres := NewViewedResourceVersionYaml(res, "default") + return vres, nil + } +} + // NewByVersionIDEndpoint returns an endpoint function that calls the method // "ByVersionId" of service "resource". func NewByVersionIDEndpoint(s Service) goa.Endpoint { diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/service.go b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/service.go index 43ca41136a..5464f1257a 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/service.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/service.go @@ -25,6 +25,11 @@ type Service interface { VersionsByID(context.Context, *VersionsByIDPayload) (res *ResourceVersions, err error) // Find resource using name of catalog & name, kind and version of resource ByCatalogKindNameVersion(context.Context, *ByCatalogKindNameVersionPayload) (res *ResourceVersion, err error) + // Find resource README using name of catalog & name, kind and version of + // resource + ByCatalogKindNameVersionReadme(context.Context, *ByCatalogKindNameVersionReadmePayload) (res *ResourceVersionReadme, err error) + // Find resource YAML using name of catalog & name, kind and version of resource + ByCatalogKindNameVersionYaml(context.Context, *ByCatalogKindNameVersionYamlPayload) (res *ResourceVersionYaml, err error) // Find a resource using its version's id ByVersionID(context.Context, *ByVersionIDPayload) (res *ResourceVersion, err error) // Find resources using name of catalog, resource name and kind of resource @@ -41,7 +46,7 @@ const ServiceName = "resource" // MethodNames lists the service method names as defined in the design. These // are the same values that are set in the endpoint request contexts under the // MethodKey key. -var MethodNames = [7]string{"Query", "List", "VersionsByID", "ByCatalogKindNameVersion", "ByVersionId", "ByCatalogKindName", "ById"} +var MethodNames = [9]string{"Query", "List", "VersionsByID", "ByCatalogKindNameVersion", "ByCatalogKindNameVersionReadme", "ByCatalogKindNameVersionYaml", "ByVersionId", "ByCatalogKindName", "ById"} // QueryPayload is the payload type of the resource service Query method. type QueryPayload struct { @@ -106,6 +111,44 @@ type ResourceVersion struct { Data *ResourceVersionData } +// ByCatalogKindNameVersionReadmePayload is the payload type of the resource +// service ByCatalogKindNameVersionReadme method. +type ByCatalogKindNameVersionReadmePayload struct { + // name of catalog + Catalog string + // kind of resource + Kind string + // name of resource + Name string + // version of resource + Version string +} + +// ResourceVersionReadme is the result type of the resource service +// ByCatalogKindNameVersionReadme method. +type ResourceVersionReadme struct { + Data *ResourceContent +} + +// ByCatalogKindNameVersionYamlPayload is the payload type of the resource +// service ByCatalogKindNameVersionYaml method. +type ByCatalogKindNameVersionYamlPayload struct { + // name of catalog + Catalog string + // kind of resource + Kind string + // name of resource + Name string + // version of resource + Version string +} + +// ResourceVersionYaml is the result type of the resource service +// ByCatalogKindNameVersionYaml method. +type ResourceVersionYaml struct { + Data *ResourceContent +} + // ByVersionIDPayload is the payload type of the resource service ByVersionId // method. type ByVersionIDPayload struct { @@ -235,6 +278,13 @@ type Versions struct { Versions []*ResourceVersionData } +type ResourceContent struct { + // Readme + Readme *string + // Yaml + Yaml *string +} + // MakeInternalError builds a goa.ServiceError from an error. func MakeInternalError(err error) *goa.ServiceError { return &goa.ServiceError{ @@ -301,6 +351,34 @@ func NewViewedResourceVersion(res *ResourceVersion, view string) *resourceviews. return &resourceviews.ResourceVersion{Projected: p, View: "default"} } +// NewResourceVersionReadme initializes result type ResourceVersionReadme from +// viewed result type ResourceVersionReadme. +func NewResourceVersionReadme(vres *resourceviews.ResourceVersionReadme) *ResourceVersionReadme { + return newResourceVersionReadme(vres.Projected) +} + +// NewViewedResourceVersionReadme initializes viewed result type +// ResourceVersionReadme from result type ResourceVersionReadme using the given +// view. +func NewViewedResourceVersionReadme(res *ResourceVersionReadme, view string) *resourceviews.ResourceVersionReadme { + p := newResourceVersionReadmeView(res) + return &resourceviews.ResourceVersionReadme{Projected: p, View: "default"} +} + +// NewResourceVersionYaml initializes result type ResourceVersionYaml from +// viewed result type ResourceVersionYaml. +func NewResourceVersionYaml(vres *resourceviews.ResourceVersionYaml) *ResourceVersionYaml { + return newResourceVersionYaml(vres.Projected) +} + +// NewViewedResourceVersionYaml initializes viewed result type +// ResourceVersionYaml from result type ResourceVersionYaml using the given +// view. +func NewViewedResourceVersionYaml(res *ResourceVersionYaml, view string) *resourceviews.ResourceVersionYaml { + p := newResourceVersionYamlView(res) + return &resourceviews.ResourceVersionYaml{Projected: p, View: "default"} +} + // NewResource initializes result type Resource from viewed result type // Resource. func NewResource(vres *resourceviews.Resource) *Resource { @@ -1002,6 +1080,102 @@ func newResourceVersionView(res *ResourceVersion) *resourceviews.ResourceVersion return vres } +// newResourceVersionReadme converts projected type ResourceVersionReadme to +// service type ResourceVersionReadme. +func newResourceVersionReadme(vres *resourceviews.ResourceVersionReadmeView) *ResourceVersionReadme { + res := &ResourceVersionReadme{} + if vres.Data != nil { + res.Data = newResourceContentReadme(vres.Data) + } + return res +} + +// newResourceVersionReadmeView projects result type ResourceVersionReadme to +// projected type ResourceVersionReadmeView using the "default" view. +func newResourceVersionReadmeView(res *ResourceVersionReadme) *resourceviews.ResourceVersionReadmeView { + vres := &resourceviews.ResourceVersionReadmeView{} + if res.Data != nil { + vres.Data = newResourceContentViewReadme(res.Data) + } + return vres +} + +// newResourceContentReadme converts projected type ResourceContent to service +// type ResourceContent. +func newResourceContentReadme(vres *resourceviews.ResourceContentView) *ResourceContent { + res := &ResourceContent{ + Readme: vres.Readme, + } + return res +} + +// newResourceContentYaml converts projected type ResourceContent to service +// type ResourceContent. +func newResourceContentYaml(vres *resourceviews.ResourceContentView) *ResourceContent { + res := &ResourceContent{ + Yaml: vres.Yaml, + } + return res +} + +// newResourceContent converts projected type ResourceContent to service type +// ResourceContent. +func newResourceContent(vres *resourceviews.ResourceContentView) *ResourceContent { + res := &ResourceContent{ + Readme: vres.Readme, + Yaml: vres.Yaml, + } + return res +} + +// newResourceContentViewReadme projects result type ResourceContent to +// projected type ResourceContentView using the "readme" view. +func newResourceContentViewReadme(res *ResourceContent) *resourceviews.ResourceContentView { + vres := &resourceviews.ResourceContentView{ + Readme: res.Readme, + } + return vres +} + +// newResourceContentViewYaml projects result type ResourceContent to projected +// type ResourceContentView using the "yaml" view. +func newResourceContentViewYaml(res *ResourceContent) *resourceviews.ResourceContentView { + vres := &resourceviews.ResourceContentView{ + Yaml: res.Yaml, + } + return vres +} + +// newResourceContentView projects result type ResourceContent to projected +// type ResourceContentView using the "default" view. +func newResourceContentView(res *ResourceContent) *resourceviews.ResourceContentView { + vres := &resourceviews.ResourceContentView{ + Readme: res.Readme, + Yaml: res.Yaml, + } + return vres +} + +// newResourceVersionYaml converts projected type ResourceVersionYaml to +// service type ResourceVersionYaml. +func newResourceVersionYaml(vres *resourceviews.ResourceVersionYamlView) *ResourceVersionYaml { + res := &ResourceVersionYaml{} + if vres.Data != nil { + res.Data = newResourceContentYaml(vres.Data) + } + return res +} + +// newResourceVersionYamlView projects result type ResourceVersionYaml to +// projected type ResourceVersionYamlView using the "default" view. +func newResourceVersionYamlView(res *ResourceVersionYaml) *resourceviews.ResourceVersionYamlView { + vres := &resourceviews.ResourceVersionYamlView{} + if res.Data != nil { + vres.Data = newResourceContentViewYaml(res.Data) + } + return vres +} + // newResource converts projected type Resource to service type Resource. func newResource(vres *resourceviews.ResourceView) *Resource { res := &Resource{} diff --git a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/views/view.go b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/views/view.go index 78728523ab..07db747d61 100644 --- a/vendor/github.com/tektoncd/hub/api/v1/gen/resource/views/view.go +++ b/vendor/github.com/tektoncd/hub/api/v1/gen/resource/views/view.go @@ -35,6 +35,24 @@ type ResourceVersion struct { View string } +// ResourceVersionReadme is the viewed result type that is projected based on a +// view. +type ResourceVersionReadme struct { + // Type to project + Projected *ResourceVersionReadmeView + // View to render + View string +} + +// ResourceVersionYaml is the viewed result type that is projected based on a +// view. +type ResourceVersionYaml struct { + // Type to project + Projected *ResourceVersionYamlView + // View to render + View string +} + // Resource is the viewed result type that is projected based on a view. type Resource struct { // Type to project @@ -162,6 +180,25 @@ type ResourceVersionView struct { Data *ResourceVersionDataView } +// ResourceVersionReadmeView is a type that runs validations on a projected +// type. +type ResourceVersionReadmeView struct { + Data *ResourceContentView +} + +// ResourceContentView is a type that runs validations on a projected type. +type ResourceContentView struct { + // Readme + Readme *string + // Yaml + Yaml *string +} + +// ResourceVersionYamlView is a type that runs validations on a projected type. +type ResourceVersionYamlView struct { + Data *ResourceContentView +} + // ResourceView is a type that runs validations on a projected type. type ResourceView struct { Data *ResourceDataView @@ -189,6 +226,20 @@ var ( "data", }, } + // ResourceVersionReadmeMap is a map of attribute names in result type + // ResourceVersionReadme indexed by view name. + ResourceVersionReadmeMap = map[string][]string{ + "default": []string{ + "data", + }, + } + // ResourceVersionYamlMap is a map of attribute names in result type + // ResourceVersionYaml indexed by view name. + ResourceVersionYamlMap = map[string][]string{ + "default": []string{ + "data", + }, + } // ResourceMap is a map of attribute names in result type Resource indexed by // view name. ResourceMap = map[string][]string{ @@ -343,6 +394,20 @@ var ( "versions", }, } + // ResourceContentMap is a map of attribute names in result type + // ResourceContent indexed by view name. + ResourceContentMap = map[string][]string{ + "readme": []string{ + "readme", + }, + "yaml": []string{ + "yaml", + }, + "default": []string{ + "readme", + "yaml", + }, + } ) // ValidateResources runs the validations defined on the viewed result type @@ -381,6 +446,30 @@ func ValidateResourceVersion(result *ResourceVersion) (err error) { return } +// ValidateResourceVersionReadme runs the validations defined on the viewed +// result type ResourceVersionReadme. +func ValidateResourceVersionReadme(result *ResourceVersionReadme) (err error) { + switch result.View { + case "default", "": + err = ValidateResourceVersionReadmeView(result.Projected) + default: + err = goa.InvalidEnumValueError("view", result.View, []interface{}{"default"}) + } + return +} + +// ValidateResourceVersionYaml runs the validations defined on the viewed +// result type ResourceVersionYaml. +func ValidateResourceVersionYaml(result *ResourceVersionYaml) (err error) { + switch result.View { + case "default", "": + err = ValidateResourceVersionYamlView(result.Projected) + default: + err = goa.InvalidEnumValueError("view", result.View, []interface{}{"default"}) + } + return +} + // ValidateResource runs the validations defined on the viewed result type // Resource. func ValidateResource(result *Resource) (err error) { @@ -908,6 +997,51 @@ func ValidateResourceVersionView(result *ResourceVersionView) (err error) { return } +// ValidateResourceVersionReadmeView runs the validations defined on +// ResourceVersionReadmeView using the "default" view. +func ValidateResourceVersionReadmeView(result *ResourceVersionReadmeView) (err error) { + + if result.Data != nil { + if err2 := ValidateResourceContentViewReadme(result.Data); err2 != nil { + err = goa.MergeErrors(err, err2) + } + } + return +} + +// ValidateResourceContentViewReadme runs the validations defined on +// ResourceContentView using the "readme" view. +func ValidateResourceContentViewReadme(result *ResourceContentView) (err error) { + + return +} + +// ValidateResourceContentViewYaml runs the validations defined on +// ResourceContentView using the "yaml" view. +func ValidateResourceContentViewYaml(result *ResourceContentView) (err error) { + + return +} + +// ValidateResourceContentView runs the validations defined on +// ResourceContentView using the "default" view. +func ValidateResourceContentView(result *ResourceContentView) (err error) { + + return +} + +// ValidateResourceVersionYamlView runs the validations defined on +// ResourceVersionYamlView using the "default" view. +func ValidateResourceVersionYamlView(result *ResourceVersionYamlView) (err error) { + + if result.Data != nil { + if err2 := ValidateResourceContentViewYaml(result.Data); err2 != nil { + err = goa.MergeErrors(err, err2) + } + } + return +} + // ValidateResourceView runs the validations defined on ResourceView using the // "default" view. func ValidateResourceView(result *ResourceView) (err error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 0a199ac6b4..27e467ce0f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -452,7 +452,7 @@ github.com/gregjones/httpcache/diskcache github.com/grpc-ecosystem/grpc-gateway/internal github.com/grpc-ecosystem/grpc-gateway/runtime github.com/grpc-ecosystem/grpc-gateway/utilities -# github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 +# github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b ## explicit github.com/hako/durafmt # github.com/hashicorp/errwrap v1.1.0 @@ -795,7 +795,7 @@ github.com/tektoncd/chains/pkg/chains/storage/oci github.com/tektoncd/chains/pkg/chains/storage/tekton github.com/tektoncd/chains/pkg/config github.com/tektoncd/chains/pkg/patch -# github.com/tektoncd/hub/api v0.0.0-20220128080824-5941f280d06a +# github.com/tektoncd/hub v1.6.1-0.20220304075515-3ebdb197f089 ## explicit github.com/tektoncd/hub/api/pkg/cli/app github.com/tektoncd/hub/api/pkg/cli/cmd