From a4052a8ff4074fa17d82aff9baead929bdea2926 Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Fri, 23 Apr 2021 14:02:16 -0400 Subject: [PATCH 1/3] Consume top level variables Signed-off-by: Maysun J Faisal --- README.md | 2 +- go.mod | 2 +- go.sum | 51 +------------------ main.go | 2 +- pkg/devfile/parse.go | 19 ++++--- pkg/devfile/parser/data/interface.go | 1 + .../data/v2/2.1.0/devfileJsonSchema210.go | 26 +++++++++- pkg/devfile/parser/data/v2/workspace.go | 4 ++ 8 files changed, 46 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index edae7673..0cc85411 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g 1. To parse a devfile, visit pkg/devfile/parse.go ``` // Parses the devfile and validates the devfile data - devfile, err := devfilePkg.ParseAndValidate(devfileLocation) + devfile, _, err := devfilePkg.ParseDevfileAndValidate(devfileLocation) // To get all the components from the devfile components, err := devfile.Data.GetComponents(DevfileOptions{}) diff --git a/go.mod b/go.mod index 8e05d93f..0016f79f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/devfile/library go 1.13 require ( - github.com/devfile/api/v2 v2.0.0-20210408144711-a313872749ed + github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292 github.com/fatih/color v1.7.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/gobwas/glob v0.2.3 diff --git a/go.sum b/go.sum index ca799479..f6c4a3ac 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/devfile/api/v2 v2.0.0-20210408144711-a313872749ed h1:eTSeB23FwKwMN0kI7qB7Nq3OhfCaXkPPWUsru8TRo+o= -github.com/devfile/api/v2 v2.0.0-20210408144711-a313872749ed/go.mod h1:Cot4snybn3qhIh48oIFi9McocnIx7zY5fFbjfrIpPvg= +github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292 h1:XNtHHNf041XmYSbz8u4ZhLbebjhdoY79wDW0HT3Y9UI= +github.com/devfile/api/v2 v2.0.0-20210420202853-ff3c01bf8292/go.mod h1:Cot4snybn3qhIh48oIFi9McocnIx7zY5fFbjfrIpPvg= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= @@ -97,7 +97,6 @@ github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQo github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -113,11 +112,9 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.3.0 h1:q4c+kbcR0d5rSurhBR8dIgieOaYpXtsdTYfx22Cu6rs= github.com/go-logr/logr v0.3.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/zapr v0.1.0 h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-logr/zapr v0.2.0 h1:v6Ji8yBW77pva6NkJKQdHLAJKrIJKRHz0RXwPqCHSR4= github.com/go-logr/zapr v0.2.0/go.mod h1:qhKdvif7YF5GI9NWEpyxTSSBdGmzkNguibrdCNVPunU= @@ -183,7 +180,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -200,12 +196,10 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -221,9 +215,7 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= -github.com/googleapis/gnostic v0.4.1 h1:DLJCy1n/vrD4HPjOvYcT8aYQXpPIzoRZONaYwyycI+I= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= github.com/googleapis/gnostic v0.5.1 h1:A8Yhf6EtqTv9RMsU6MQTyrtV1TjWlR6xU9BsZIwuTCM= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= @@ -246,11 +238,9 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.10 h1:6q5mVkdH/vYmqngx7kZQTjJ5HRsx+ImorDIEQ+beJgc= github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -270,12 +260,10 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5 h1:hyz3dwM5QLc1Rfoz4FuWJQG5BN7tc6K1MndAUnGpQr4= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -296,7 +284,6 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -321,16 +308,13 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -342,7 +326,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -351,7 +334,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -362,14 +344,12 @@ github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -407,7 +387,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= @@ -440,20 +419,17 @@ 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.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.8.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= @@ -468,7 +444,6 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -520,7 +495,6 @@ golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -573,15 +547,12 @@ golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -620,7 +591,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0= gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= gomodules.xyz/jsonpatch/v2 v2.1.0 h1:Phva6wqu+xR//Njw6iorylFFgn/z547tw5Ne3HZPQ+k= gomodules.xyz/jsonpatch/v2 v2.1.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= @@ -633,7 +603,6 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= @@ -661,7 +630,6 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= @@ -673,7 +641,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -690,11 +657,9 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -703,25 +668,19 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.18.6 h1:osqrAXbOQjkKIWDTjrqxWQ3w0GkKb1KA1XkUGHHYpeE= k8s.io/api v0.18.6/go.mod h1:eeyxr+cwCjMdLAmr2W3RyDI0VvTawSg/3RFFBEnmZGI= -k8s.io/api v0.19.0 h1:XyrFIJqTYZJ2DU7FBE/bSPz7b1HvbVBuBf07oeo6eTc= k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw= k8s.io/api v0.19.2 h1:q+/krnHWKsL7OBZg/rxnycsl9569Pud76UJ77MvKXms= k8s.io/api v0.19.2/go.mod h1:IQpK0zFQ1xc5iNIQPqzgoOwuFugaYHK4iCknlAQP9nI= -k8s.io/apiextensions-apiserver v0.18.6 h1:vDlk7cyFsDyfwn2rNAO2DbmUbvXy5yT5GE3rrqOzaMo= k8s.io/apiextensions-apiserver v0.18.6/go.mod h1:lv89S7fUysXjLZO7ke783xOwVTm6lKizADfvUM/SS/M= k8s.io/apiextensions-apiserver v0.19.2 h1:oG84UwiDsVDu7dlsGQs5GySmQHCzMhknfhFExJMz9tA= k8s.io/apiextensions-apiserver v0.19.2/go.mod h1:EYNjpqIAvNZe+svXVx9j4uBaVhTB4C94HkY3w058qcg= -k8s.io/apimachinery v0.18.6 h1:RtFHnfGNfd1N0LeSrKCUznz5xtUP1elRGvHJbL3Ntag= k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= -k8s.io/apimachinery v0.19.0 h1:gjKnAda/HZp5k4xQYjL0K/Yb66IvNqjthCb03QlKpaQ= k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA= k8s.io/apimachinery v0.19.2 h1:5Gy9vQpAGTKHPVOh5c4plE274X8D/6cuEiTO2zve7tc= k8s.io/apimachinery v0.19.2/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA= k8s.io/apiserver v0.18.6/go.mod h1:Zt2XvTHuaZjBz6EFYzpp+X4hTmgWGy8AthNVnTdm3Wg= k8s.io/apiserver v0.19.2/go.mod h1:FreAq0bJ2vtZFj9Ago/X0oNGC51GfubKK/ViOKfVAOA= -k8s.io/client-go v0.18.6 h1:I+oWqJbibLSGsZj8Xs8F0aWVXJVIoUHWaaJV3kUN/Zw= k8s.io/client-go v0.18.6/go.mod h1:/fwtGLjYMS1MaM5oi+eXhKwG+1UHidUEXRh6cNsdO0Q= k8s.io/client-go v0.19.2 h1:gMJuU3xJZs86L1oQ99R4EViAADUPMHHtS9jFshasHSc= k8s.io/client-go v0.19.2/go.mod h1:S5wPhCqyDNAlzM9CnEdgTGV4OqhsW3jGO1UM1epwfJA= @@ -732,7 +691,6 @@ k8s.io/component-base v0.18.6/go.mod h1:knSVsibPR5K6EW2XOjEHik6sdU5nCvKMrzMt2D4I k8s.io/component-base v0.19.2 h1:jW5Y9RcZTb79liEhW3XDVTW7MuvEGP0tQZnfSX6/+gs= k8s.io/component-base v0.19.2/go.mod h1:g5LrsiTiabMLZ40AR6Hl45f088DevyGY+cCE2agEIVo= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 h1:RPscN6KhmG54S33L+lr3GS+oD1jmchIU0ll519K6FA4= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= 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= @@ -743,26 +701,21 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0 h1:XRvcwJozkgZ1UQJmfMGpvRthQHOvihEhYtDfAaxMz/A= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOECPVeXsVot0UkiaCGVyfGQY= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6 h1:+WnxoVtG8TMiudHBSEtrVL1egv36TkkJm+bA8AxicmQ= k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE= k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K8Hf8whTseBgJcg= k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20200912215256-4140de9c8800 h1:9ZNvfPvVIEsp/T1ez4GQuzCcCTEQWhovSofhqR73A6g= k8s.io/utils v0.0.0-20200912215256-4140de9c8800/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.9/go.mod h1:dzAXnQbTRyDlZPJX2SUPEqvnB+j7AJjtlox7PEwigU0= -sigs.k8s.io/controller-runtime v0.6.3 h1:SBbr+inLPEKhvlJtrvDcwIpm+uhDvp63Bl72xYJtoOE= sigs.k8s.io/controller-runtime v0.6.3/go.mod h1:WlZNXcM0++oyaQt4B7C2lEE5JYRs8vJUzRP4N4JpdAY= sigs.k8s.io/controller-runtime v0.7.0 h1:bU20IBBEPccWz5+zXpLnpVsgBYxqclaHu1pVDl/gEt8= sigs.k8s.io/controller-runtime v0.7.0/go.mod h1:pJ3YBrJiAqMAZKi6UVGuE98ZrroV1p+pIhoHsMm9wdU= sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= -sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E= sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/structured-merge-diff/v4 v4.0.1 h1:YXTMot5Qz/X1iBRJhAt+vI+HVttY0WkSqqhKxQ0xVbA= sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= diff --git a/main.go b/main.go index 42d8817d..67844d4e 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func parserTest() { } fmt.Println("parsing devfile from ./devfile.yaml") } - devfile, err := devfilepkg.ParseDevfileAndValidate(args) + devfile, _, err := devfilepkg.ParseDevfileAndValidate(args) if err != nil { fmt.Println(err) } else { diff --git a/pkg/devfile/parse.go b/pkg/devfile/parse.go index 92a858ed..a4874669 100644 --- a/pkg/devfile/parse.go +++ b/pkg/devfile/parse.go @@ -1,6 +1,7 @@ package devfile import ( + "github.com/devfile/api/v2/pkg/validation/variables" "github.com/devfile/library/pkg/devfile/parser" "github.com/devfile/library/pkg/devfile/validate" ) @@ -69,21 +70,23 @@ func ParseAndValidate(path string) (d parser.DevfileObj, err error) { return d, err } -// ParseDevfileAndValidate func parses the devfile data -// and validates the devfile integrity with the schema -// and validates the devfile data. -// Creates devfile context and runtime objects. -func ParseDevfileAndValidate(args parser.ParserArgs) (d parser.DevfileObj, err error) { +// ParseDevfileAndValidate func parses the devfile data, validates the devfile integrity with the schema +// replaces the top-level variable keys if present and validates the devfile data. +// It returns devfile context and runtime objects, variable substitution warning if any and an error. +func ParseDevfileAndValidate(args parser.ParserArgs) (d parser.DevfileObj, varWarning variables.VariableWarning, err error) { d, err = parser.ParseDevfile(args) if err != nil { - return d, err + return d, varWarning, err } + // replace the top level variable keys with their values in the devfile + varWarning = variables.ValidateAndReplaceGlobalVariable(d.Data.GetDevfileWorkspaceSpec()) + // generic validation on devfile content err = validate.ValidateDevfileData(d.Data) if err != nil { - return d, err + return d, varWarning, err } - return d, err + return d, varWarning, err } diff --git a/pkg/devfile/parser/data/interface.go b/pkg/devfile/parser/data/interface.go index ff6049c3..69752107 100644 --- a/pkg/devfile/parser/data/interface.go +++ b/pkg/devfile/parser/data/interface.go @@ -54,6 +54,7 @@ type DevfileData interface { // workspace related methods GetDevfileWorkspaceSpecContent() *v1.DevWorkspaceTemplateSpecContent SetDevfileWorkspaceSpecContent(content v1.DevWorkspaceTemplateSpecContent) + GetDevfileWorkspaceSpec() *v1.DevWorkspaceTemplateSpec SetDevfileWorkspaceSpec(spec v1.DevWorkspaceTemplateSpec) // utils diff --git a/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go b/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go index 162324fc..3628e0a4 100644 --- a/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go +++ b/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go @@ -9,6 +9,11 @@ const JsonSchema210 = `{ "schemaVersion" ], "properties": { + "attributes": { + "description": "Map of implementation-dependant free-form YAML attributes.", + "type": "object", + "additionalProperties": true + }, "commands": { "description": "Predefined, ready-to-use, devworkspace-related commands", "type": "array", @@ -635,7 +640,7 @@ const JsonSchema210 = `{ "type": "object", "properties": { "attributes": { - "description": "Map of implementation-dependant free-form YAML attributes.", + "description": "Map of implementation-dependant free-form YAML attributes. Deprecated, use the top-level attributes field instead.", "type": "object", "additionalProperties": true }, @@ -707,6 +712,11 @@ const JsonSchema210 = `{ } ], "properties": { + "attributes": { + "description": "Overrides of attributes encapsulated in a parent devfile. Overriding is done according to K8S strategic merge patch standard rules.", + "type": "object", + "additionalProperties": true + }, "commands": { "description": "Overrides of commands encapsulated in a parent devfile or a plugin. Overriding is done according to K8S strategic merge patch standard rules.", "type": "array", @@ -1527,6 +1537,13 @@ const JsonSchema210 = `{ "uri": { "description": "Uri of a Devfile yaml file", "type": "string" + }, + "variables": { + "description": "Overrides of variables encapsulated in a parent devfile. Overriding is done according to K8S strategic merge patch standard rules.", + "type": "object", + "additionalProperties": { + "type": "string" + } } }, "additionalProperties": false @@ -1786,6 +1803,13 @@ const JsonSchema210 = `{ }, "additionalProperties": false } + }, + "variables": { + "description": "Map of key-value variables used for string replacement in the devfile. Values can can be referenced via {{variable-key}} to replace the corresponding value in string fields in the devfile. Replacement cannot be used for\n\n - schemaVersion, metadata, parent source - element identifiers, e.g. command id, component name, endpoint name, project name - references to identifiers, e.g. in events, a command's component, container's volume mount name - string enums, e.g. command group kind, endpoint exposure", + "type": "object", + "additionalProperties": { + "type": "string" + } } }, "additionalProperties": false diff --git a/pkg/devfile/parser/data/v2/workspace.go b/pkg/devfile/parser/data/v2/workspace.go index 53f0d1fd..6cf94d56 100644 --- a/pkg/devfile/parser/data/v2/workspace.go +++ b/pkg/devfile/parser/data/v2/workspace.go @@ -15,6 +15,10 @@ func (d *DevfileV2) SetDevfileWorkspaceSpecContent(content v1.DevWorkspaceTempla d.DevWorkspaceTemplateSpecContent = content } +func (d *DevfileV2) GetDevfileWorkspaceSpec() *v1.DevWorkspaceTemplateSpec { + return &d.DevWorkspaceTemplateSpec +} + // SetDevfileWorkspaceSpec sets the workspace spec func (d *DevfileV2) SetDevfileWorkspaceSpec(spec v1.DevWorkspaceTemplateSpec) { d.DevWorkspaceTemplateSpec = spec From c0cbaf3e433f60438bf18ad0300df9293ca793f2 Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Mon, 26 Apr 2021 13:12:26 -0400 Subject: [PATCH 2/3] Add interface funcs for top-level attributes Signed-off-by: Maysun J Faisal --- README.md | 7 +- devfile.yaml | 6 +- main.go | 7 +- pkg/devfile/parse.go | 6 +- pkg/devfile/parser/data/interface.go | 19 ++ pkg/devfile/parser/data/v2/attributes.go | 48 +++++ pkg/devfile/parser/data/v2/attributes_test.go | 197 ++++++++++++++++++ pkg/devfile/parser/data/v2/header_test.go | 12 -- pkg/devfile/parser/data/v2/workspace_test.go | 105 ++++++---- 9 files changed, 350 insertions(+), 57 deletions(-) create mode 100644 pkg/devfile/parser/data/v2/attributes.go create mode 100644 pkg/devfile/parser/data/v2/attributes_test.go diff --git a/README.md b/README.md index 0cc85411..a0c87acc 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,10 @@ The Devfile Parser library is a Golang module that: The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/github.com/devfile/library). 1. To parse a devfile, visit pkg/devfile/parse.go - ``` + ```go // Parses the devfile and validates the devfile data - devfile, _, err := devfilePkg.ParseDevfileAndValidate(devfileLocation) + // if top-level variables are not substituted successfully, the warnings can be logged by parsing variableWarning + devfile, variableWarning, err := devfilePkg.ParseDevfileAndValidate(devfileLocation) // To get all the components from the devfile components, err := devfile.Data.GetComponents(DevfileOptions{}) @@ -46,7 +47,7 @@ The function documentation can be accessed via [pkg.go.dev](https://pkg.go.dev/g }) ``` 2. To get the Kubernetes objects from the devfile, visit pkg/devfile/generator/generators.go - ``` + ```go // To get a slice of Kubernetes containers of type corev1.Container from the devfile component containers containers, err := generator.GetContainers(devfile) diff --git a/devfile.yaml b/devfile.yaml index db769a31..47d6cc57 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -4,6 +4,8 @@ metadata: version: 1.0.0 attributes: alpha.build-dockerfile: /relative/path/to/Dockerfile +variables: + test: testValue parent: # uri: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml id: nodejs @@ -58,7 +60,7 @@ components: endpoints: - name: http-9090 targetPort: 9090 - image: registry.access.redhat.com/ubi8/nodejs-12:1-45 + image: "{{invalid-var}}" memoryLimit: 1024Mi mountSources: true sourceMapping: /project @@ -69,7 +71,7 @@ commands: group: isDefault: false kind: build - workingDir: /project + workingDir: "{{test}}" id: install2 attributes: tool: odo diff --git a/main.go b/main.go index 67844d4e..5e4eb54e 100644 --- a/main.go +++ b/main.go @@ -40,10 +40,13 @@ func parserTest() { } fmt.Println("parsing devfile from ./devfile.yaml") } - devfile, _, err := devfilepkg.ParseDevfileAndValidate(args) + devfile, warning, err := devfilepkg.ParseDevfileAndValidate(args) if err != nil { fmt.Println(err) } else { + if len(warning.Commands) > 0 || len(warning.Components) > 0 || len(warning.Projects) > 0 || len(warning.StarterProjects) > 0 { + fmt.Printf("top-level variables were not substituted successfully %+v\n", warning) + } devdata := devfile.Data if (reflect.TypeOf(devdata) == reflect.TypeOf(&v2.DevfileV2{})) { d := devdata.(*v2.DevfileV2) @@ -66,7 +69,7 @@ func parserTest() { } for _, command := range commands { if command.Exec != nil { - fmt.Printf("command %s is with kind: %s", command.Id, command.Exec.Group.Kind) + fmt.Printf("command %s is with kind: %s\n", command.Id, command.Exec.Group.Kind) fmt.Printf("workingDir is: %s\n", command.Exec.WorkingDir) } } diff --git a/pkg/devfile/parse.go b/pkg/devfile/parse.go index a4874669..6eba767f 100644 --- a/pkg/devfile/parse.go +++ b/pkg/devfile/parse.go @@ -79,8 +79,10 @@ func ParseDevfileAndValidate(args parser.ParserArgs) (d parser.DevfileObj, varWa return d, varWarning, err } - // replace the top level variable keys with their values in the devfile - varWarning = variables.ValidateAndReplaceGlobalVariable(d.Data.GetDevfileWorkspaceSpec()) + if d.Data.GetSchemaVersion() != "2.0.0" { + // replace the top level variable keys with their values in the devfile + varWarning = variables.ValidateAndReplaceGlobalVariable(d.Data.GetDevfileWorkspaceSpec()) + } // generic validation on devfile content err = validate.ValidateDevfileData(d.Data) diff --git a/pkg/devfile/parser/data/interface.go b/pkg/devfile/parser/data/interface.go index 69752107..8f4c6a24 100644 --- a/pkg/devfile/parser/data/interface.go +++ b/pkg/devfile/parser/data/interface.go @@ -2,62 +2,81 @@ package data import ( v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" + "github.com/devfile/api/v2/pkg/attributes" devfilepkg "github.com/devfile/api/v2/pkg/devfile" "github.com/devfile/library/pkg/devfile/parser/data/v2/common" ) // DevfileData is an interface that defines functions for Devfile data operations type DevfileData interface { + + // header related methods + GetSchemaVersion() string SetSchemaVersion(version string) GetMetadata() devfilepkg.DevfileMetadata SetMetadata(metadata devfilepkg.DevfileMetadata) + // top-level attributes related method + + GetAttributes() (attributes.Attributes, error) + AddAttributes(key string, value interface{}) error + UpdateAttributes(attr attributes.Attributes) error + // parent related methods + GetParent() *v1.Parent SetParent(parent *v1.Parent) // event related methods + GetEvents() v1.Events AddEvents(events v1.Events) error UpdateEvents(postStart, postStop, preStart, preStop []string) // component related methods + GetComponents(common.DevfileOptions) ([]v1.Component, error) AddComponents(components []v1.Component) error UpdateComponent(component v1.Component) DeleteComponent(name string) error // project related methods + GetProjects(common.DevfileOptions) ([]v1.Project, error) AddProjects(projects []v1.Project) error UpdateProject(project v1.Project) DeleteProject(name string) error // starter projects related commands + GetStarterProjects(common.DevfileOptions) ([]v1.StarterProject, error) AddStarterProjects(projects []v1.StarterProject) error UpdateStarterProject(project v1.StarterProject) DeleteStarterProject(name string) error // command related methods + GetCommands(common.DevfileOptions) ([]v1.Command, error) AddCommands(commands []v1.Command) error UpdateCommand(command v1.Command) DeleteCommand(id string) error // volume mount related methods + AddVolumeMounts(containerName string, volumeMounts []v1.VolumeMount) error DeleteVolumeMount(name string) error GetVolumeMountPaths(mountName, containerName string) ([]string, error) // workspace related methods + GetDevfileWorkspaceSpecContent() *v1.DevWorkspaceTemplateSpecContent SetDevfileWorkspaceSpecContent(content v1.DevWorkspaceTemplateSpecContent) GetDevfileWorkspaceSpec() *v1.DevWorkspaceTemplateSpec SetDevfileWorkspaceSpec(spec v1.DevWorkspaceTemplateSpec) // utils + GetDevfileContainerComponents(common.DevfileOptions) ([]v1.Component, error) GetDevfileVolumeComponents(common.DevfileOptions) ([]v1.Component, error) } diff --git a/pkg/devfile/parser/data/v2/attributes.go b/pkg/devfile/parser/data/v2/attributes.go new file mode 100644 index 00000000..0c062aeb --- /dev/null +++ b/pkg/devfile/parser/data/v2/attributes.go @@ -0,0 +1,48 @@ +package v2 + +import ( + "fmt" + + "github.com/devfile/api/v2/pkg/attributes" +) + +// GetAttributes gets the devfile top level attributes +func (d *DevfileV2) GetAttributes() (attributes.Attributes, error) { + // This feature was introduced in 2.1.0; so any version 2.1.0 and up should use the 2.1.0 implementation + switch d.SchemaVersion { + case "2.0.0": + return attributes.Attributes{}, fmt.Errorf("top-level attributes is not supported in devfile schema version 2.0.0") + default: + return d.Attributes, nil + } +} + +// UpdateAttributes updates the devfile top level attributes +func (d *DevfileV2) UpdateAttributes(attr attributes.Attributes) error { + // This feature was introduced in 2.1.0; so any version 2.1.0 and up should use the 2.1.0 implementation + switch d.SchemaVersion { + case "2.0.0": + return fmt.Errorf("top-level attributes is not supported in devfile schema version 2.0.0") + default: + d.Attributes = attr + } + + return nil +} + +// AddAttributes adds to the devfile top level attributes +func (d *DevfileV2) AddAttributes(key string, value interface{}) error { + // This feature was introduced in 2.1.0; so any version 2.1.0 and up should use the 2.1.0 implementation + switch d.SchemaVersion { + case "2.0.0": + return fmt.Errorf("top-level attributes is not supported in devfile schema version 2.0.0") + default: + var err error + d.Attributes.Put(key, value, &err) + if err != nil { + return err + } + } + + return nil +} diff --git a/pkg/devfile/parser/data/v2/attributes_test.go b/pkg/devfile/parser/data/v2/attributes_test.go new file mode 100644 index 00000000..d52c44aa --- /dev/null +++ b/pkg/devfile/parser/data/v2/attributes_test.go @@ -0,0 +1,197 @@ +package v2 + +import ( + "reflect" + "testing" + + "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" + "github.com/devfile/api/v2/pkg/attributes" + devfilepkg "github.com/devfile/api/v2/pkg/devfile" + "github.com/kylelemons/godebug/pretty" +) + +func TestGetAttributes(t *testing.T) { + + tests := []struct { + name string + devfilev2 *DevfileV2 + wantAttributes attributes.Attributes + wantErr bool + }{ + { + name: "Schema 2.0.0 does not have attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.0.0", + }, + }, + }, + wantErr: true, + }, + { + name: "Schema 2.1.0 has attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.1.0", + }, + DevWorkspaceTemplateSpec: v1alpha2.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: v1alpha2.DevWorkspaceTemplateSpecContent{ + Attributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + }, + }, + }, + wantAttributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + attributes, err := tt.devfilev2.GetAttributes() + if tt.wantErr == (err == nil) { + t.Errorf("TestGetAttributes error - %v, wantErr %v", err, tt.wantErr) + } else if err == nil { + if !reflect.DeepEqual(attributes, tt.wantAttributes) { + t.Errorf("TestGetAttributes error - actual does not equal expected, difference at %+v", pretty.Compare(attributes, tt.wantAttributes)) + } + } + }) + } +} + +func TestUpdateAttributes(t *testing.T) { + + tests := []struct { + name string + devfilev2 *DevfileV2 + attributes attributes.Attributes + wantErr bool + }{ + { + name: "Schema 2.0.0 does not have attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.0.0", + }, + }, + }, + wantErr: true, + }, + { + name: "Schema 2.1.0 has attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.1.0", + }, + DevWorkspaceTemplateSpec: v1alpha2.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: v1alpha2.DevWorkspaceTemplateSpecContent{ + Attributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + }, + }, + }, + attributes: attributes.Attributes{}.PutString("key3", "value3"), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.devfilev2.UpdateAttributes(tt.attributes) + if tt.wantErr == (err == nil) { + t.Errorf("TestUpdateAttributes error - %v, wantErr %v", err, tt.wantErr) + } else if err == nil { + attributes, err := tt.devfilev2.GetAttributes() + if err != nil { + t.Errorf("TestUpdateAttributes error2 - %+v", err) + } + if !reflect.DeepEqual(attributes, tt.attributes) { + t.Errorf("TestUpdateAttributes mismatch error - expected %+v, actual %+v", tt.attributes, attributes) + } + } + }) + } +} + +func TestAddAttributes(t *testing.T) { + + nestedValue := map[string]interface{}{ + "key3.1": map[string]interface{}{ + "key3.1.1": "value3.1.1", + }, + } + + tests := []struct { + name string + devfilev2 *DevfileV2 + key string + value interface{} + wantAttributes attributes.Attributes + wantErr bool + }{ + { + name: "Schema 2.0.0 does not have attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.0.0", + }, + }, + }, + wantErr: true, + }, + { + name: "Schema 2.1.0 has attributes", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.1.0", + }, + DevWorkspaceTemplateSpec: v1alpha2.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: v1alpha2.DevWorkspaceTemplateSpecContent{ + Attributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + }, + }, + }, + key: "key3", + value: nestedValue, + wantAttributes: attributes.Attributes{}.PutString("key1", "value1").Put("key3", nestedValue, nil).PutString("key2", "value2"), + }, + { + name: "If Schema 2.1.0 has an attribute already present, it should overwrite", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.1.0", + }, + DevWorkspaceTemplateSpec: v1alpha2.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: v1alpha2.DevWorkspaceTemplateSpecContent{ + Attributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + }, + }, + }, + key: "key2", + value: "value2new", + wantAttributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2new"), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.devfilev2.AddAttributes(tt.key, tt.value) + if tt.wantErr == (err == nil) { + t.Errorf("TestAddAttributes error - %v, wantErr %v", err, tt.wantErr) + } else if err == nil { + attributes, err := tt.devfilev2.GetAttributes() + if err != nil { + t.Errorf("TestAddAttributes error2 - %+v", err) + } + if !reflect.DeepEqual(attributes, tt.wantAttributes) { + t.Errorf("TestAddAttributes mismatch error - expected %+v, actual %+v", tt.wantAttributes, attributes) + } + } + }) + } +} diff --git a/pkg/devfile/parser/data/v2/header_test.go b/pkg/devfile/parser/data/v2/header_test.go index f7e2835f..0c8a1eaa 100644 --- a/pkg/devfile/parser/data/v2/header_test.go +++ b/pkg/devfile/parser/data/v2/header_test.go @@ -11,9 +11,6 @@ import ( func TestDevfile200_GetSchemaVersion(t *testing.T) { - type args struct { - name string - } tests := []struct { name string expectedSchemaVersion string @@ -43,9 +40,6 @@ func TestDevfile200_GetSchemaVersion(t *testing.T) { func TestDevfile200_SetSchemaVersion(t *testing.T) { - type args struct { - name string - } tests := []struct { name string schemaVersion string @@ -99,9 +93,6 @@ func TestDevfile200_SetSchemaVersion(t *testing.T) { func TestDevfile200_GetMetadata(t *testing.T) { - type args struct { - name string - } tests := []struct { name string devfilev2 *DevfileV2 @@ -148,9 +139,6 @@ func TestDevfile200_GetMetadata(t *testing.T) { func TestDevfile200_SetSetMetadata(t *testing.T) { - type args struct { - name string - } tests := []struct { name string metadata devfilepkg.DevfileMetadata diff --git a/pkg/devfile/parser/data/v2/workspace_test.go b/pkg/devfile/parser/data/v2/workspace_test.go index 2eb026ee..96957149 100644 --- a/pkg/devfile/parser/data/v2/workspace_test.go +++ b/pkg/devfile/parser/data/v2/workspace_test.go @@ -7,57 +7,90 @@ import ( v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" ) +var devworkspaceContent = v1.DevWorkspaceTemplateSpecContent{ + Components: []v1.Component{ + { + Name: "component1", + ComponentUnion: v1.ComponentUnion{ + Container: &v1.ContainerComponent{}, + }, + }, + { + Name: "component2", + ComponentUnion: v1.ComponentUnion{ + Volume: &v1.VolumeComponent{}, + }, + }, + }, +} + func TestDevfile200_SetDevfileWorkspaceSpecContent(t *testing.T) { - type args struct { - name string + devfilev2 := &DevfileV2{ + v1.Devfile{}, + } + + tests := []struct { + name string + workspaceSpecContent v1.DevWorkspaceTemplateSpecContent + expectedDevfilev2 *DevfileV2 + }{ + { + name: "set workspace", + workspaceSpecContent: devworkspaceContent, + expectedDevfilev2: &DevfileV2{ + v1.Devfile{ + DevWorkspaceTemplateSpec: v1.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: devworkspaceContent, + }, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + devfilev2.SetDevfileWorkspaceSpecContent(tt.workspaceSpecContent) + if !reflect.DeepEqual(devfilev2, tt.expectedDevfilev2) { + t.Errorf("TestDevfile200_SetDevfileWorkspaceSpecContent() expected %v, got %v", tt.expectedDevfilev2, devfilev2) + } + }) + } +} + +func TestDevfile200_SetDevfileWorkspaceSpec(t *testing.T) { + + devfilev2 := &DevfileV2{ + v1.Devfile{}, } + tests := []struct { name string - workspace v1.DevWorkspaceTemplateSpecContent - devfilev2 *DevfileV2 + workspaceSpec v1.DevWorkspaceTemplateSpec expectedDevfilev2 *DevfileV2 }{ { - name: "set workspace", - devfilev2: &DevfileV2{ - v1.Devfile{}, - }, - workspace: v1.DevWorkspaceTemplateSpecContent{ - Components: []v1.Component{ - { - Name: "component1", - ComponentUnion: v1.ComponentUnion{ - Container: &v1.ContainerComponent{}, - }, - }, - { - Name: "component2", - ComponentUnion: v1.ComponentUnion{ - Volume: &v1.VolumeComponent{}, + name: "set workspace spec", + workspaceSpec: v1.DevWorkspaceTemplateSpec{ + Parent: &v1.Parent{ + ImportReference: v1.ImportReference{ + ImportReferenceUnion: v1.ImportReferenceUnion{ + Uri: "uri", }, }, }, + DevWorkspaceTemplateSpecContent: devworkspaceContent, }, expectedDevfilev2: &DevfileV2{ v1.Devfile{ DevWorkspaceTemplateSpec: v1.DevWorkspaceTemplateSpec{ - DevWorkspaceTemplateSpecContent: v1.DevWorkspaceTemplateSpecContent{ - Components: []v1.Component{ - { - Name: "component1", - ComponentUnion: v1.ComponentUnion{ - Container: &v1.ContainerComponent{}, - }, - }, - { - Name: "component2", - ComponentUnion: v1.ComponentUnion{ - Volume: &v1.VolumeComponent{}, - }, + Parent: &v1.Parent{ + ImportReference: v1.ImportReference{ + ImportReferenceUnion: v1.ImportReferenceUnion{ + Uri: "uri", }, }, }, + DevWorkspaceTemplateSpecContent: devworkspaceContent, }, }, }, @@ -65,9 +98,9 @@ func TestDevfile200_SetDevfileWorkspaceSpecContent(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tt.devfilev2.SetDevfileWorkspaceSpecContent(tt.workspace) - if !reflect.DeepEqual(tt.devfilev2, tt.expectedDevfilev2) { - t.Errorf("TestDevfile200_SetDevfileWorkspaceSpecContent() expected %v, got %v", tt.expectedDevfilev2, tt.devfilev2) + devfilev2.SetDevfileWorkspaceSpec(tt.workspaceSpec) + if !reflect.DeepEqual(devfilev2, tt.expectedDevfilev2) { + t.Errorf("TestDevfile200_SetDevfileWorkspaceSpec() expected %v, got %v", tt.expectedDevfilev2, devfilev2) } }) } From 28cfac00e0399b7fdf10700a3e9a26e3bd6d01c6 Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Fri, 30 Apr 2021 12:00:32 -0400 Subject: [PATCH 3/3] Address PR review feedback - attribute funcs Signed-off-by: Maysun J Faisal --- pkg/devfile/parser/data/interface.go | 2 +- pkg/devfile/parser/data/v2/attributes.go | 24 +++++---- pkg/devfile/parser/data/v2/attributes_test.go | 52 +++++++++++++++---- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/pkg/devfile/parser/data/interface.go b/pkg/devfile/parser/data/interface.go index 8f4c6a24..8b61742c 100644 --- a/pkg/devfile/parser/data/interface.go +++ b/pkg/devfile/parser/data/interface.go @@ -21,7 +21,7 @@ type DevfileData interface { GetAttributes() (attributes.Attributes, error) AddAttributes(key string, value interface{}) error - UpdateAttributes(attr attributes.Attributes) error + UpdateAttributes(key string, value interface{}) error // parent related methods diff --git a/pkg/devfile/parser/data/v2/attributes.go b/pkg/devfile/parser/data/v2/attributes.go index 0c062aeb..d241a1b5 100644 --- a/pkg/devfile/parser/data/v2/attributes.go +++ b/pkg/devfile/parser/data/v2/attributes.go @@ -17,32 +17,36 @@ func (d *DevfileV2) GetAttributes() (attributes.Attributes, error) { } } -// UpdateAttributes updates the devfile top level attributes -func (d *DevfileV2) UpdateAttributes(attr attributes.Attributes) error { +// UpdateAttributes updates the devfile top level attribute for the specific key, err out if key is absent +func (d *DevfileV2) UpdateAttributes(key string, value interface{}) error { + var err error + // This feature was introduced in 2.1.0; so any version 2.1.0 and up should use the 2.1.0 implementation switch d.SchemaVersion { case "2.0.0": return fmt.Errorf("top-level attributes is not supported in devfile schema version 2.0.0") default: - d.Attributes = attr + if d.Attributes.Exists(key) { + d.Attributes.Put(key, value, &err) + } else { + return fmt.Errorf("cannot update top-level attribute, key %s is not present", key) + } } - return nil + return err } -// AddAttributes adds to the devfile top level attributes +// AddAttributes adds to the devfile top level attributes, value will be overwritten if key is already present func (d *DevfileV2) AddAttributes(key string, value interface{}) error { + var err error + // This feature was introduced in 2.1.0; so any version 2.1.0 and up should use the 2.1.0 implementation switch d.SchemaVersion { case "2.0.0": return fmt.Errorf("top-level attributes is not supported in devfile schema version 2.0.0") default: - var err error d.Attributes.Put(key, value, &err) - if err != nil { - return err - } } - return nil + return err } diff --git a/pkg/devfile/parser/data/v2/attributes_test.go b/pkg/devfile/parser/data/v2/attributes_test.go index d52c44aa..133bb7a1 100644 --- a/pkg/devfile/parser/data/v2/attributes_test.go +++ b/pkg/devfile/parser/data/v2/attributes_test.go @@ -62,11 +62,19 @@ func TestGetAttributes(t *testing.T) { func TestUpdateAttributes(t *testing.T) { + nestedValue := map[string]interface{}{ + "key1.1": map[string]interface{}{ + "key1.1.1": "value1.1.1", + }, + } + tests := []struct { - name string - devfilev2 *DevfileV2 - attributes attributes.Attributes - wantErr bool + name string + devfilev2 *DevfileV2 + key string + value interface{} + wantAttributes attributes.Attributes + wantErr bool }{ { name: "Schema 2.0.0 does not have attributes", @@ -80,7 +88,25 @@ func TestUpdateAttributes(t *testing.T) { wantErr: true, }, { - name: "Schema 2.1.0 has attributes", + name: "Schema 2.1.0 has the top-level key attribute", + devfilev2: &DevfileV2{ + v1alpha2.Devfile{ + DevfileHeader: devfilepkg.DevfileHeader{ + SchemaVersion: "2.1.0", + }, + DevWorkspaceTemplateSpec: v1alpha2.DevWorkspaceTemplateSpec{ + DevWorkspaceTemplateSpecContent: v1alpha2.DevWorkspaceTemplateSpecContent{ + Attributes: attributes.Attributes{}.PutString("key1", "value1").PutString("key2", "value2"), + }, + }, + }, + }, + key: "key1", + value: nestedValue, + wantAttributes: attributes.Attributes{}.Put("key1", nestedValue, nil).PutString("key2", "value2"), + }, + { + name: "Schema 2.1.0 does not have the top-level key attribute", devfilev2: &DevfileV2{ v1alpha2.Devfile{ DevfileHeader: devfilepkg.DevfileHeader{ @@ -93,21 +119,24 @@ func TestUpdateAttributes(t *testing.T) { }, }, }, - attributes: attributes.Attributes{}.PutString("key3", "value3"), + key: "key_invalid", + value: nestedValue, + wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.devfilev2.UpdateAttributes(tt.attributes) + err := tt.devfilev2.UpdateAttributes(tt.key, tt.value) if tt.wantErr == (err == nil) { t.Errorf("TestUpdateAttributes error - %v, wantErr %v", err, tt.wantErr) } else if err == nil { attributes, err := tt.devfilev2.GetAttributes() if err != nil { - t.Errorf("TestUpdateAttributes error2 - %+v", err) + t.Errorf("TestUpdateAttributes error - %+v", err) + return } - if !reflect.DeepEqual(attributes, tt.attributes) { - t.Errorf("TestUpdateAttributes mismatch error - expected %+v, actual %+v", tt.attributes, attributes) + if !reflect.DeepEqual(attributes, tt.wantAttributes) { + t.Errorf("TestUpdateAttributes mismatch error - expected %+v, actual %+v", tt.wantAttributes, attributes) } } }) @@ -186,7 +215,8 @@ func TestAddAttributes(t *testing.T) { } else if err == nil { attributes, err := tt.devfilev2.GetAttributes() if err != nil { - t.Errorf("TestAddAttributes error2 - %+v", err) + t.Errorf("TestAddAttributes error - %+v", err) + return } if !reflect.DeepEqual(attributes, tt.wantAttributes) { t.Errorf("TestAddAttributes mismatch error - expected %+v, actual %+v", tt.wantAttributes, attributes)