diff --git a/go.mod b/go.mod index ed7f743e5b1..7c6d2999b66 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Xuanwo/go-locale v1.1.0 github.com/blang/semver v3.5.1+incompatible github.com/devfile/api/v2 v2.2.0 - github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c + github.com/devfile/library/v2 v2.2.1-0.20230118161058-0d04f791d801 github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273 github.com/devfile/registry-support/registry-library v0.0.0-20221201200738-19293ac0b8ab github.com/fatih/color v1.13.0 diff --git a/go.sum b/go.sum index a5214763e30..12d987d3327 100644 --- a/go.sum +++ b/go.sum @@ -373,19 +373,19 @@ github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1 github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/devfile/api/v2 v2.0.0-20211021164004-dabee4e633ed/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= -github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4= github.com/devfile/api/v2 v2.2.0 h1:3Mwl/dtT508oU4pNt/v4G8vqvjoZqi9LOInXCNwKMoc= github.com/devfile/api/v2 v2.2.0/go.mod h1:dN7xFrOVG+iPqn4UKGibXLd5oVsdE8XyK9OEb5JL3aI= github.com/devfile/library v1.2.1-0.20211104222135-49d635cb492f/go.mod h1:uFZZdTuRqA68FVe/JoJHP92CgINyQkyWnM2Qyiim+50= github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de/go.mod h1:GSPfJaBg0+bBjBHbwBE5aerJLH6tWGQu2q2rHYd9czM= -github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c h1:Puqg/NJ6pP1LPFxPYBX9c0Oh0Ttu5PVdNJL5WR/CRTk= -github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c/go.mod h1:kpkIA9YI7gkfglRDsKJ3n5QgVyyBmnasr2U2djYwg6s= github.com/devfile/library/v2 v2.0.1/go.mod h1:paJ0PARAVy0br13VpBEQ4fO3rZVDxWtooQ29+23PNBk= +github.com/devfile/library/v2 v2.2.1-0.20230118161058-0d04f791d801 h1:DreLje9666H/di1jx4nj7+I4vV6C4M0T02FW05heI+0= +github.com/devfile/library/v2 v2.2.1-0.20230118161058-0d04f791d801/go.mod h1:DkZkmV09jZjOtkVgZ8YMWeMTIRM/twUGE1HdToIhkUA= github.com/devfile/registry-support/index/generator v0.0.0-20220222194908-7a90a4214f3e/go.mod h1:iRPBxs+ZjfLEduVXpCCIOzdD2588Zv9OCs/CcXMcCCY= github.com/devfile/registry-support/index/generator v0.0.0-20220527155645-8328a8a883be/go.mod h1:1fyDJL+fPHtcrYA6yjSVWeLmXmjCNth0d5Rq1rvtryc= github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273 h1:DXENQSRTEDsk9com38njPg5511DD12HPIgzyFUErnpM= github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273/go.mod h1:ZJnaSLjTKCvGJhWmYgQoQ1O3g78qBe4Va6ZugLmi4dE= github.com/devfile/registry-support/registry-library v0.0.0-20220627163229-4aa39fcb0c0a/go.mod h1:kmEjH5oO465vh36kcYdZLYeG8edVD6N/ZgzyLs1x7qs= +github.com/devfile/registry-support/registry-library v0.0.0-20221018213054-47b3ffaeadba/go.mod h1:NOtmnbozFn15w/DPD/Urc+KDlNRP4JH5m+KC5GZoAWA= github.com/devfile/registry-support/registry-library v0.0.0-20221201200738-19293ac0b8ab h1:MBZdywPNNDf1f7V+plOOHqAiaY/C+IELrI4Rfdq78e4= github.com/devfile/registry-support/registry-library v0.0.0-20221201200738-19293ac0b8ab/go.mod h1:NOtmnbozFn15w/DPD/Urc+KDlNRP4JH5m+KC5GZoAWA= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= diff --git a/pkg/api/devfile-data.go b/pkg/api/devfile-data.go index 0c7b3dff141..172f5df0164 100644 --- a/pkg/api/devfile-data.go +++ b/pkg/api/devfile-data.go @@ -1,6 +1,6 @@ package api -import "github.com/devfile/library/pkg/devfile/parser/data" +import "github.com/devfile/library/v2/pkg/devfile/parser/data" // DevfileData describes a devfile content type DevfileData struct { diff --git a/pkg/api/utils.go b/pkg/api/utils.go index a6bb228fdf3..4716b28d235 100644 --- a/pkg/api/utils.go +++ b/pkg/api/utils.go @@ -1,8 +1,8 @@ package api import ( - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/redhat-developer/odo/pkg/libdevfile" ) diff --git a/pkg/binding/add.go b/pkg/binding/add.go index b76bed65338..e5be593d273 100644 --- a/pkg/binding/add.go +++ b/pkg/binding/add.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/binding/backend/flags.go b/pkg/binding/backend/flags.go index 7c0d2fe192f..d283401d6f1 100644 --- a/pkg/binding/backend/flags.go +++ b/pkg/binding/backend/flags.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/binding/binding.go b/pkg/binding/binding.go index 4b1c2db73be..7a91453f6ee 100644 --- a/pkg/binding/binding.go +++ b/pkg/binding/binding.go @@ -12,8 +12,8 @@ import ( "github.com/redhat-developer/odo/pkg/project" - "github.com/devfile/library/pkg/devfile/parser" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "gopkg.in/yaml.v2" appsv1 "k8s.io/api/apps/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -22,7 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" devfilev1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/binding/asker" diff --git a/pkg/binding/binding_test.go b/pkg/binding/binding_test.go index e7076772e2d..cf4f0c67e3e 100644 --- a/pkg/binding/binding_test.go +++ b/pkg/binding/binding_test.go @@ -5,9 +5,9 @@ import ( "testing" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" diff --git a/pkg/binding/interface.go b/pkg/binding/interface.go index 93fc3e38bd5..15d9b2a3cd5 100644 --- a/pkg/binding/interface.go +++ b/pkg/binding/interface.go @@ -1,7 +1,7 @@ package binding import ( - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/binding/list.go b/pkg/binding/list.go index a9f186808c4..ba896c9608c 100644 --- a/pkg/binding/list.go +++ b/pkg/binding/list.go @@ -4,7 +4,7 @@ import ( "sort" "strings" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/labels" diff --git a/pkg/binding/list_test.go b/pkg/binding/list_test.go index f1c1f8ab81c..ad3a15f8d40 100644 --- a/pkg/binding/list_test.go +++ b/pkg/binding/list_test.go @@ -3,7 +3,7 @@ package binding import ( "testing" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" diff --git a/pkg/binding/mock.go b/pkg/binding/mock.go index 9958a4aafc6..6cd4e1ce952 100644 --- a/pkg/binding/mock.go +++ b/pkg/binding/mock.go @@ -7,7 +7,7 @@ package binding import ( reflect "reflect" - parser "github.com/devfile/library/pkg/devfile/parser" + parser "github.com/devfile/library/v2/pkg/devfile/parser" gomock "github.com/golang/mock/gomock" api "github.com/redhat-developer/odo/pkg/api" asker "github.com/redhat-developer/odo/pkg/binding/asker" diff --git a/pkg/binding/remove.go b/pkg/binding/remove.go index 53c8f92c557..535046ce670 100644 --- a/pkg/binding/remove.go +++ b/pkg/binding/remove.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" backendpkg "github.com/redhat-developer/odo/pkg/binding/backend" diff --git a/pkg/binding/remove_binding_test.go b/pkg/binding/remove_binding_test.go index d6e10c657fb..d5325ddc569 100644 --- a/pkg/binding/remove_binding_test.go +++ b/pkg/binding/remove_binding_test.go @@ -3,8 +3,8 @@ package binding import ( "testing" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" "github.com/google/go-cmp/cmp" odoTestingUtil "github.com/redhat-developer/odo/pkg/testingutil" diff --git a/pkg/component/apply_kubernetes.go b/pkg/component/apply_kubernetes.go index 1d6a69b531d..d6ec15d6400 100644 --- a/pkg/component/apply_kubernetes.go +++ b/pkg/component/apply_kubernetes.go @@ -4,8 +4,8 @@ import ( "fmt" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/kclient" diff --git a/pkg/component/component.go b/pkg/component/component.go index 6df53886ac4..676871af8b7 100644 --- a/pkg/component/component.go +++ b/pkg/component/component.go @@ -9,8 +9,8 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" routev1 "github.com/openshift/api/route/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog" diff --git a/pkg/component/component_test.go b/pkg/component/component_test.go index 000e6b72de9..a84a2079d79 100644 --- a/pkg/component/component_test.go +++ b/pkg/component/component_test.go @@ -9,12 +9,12 @@ import ( "testing" devfilepkg "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - "github.com/devfile/library/pkg/testingutil/filesystem" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" v12 "github.com/openshift/api/route/v1" diff --git a/pkg/component/delete/delete.go b/pkg/component/delete/delete.go index fdacc212cd5..f1ed399f1a6 100644 --- a/pkg/component/delete/delete.go +++ b/pkg/component/delete/delete.go @@ -5,7 +5,7 @@ import ( "fmt" "path/filepath" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/component/delete/delete_test.go b/pkg/component/delete/delete_test.go index 46a09d8c505..8fe3fe7cafb 100644 --- a/pkg/component/delete/delete_test.go +++ b/pkg/component/delete/delete_test.go @@ -6,10 +6,18 @@ import ( "reflect" "testing" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + kerrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/redhat-developer/odo/pkg/exec" "github.com/redhat-developer/odo/pkg/kclient" odolabels "github.com/redhat-developer/odo/pkg/labels" @@ -18,13 +26,6 @@ import ( "github.com/redhat-developer/odo/pkg/podman" odoTestingUtil "github.com/redhat-developer/odo/pkg/testingutil" "github.com/redhat-developer/odo/pkg/util" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - kerrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/component/delete/interface.go b/pkg/component/delete/interface.go index 22b4974515a..ae52201e456 100644 --- a/pkg/component/delete/interface.go +++ b/pkg/component/delete/interface.go @@ -3,7 +3,7 @@ package delete import ( "context" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/component/delete/mock.go b/pkg/component/delete/mock.go index 4362de559d3..c8f7aecaeac 100644 --- a/pkg/component/delete/mock.go +++ b/pkg/component/delete/mock.go @@ -8,7 +8,7 @@ import ( context "context" reflect "reflect" - parser "github.com/devfile/library/pkg/devfile/parser" + parser "github.com/devfile/library/v2/pkg/devfile/parser" gomock "github.com/golang/mock/gomock" v1 "k8s.io/api/core/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/component/validate.go b/pkg/component/validate.go index aa73a325233..f283bcc9bbb 100644 --- a/pkg/component/validate.go +++ b/pkg/component/validate.go @@ -6,8 +6,8 @@ import ( "strings" devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/redhat-developer/odo/pkg/kclient" "github.com/redhat-developer/odo/pkg/libdevfile" diff --git a/pkg/deploy/deploy.go b/pkg/deploy/deploy.go index f2556778f1f..96b15756f54 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/deploy.go @@ -6,7 +6,7 @@ import ( "path/filepath" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/component" "github.com/redhat-developer/odo/pkg/devfile/image" diff --git a/pkg/dev/common/common.go b/pkg/dev/common/common.go index 9306a328df2..e1dbf62d63e 100644 --- a/pkg/dev/common/common.go +++ b/pkg/dev/common/common.go @@ -3,7 +3,7 @@ package common import ( "fmt" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/dev/common/common_test.go b/pkg/dev/common/common_test.go index 8f867e48f78..597d67decb8 100644 --- a/pkg/dev/common/common_test.go +++ b/pkg/dev/common/common_test.go @@ -3,7 +3,7 @@ package common import ( "testing" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/dev/podmandev/pod.go b/pkg/dev/podmandev/pod.go index 5ede93e26ce..ee8202b6cfe 100644 --- a/pkg/dev/podmandev/pod.go +++ b/pkg/dev/podmandev/pod.go @@ -3,9 +3,9 @@ package podmandev import ( "fmt" - "github.com/devfile/library/pkg/devfile/generator" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/component" diff --git a/pkg/dev/podmandev/pod_test.go b/pkg/dev/podmandev/pod_test.go index 6ab26ccd3d6..51589166a3f 100644 --- a/pkg/dev/podmandev/pod_test.go +++ b/pkg/dev/podmandev/pod_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" diff --git a/pkg/dev/podmandev/podmandev.go b/pkg/dev/podmandev/podmandev.go index 7c1a727a570..b882a7db429 100644 --- a/pkg/dev/podmandev/podmandev.go +++ b/pkg/dev/podmandev/podmandev.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/dev" diff --git a/pkg/dev/podmandev/reconcile.go b/pkg/dev/podmandev/reconcile.go index d6c7fe1a19f..449a7d135d8 100644 --- a/pkg/dev/podmandev/reconcile.go +++ b/pkg/dev/podmandev/reconcile.go @@ -8,7 +8,7 @@ import ( "strings" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/fatih/color" "github.com/redhat-developer/odo/pkg/api" diff --git a/pkg/devfile/adapters/kubernetes/component/adapter.go b/pkg/devfile/adapters/kubernetes/component/adapter.go index 7794ce889d7..ca1cbe73108 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter.go @@ -9,7 +9,7 @@ import ( "strings" sync2 "sync" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" kerrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" @@ -38,10 +38,10 @@ import ( "github.com/redhat-developer/odo/pkg/watch" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/generator" - "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + dfutil "github.com/devfile/library/v2/pkg/util" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/pkg/devfile/adapters/kubernetes/component/adapter_test.go b/pkg/devfile/adapters/kubernetes/component/adapter_test.go index abc79b12d8a..62c29c39c46 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter_test.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter_test.go @@ -3,8 +3,8 @@ package component import ( "testing" - "github.com/devfile/library/pkg/devfile/generator" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" @@ -13,8 +13,8 @@ import ( "github.com/redhat-developer/odo/pkg/util" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/testingutil" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/testingutil" "github.com/redhat-developer/odo/pkg/kclient" odolabels "github.com/redhat-developer/odo/pkg/labels" diff --git a/pkg/devfile/adapters/kubernetes/component/handler.go b/pkg/devfile/adapters/kubernetes/component/handler.go index 02dae7e2dd7..bd846897d74 100644 --- a/pkg/devfile/adapters/kubernetes/component/handler.go +++ b/pkg/devfile/adapters/kubernetes/component/handler.go @@ -4,7 +4,7 @@ import ( "context" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/component" "github.com/redhat-developer/odo/pkg/devfile/image" "github.com/redhat-developer/odo/pkg/exec" diff --git a/pkg/devfile/adapters/kubernetes/storage/utils.go b/pkg/devfile/adapters/kubernetes/storage/utils.go index c6b9ce2b928..4bf0810a9a0 100644 --- a/pkg/devfile/adapters/kubernetes/storage/utils.go +++ b/pkg/devfile/adapters/kubernetes/storage/utils.go @@ -5,10 +5,10 @@ import ( "sort" "strings" - "github.com/devfile/library/pkg/devfile/generator" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/generator" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/kclient" odolabels "github.com/redhat-developer/odo/pkg/labels" diff --git a/pkg/devfile/adapters/kubernetes/storage/utils_test.go b/pkg/devfile/adapters/kubernetes/storage/utils_test.go index 3eaaaf2a6b6..d9b3b9d8c3c 100644 --- a/pkg/devfile/adapters/kubernetes/storage/utils_test.go +++ b/pkg/devfile/adapters/kubernetes/storage/utils_test.go @@ -5,10 +5,10 @@ import ( devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/v2/pkg/attributes" - "github.com/devfile/library/pkg/devfile/generator" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/generator" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" diff --git a/pkg/devfile/adapters/kubernetes/utils/utils.go b/pkg/devfile/adapters/kubernetes/utils/utils.go index 4d26411437f..ec95294b378 100644 --- a/pkg/devfile/adapters/kubernetes/utils/utils.go +++ b/pkg/devfile/adapters/kubernetes/utils/utils.go @@ -2,7 +2,7 @@ package utils import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - devfileParser "github.com/devfile/library/pkg/devfile/parser" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" corev1 "k8s.io/api/core/v1" "k8s.io/klog" diff --git a/pkg/devfile/adapters/kubernetes/utils/utils_test.go b/pkg/devfile/adapters/kubernetes/utils/utils_test.go index 825e48654a6..cc8d2568783 100644 --- a/pkg/devfile/adapters/kubernetes/utils/utils_test.go +++ b/pkg/devfile/adapters/kubernetes/utils/utils_test.go @@ -3,14 +3,14 @@ package utils import ( "testing" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/google/go-cmp/cmp" "github.com/redhat-developer/odo/pkg/storage" "github.com/redhat-developer/odo/pkg/util" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - devfileParser "github.com/devfile/library/pkg/devfile/parser" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/devfile/components.go b/pkg/devfile/components.go index fed70724568..60489da9dcb 100644 --- a/pkg/devfile/components.go +++ b/pkg/devfile/components.go @@ -2,8 +2,8 @@ package devfile import ( devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) // GetKubernetesComponentsToPush returns the list of Kubernetes components to push, diff --git a/pkg/devfile/components_test.go b/pkg/devfile/components_test.go index 889181c87c5..36c69a84b8d 100644 --- a/pkg/devfile/components_test.go +++ b/pkg/devfile/components_test.go @@ -9,9 +9,9 @@ import ( devfiletesting "github.com/redhat-developer/odo/pkg/devfile/testing" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - devfileFileSystem "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + devfileFileSystem "github.com/devfile/library/v2/pkg/testingutil/filesystem" ) func TestGetKubernetesComponentsToPush(t *testing.T) { diff --git a/pkg/devfile/devfile.go b/pkg/devfile/devfile.go index c00963465b5..92e468ce0c2 100644 --- a/pkg/devfile/devfile.go +++ b/pkg/devfile/devfile.go @@ -5,8 +5,8 @@ import ( "strings" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/devfile/validate" "github.com/redhat-developer/odo/pkg/log" diff --git a/pkg/devfile/image/docker_compatible.go b/pkg/devfile/image/docker_compatible.go index 64c45a23775..5af22a369e2 100644 --- a/pkg/devfile/image/docker_compatible.go +++ b/pkg/devfile/image/docker_compatible.go @@ -11,7 +11,7 @@ import ( "github.com/fatih/color" "k8s.io/klog" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/log" "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/devfile/image/image.go b/pkg/devfile/image/image.go index c5062d32315..b23b0c92b12 100644 --- a/pkg/devfile/image/image.go +++ b/pkg/devfile/image/image.go @@ -8,7 +8,7 @@ import ( "path/filepath" devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" envcontext "github.com/redhat-developer/odo/pkg/config/context" "github.com/redhat-developer/odo/pkg/libdevfile" diff --git a/pkg/devfile/testing/testing.go b/pkg/devfile/testing/testing.go index d24cd6fc089..01b74fdb38f 100644 --- a/pkg/devfile/testing/testing.go +++ b/pkg/devfile/testing/testing.go @@ -6,8 +6,8 @@ import ( "testing" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data" - devfileFileSystem "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + devfileFileSystem "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/redhat-developer/odo/pkg/devfile/consts" ) diff --git a/pkg/devfile/validate/validate.go b/pkg/devfile/validate/validate.go index df75170e54c..efb9263d484 100644 --- a/pkg/devfile/validate/validate.go +++ b/pkg/devfile/validate/validate.go @@ -5,8 +5,8 @@ import ( "strings" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - v2 "github.com/devfile/library/pkg/devfile/parser/data/v2" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + v2 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "k8s.io/klog" ) diff --git a/pkg/devfile/validate/validate_test.go b/pkg/devfile/validate/validate_test.go index 35e3a1dbb3f..b227a8aaecc 100644 --- a/pkg/devfile/validate/validate_test.go +++ b/pkg/devfile/validate/validate_test.go @@ -3,12 +3,12 @@ package validate import ( "testing" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - "github.com/devfile/library/pkg/testingutil" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/testingutil" "github.com/redhat-developer/odo/pkg/util" ) diff --git a/pkg/init/backend/alizer.go b/pkg/init/backend/alizer.go index 87ac150b9ca..50acfa218f9 100644 --- a/pkg/init/backend/alizer.go +++ b/pkg/init/backend/alizer.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/alizer" "github.com/redhat-developer/odo/pkg/api" diff --git a/pkg/init/backend/applicationports.go b/pkg/init/backend/applicationports.go index efffe5aeb5d..7b1f3526e7a 100644 --- a/pkg/init/backend/applicationports.go +++ b/pkg/init/backend/applicationports.go @@ -5,8 +5,8 @@ import ( "io" "strconv" - "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/libdevfile" diff --git a/pkg/init/backend/applicationports_test.go b/pkg/init/backend/applicationports_test.go index d32df542d30..040f8879260 100644 --- a/pkg/init/backend/applicationports_test.go +++ b/pkg/init/backend/applicationports_test.go @@ -6,10 +6,10 @@ import ( v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" devfilepkg "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" diff --git a/pkg/init/backend/flags.go b/pkg/init/backend/flags.go index 2309bbc7180..05c6526faa6 100644 --- a/pkg/init/backend/flags.go +++ b/pkg/init/backend/flags.go @@ -8,9 +8,9 @@ import ( "github.com/redhat-developer/odo/pkg/registry" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/devfile/location" diff --git a/pkg/init/backend/flags_test.go b/pkg/init/backend/flags_test.go index 12f10267a78..4f8eef0188f 100644 --- a/pkg/init/backend/flags_test.go +++ b/pkg/init/backend/flags_test.go @@ -8,10 +8,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - parsercontext "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - dffilesystem "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercontext "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + dffilesystem "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/preference" diff --git a/pkg/init/backend/interactive.go b/pkg/init/backend/interactive.go index d7c0f3971a7..97aa530daf4 100644 --- a/pkg/init/backend/interactive.go +++ b/pkg/init/backend/interactive.go @@ -8,9 +8,9 @@ import ( "strconv" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/alizer" diff --git a/pkg/init/backend/interactive_test.go b/pkg/init/backend/interactive_test.go index c7bf87e0623..b9ede94bc15 100644 --- a/pkg/init/backend/interactive_test.go +++ b/pkg/init/backend/interactive_test.go @@ -14,10 +14,10 @@ import ( "github.com/redhat-developer/odo/pkg/testingutil" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - parsercontext "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercontext "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" ) func TestInteractiveBackend_SelectDevfile(t *testing.T) { diff --git a/pkg/init/backend/interface.go b/pkg/init/backend/interface.go index ee756dce619..fb18dc8e83f 100644 --- a/pkg/init/backend/interface.go +++ b/pkg/init/backend/interface.go @@ -7,7 +7,7 @@ import ( "context" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/init/backend/mock.go b/pkg/init/backend/mock.go index 017895f8074..264c5498799 100644 --- a/pkg/init/backend/mock.go +++ b/pkg/init/backend/mock.go @@ -9,7 +9,7 @@ import ( reflect "reflect" v1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - parser "github.com/devfile/library/pkg/devfile/parser" + parser "github.com/devfile/library/v2/pkg/devfile/parser" gomock "github.com/golang/mock/gomock" api "github.com/redhat-developer/odo/pkg/api" filesystem "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/init/init.go b/pkg/init/init.go index d5e4e164fa5..529e02b1fbe 100644 --- a/pkg/init/init.go +++ b/pkg/init/init.go @@ -9,9 +9,9 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/utils/pointer" "github.com/redhat-developer/odo/pkg/alizer" diff --git a/pkg/init/interface.go b/pkg/init/interface.go index 6de301ac9e1..2329301bd62 100644 --- a/pkg/init/interface.go +++ b/pkg/init/interface.go @@ -11,7 +11,7 @@ import ( "context" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/init/mock.go b/pkg/init/mock.go index 7c04fa31d66..d26257c2309 100644 --- a/pkg/init/mock.go +++ b/pkg/init/mock.go @@ -9,7 +9,7 @@ import ( reflect "reflect" v1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - parser "github.com/devfile/library/pkg/devfile/parser" + parser "github.com/devfile/library/v2/pkg/devfile/parser" gomock "github.com/golang/mock/gomock" api "github.com/redhat-developer/odo/pkg/api" filesystem "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/kclient/deployments_test.go b/pkg/kclient/deployments_test.go index 09535fa53fd..b0fac1341d1 100644 --- a/pkg/kclient/deployments_test.go +++ b/pkg/kclient/deployments_test.go @@ -5,11 +5,11 @@ import ( "testing" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/generator" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - "github.com/devfile/library/pkg/testingutil" + "github.com/devfile/library/v2/pkg/devfile/generator" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/testingutil" odoTestingUtil "github.com/redhat-developer/odo/pkg/testingutil" diff --git a/pkg/kclient/oc_server.go b/pkg/kclient/oc_server.go index 5591af9cab8..97fb850e5e2 100644 --- a/pkg/kclient/oc_server.go +++ b/pkg/kclient/oc_server.go @@ -8,7 +8,7 @@ import ( "net" "time" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/apimachinery/pkg/version" "k8s.io/klog" ) diff --git a/pkg/kclient/services_test.go b/pkg/kclient/services_test.go index 901eb49cf10..621f91a42b0 100644 --- a/pkg/kclient/services_test.go +++ b/pkg/kclient/services_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/google/go-cmp/cmp" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/generator" - devfileParser "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - "github.com/devfile/library/pkg/testingutil" + "github.com/devfile/library/v2/pkg/devfile/generator" + devfileParser "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/testingutil" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/kclient/volumes.go b/pkg/kclient/volumes.go index 91498a94ef4..fe4e92d3808 100644 --- a/pkg/kclient/volumes.go +++ b/pkg/kclient/volumes.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/kclient/volumes_test.go b/pkg/kclient/volumes_test.go index b3e189c8cd3..73c1fb53ace 100644 --- a/pkg/kclient/volumes_test.go +++ b/pkg/kclient/volumes_test.go @@ -16,7 +16,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/runtime" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" "github.com/redhat-developer/odo/pkg/util" ) diff --git a/pkg/labels/labels.go b/pkg/labels/labels.go index 8c214a1ccef..874b16ef1d0 100644 --- a/pkg/labels/labels.go +++ b/pkg/labels/labels.go @@ -6,7 +6,7 @@ import ( "strings" "unicode" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" k8slabels "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/klog" diff --git a/pkg/libdevfile/command.go b/pkg/libdevfile/command.go index ca8a048d6b6..9ec2394fc13 100644 --- a/pkg/libdevfile/command.go +++ b/pkg/libdevfile/command.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/redhat-developer/odo/pkg/util" ) diff --git a/pkg/libdevfile/command_apply.go b/pkg/libdevfile/command_apply.go index 70afdf45bde..38778d71d9f 100644 --- a/pkg/libdevfile/command_apply.go +++ b/pkg/libdevfile/command_apply.go @@ -2,8 +2,8 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) // applyCommand is a command implementation for Apply commands diff --git a/pkg/libdevfile/command_apply_test.go b/pkg/libdevfile/command_apply_test.go index 828d7138410..068e6b6d29f 100644 --- a/pkg/libdevfile/command_apply_test.go +++ b/pkg/libdevfile/command_apply_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/redhat-developer/odo/pkg/libdevfile/generator" ) diff --git a/pkg/libdevfile/command_composite.go b/pkg/libdevfile/command_composite.go index f01057a4331..1306f0f1558 100644 --- a/pkg/libdevfile/command_composite.go +++ b/pkg/libdevfile/command_composite.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // compositeCommand is a command implementation that represents non-parallel composite commands diff --git a/pkg/libdevfile/command_composite_parallel.go b/pkg/libdevfile/command_composite_parallel.go index 4544bd0fe4c..0d1119792f2 100644 --- a/pkg/libdevfile/command_composite_parallel.go +++ b/pkg/libdevfile/command_composite_parallel.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/util" ) diff --git a/pkg/libdevfile/command_exec.go b/pkg/libdevfile/command_exec.go index 3ac02a683a8..2f0cd608e22 100644 --- a/pkg/libdevfile/command_exec.go +++ b/pkg/libdevfile/command_exec.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // execCommand is a command implementation for exec commands diff --git a/pkg/libdevfile/command_test.go b/pkg/libdevfile/command_test.go index fedebacccfe..f8f47c35642 100644 --- a/pkg/libdevfile/command_test.go +++ b/pkg/libdevfile/command_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/redhat-developer/odo/pkg/libdevfile/generator" "k8s.io/utils/pointer" ) diff --git a/pkg/libdevfile/component.go b/pkg/libdevfile/component.go index 35238efbd82..dff9ac228b7 100644 --- a/pkg/libdevfile/component.go +++ b/pkg/libdevfile/component.go @@ -2,8 +2,8 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) type component interface { diff --git a/pkg/libdevfile/component_container.go b/pkg/libdevfile/component_container.go index eedb627536b..5309eaf615d 100644 --- a/pkg/libdevfile/component_container.go +++ b/pkg/libdevfile/component_container.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // containerComponent implements the component interface diff --git a/pkg/libdevfile/component_image.go b/pkg/libdevfile/component_image.go index fcc4f410a7f..e2dba3f47d7 100644 --- a/pkg/libdevfile/component_image.go +++ b/pkg/libdevfile/component_image.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // imageComponent implements the component interface diff --git a/pkg/libdevfile/component_kubernetes.go b/pkg/libdevfile/component_kubernetes.go index abd2a49bd76..126c9d49b7f 100644 --- a/pkg/libdevfile/component_kubernetes.go +++ b/pkg/libdevfile/component_kubernetes.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // kubernetesComponent implements the component interface diff --git a/pkg/libdevfile/component_kubernetes_utils.go b/pkg/libdevfile/component_kubernetes_utils.go index 2212f692874..0a965b08017 100644 --- a/pkg/libdevfile/component_kubernetes_utils.go +++ b/pkg/libdevfile/component_kubernetes_utils.go @@ -5,9 +5,9 @@ import ( "io" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/ghodss/yaml" yaml3 "gopkg.in/yaml.v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/libdevfile/component_openshift.go b/pkg/libdevfile/component_openshift.go index 99c978cb683..5020d059ce3 100644 --- a/pkg/libdevfile/component_openshift.go +++ b/pkg/libdevfile/component_openshift.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // openshiftComponent implements the component interface diff --git a/pkg/libdevfile/component_volume.go b/pkg/libdevfile/component_volume.go index 0a84cd857b1..1dce643cdab 100644 --- a/pkg/libdevfile/component_volume.go +++ b/pkg/libdevfile/component_volume.go @@ -2,7 +2,7 @@ package libdevfile import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) // volumeComponent implements the component interface diff --git a/pkg/libdevfile/libdevfile.go b/pkg/libdevfile/libdevfile.go index 2445bff243c..3c61c544072 100644 --- a/pkg/libdevfile/libdevfile.go +++ b/pkg/libdevfile/libdevfile.go @@ -8,10 +8,10 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/v2/pkg/validation/variables" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/util" diff --git a/pkg/libdevfile/libdevfile_test.go b/pkg/libdevfile/libdevfile_test.go index 08c7b3ba964..b674c1c4b60 100644 --- a/pkg/libdevfile/libdevfile_test.go +++ b/pkg/libdevfile/libdevfile_test.go @@ -7,10 +7,10 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" devfilepkg "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" - devfileFileSystem "github.com/devfile/library/pkg/testingutil/filesystem" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + devfileFileSystem "github.com/devfile/library/v2/pkg/testingutil/filesystem" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" "k8s.io/utils/pointer" diff --git a/pkg/libdevfile/uris.go b/pkg/libdevfile/uris.go index 0c4d1366943..8185aa001f1 100644 --- a/pkg/libdevfile/uris.go +++ b/pkg/libdevfile/uris.go @@ -9,8 +9,8 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/v2/pkg/attributes" "github.com/devfile/api/v2/pkg/validation" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) const _importSourceAttributeUriPrefix = "uri: " diff --git a/pkg/libdevfile/uris_test.go b/pkg/libdevfile/uris_test.go index 2cf1eb7630e..3ff7b1ab4c9 100644 --- a/pkg/libdevfile/uris_test.go +++ b/pkg/libdevfile/uris_test.go @@ -6,11 +6,11 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/api/v2/pkg/attributes" "github.com/devfile/api/v2/pkg/validation" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - context "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" + context "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/google/go-cmp/cmp" "github.com/redhat-developer/odo/pkg/libdevfile/generator" diff --git a/pkg/odo/cli/add/binding/binding.go b/pkg/odo/cli/add/binding/binding.go index 2c1f8730588..508e9dbf5a6 100644 --- a/pkg/odo/cli/add/binding/binding.go +++ b/pkg/odo/cli/add/binding/binding.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/runtime/schema" ktemplates "k8s.io/kubectl/pkg/util/templates" diff --git a/pkg/odo/cli/create/namespace/namespace.go b/pkg/odo/cli/create/namespace/namespace.go index 9e84777c501..26975e728e0 100644 --- a/pkg/odo/cli/create/namespace/namespace.go +++ b/pkg/odo/cli/create/namespace/namespace.go @@ -8,7 +8,7 @@ import ( "golang.org/x/text/cases" "golang.org/x/text/language" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/spf13/cobra" ktemplates "k8s.io/kubectl/pkg/util/templates" diff --git a/pkg/odo/cli/delete/component/component_test.go b/pkg/odo/cli/delete/component/component_test.go index 0e64fc133cb..27c11c3156a 100644 --- a/pkg/odo/cli/delete/component/component_test.go +++ b/pkg/odo/cli/delete/component/component_test.go @@ -8,8 +8,8 @@ import ( "path/filepath" "testing" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" _delete "github.com/redhat-developer/odo/pkg/component/delete" diff --git a/pkg/odo/cli/describe/component.go b/pkg/odo/cli/describe/component.go index c1744ed2b3b..054219c03b8 100644 --- a/pkg/odo/cli/describe/component.go +++ b/pkg/odo/cli/describe/component.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/generator" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/spf13/cobra" "k8s.io/klog" ktemplates "k8s.io/kubectl/pkg/util/templates" diff --git a/pkg/odo/cli/init/init.go b/pkg/odo/cli/init/init.go index 3534055618d..29f94165e91 100644 --- a/pkg/odo/cli/init/init.go +++ b/pkg/odo/cli/init/init.go @@ -10,8 +10,8 @@ import ( "k8s.io/klog" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/api" "github.com/redhat-developer/odo/pkg/component" diff --git a/pkg/odo/cli/list/list.go b/pkg/odo/cli/list/list.go index 500f151a745..6e0903f58bf 100644 --- a/pkg/odo/cli/list/list.go +++ b/pkg/odo/cli/list/list.go @@ -24,7 +24,7 @@ import ( "github.com/redhat-developer/odo/pkg/odo/util" odoutil "github.com/redhat-developer/odo/pkg/odo/util" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" ktemplates "k8s.io/kubectl/pkg/util/templates" ) diff --git a/pkg/odo/cli/preference/add/registry.go b/pkg/odo/cli/preference/add/registry.go index 1cd17acb21b..9c8c39f0eea 100644 --- a/pkg/odo/cli/preference/add/registry.go +++ b/pkg/odo/cli/preference/add/registry.go @@ -6,7 +6,7 @@ import ( "fmt" // Third-party packages - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/spf13/cobra" "github.com/zalando/go-keyring" ktemplates "k8s.io/kubectl/pkg/util/templates" diff --git a/pkg/odo/cli/preference/remove/registry.go b/pkg/odo/cli/preference/remove/registry.go index 34a7e9ebad1..6efac5a6202 100644 --- a/pkg/odo/cli/preference/remove/registry.go +++ b/pkg/odo/cli/preference/remove/registry.go @@ -6,7 +6,7 @@ import ( "fmt" // Third-party packages - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/spf13/cobra" "github.com/zalando/go-keyring" ktemplates "k8s.io/kubectl/pkg/util/templates" diff --git a/pkg/odo/cli/set/namespace/namespace.go b/pkg/odo/cli/set/namespace/namespace.go index fd7e5129e2d..f87f53fadbc 100644 --- a/pkg/odo/cli/set/namespace/namespace.go +++ b/pkg/odo/cli/set/namespace/namespace.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/log" "github.com/redhat-developer/odo/pkg/odo/cmdline" diff --git a/pkg/odo/cli/version/notify.go b/pkg/odo/cli/version/notify.go index 2189aaa9f15..3e1f0f5a7fe 100644 --- a/pkg/odo/cli/version/notify.go +++ b/pkg/odo/cli/version/notify.go @@ -6,7 +6,7 @@ import ( "github.com/blang/semver" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" ) const ( diff --git a/pkg/odo/cmdline/cobra.go b/pkg/odo/cmdline/cobra.go index ec282a021f6..3fa24bfdb6b 100644 --- a/pkg/odo/cmdline/cobra.go +++ b/pkg/odo/cmdline/cobra.go @@ -9,7 +9,7 @@ import ( "github.com/redhat-developer/odo/pkg/kclient" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" ) type Cobra struct { diff --git a/pkg/odo/context/odo.go b/pkg/odo/context/odo.go index bd96985a30e..9ac76f150da 100644 --- a/pkg/odo/context/odo.go +++ b/pkg/odo/context/odo.go @@ -3,7 +3,7 @@ package context import ( "context" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) type ( diff --git a/pkg/odo/genericclioptions/devfile.go b/pkg/odo/genericclioptions/devfile.go index 269d147a45a..617318955f9 100644 --- a/pkg/odo/genericclioptions/devfile.go +++ b/pkg/odo/genericclioptions/devfile.go @@ -3,8 +3,8 @@ package genericclioptions import ( "fmt" - "github.com/devfile/library/pkg/devfile/parser" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/component" "github.com/redhat-developer/odo/pkg/devfile" "github.com/redhat-developer/odo/pkg/devfile/location" diff --git a/pkg/odo/genericclioptions/init.go b/pkg/odo/genericclioptions/init.go index 33992a2b88b..858d677c045 100644 --- a/pkg/odo/genericclioptions/init.go +++ b/pkg/odo/genericclioptions/init.go @@ -4,7 +4,7 @@ import ( "context" "path/filepath" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "k8s.io/klog" "github.com/redhat-developer/odo/pkg/devfile/location" diff --git a/pkg/odo/genericclioptions/runnable.go b/pkg/odo/genericclioptions/runnable.go index 740f688ef2a..b29c9443b4e 100644 --- a/pkg/odo/genericclioptions/runnable.go +++ b/pkg/odo/genericclioptions/runnable.go @@ -13,7 +13,7 @@ import ( "gopkg.in/AlecAivazis/survey.v1/terminal" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/machineoutput" diff --git a/pkg/odo/genericclioptions/util.go b/pkg/odo/genericclioptions/util.go index 9f89e6a682b..839477f5a81 100644 --- a/pkg/odo/genericclioptions/util.go +++ b/pkg/odo/genericclioptions/util.go @@ -3,7 +3,7 @@ package genericclioptions import ( pkgUtil "github.com/redhat-developer/odo/pkg/util" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" ) const ( diff --git a/pkg/portForward/interface.go b/pkg/portForward/interface.go index 31435194437..98e6572ffb3 100644 --- a/pkg/portForward/interface.go +++ b/pkg/portForward/interface.go @@ -3,7 +3,7 @@ package portForward import ( "io" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" ) type Client interface { diff --git a/pkg/portForward/portForward.go b/pkg/portForward/portForward.go index b773012429a..52aecf132da 100644 --- a/pkg/portForward/portForward.go +++ b/pkg/portForward/portForward.go @@ -8,8 +8,8 @@ import ( "time" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/klog" diff --git a/pkg/preference/implem.go b/pkg/preference/implem.go index 1084bda7ef1..42647a65a17 100644 --- a/pkg/preference/implem.go +++ b/pkg/preference/implem.go @@ -15,7 +15,7 @@ import ( "github.com/redhat-developer/odo/pkg/odo/cli/ui" "github.com/redhat-developer/odo/pkg/util" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" diff --git a/pkg/registry/interface.go b/pkg/registry/interface.go index fa921e1036c..12e8ca9c2d7 100644 --- a/pkg/registry/interface.go +++ b/pkg/registry/interface.go @@ -5,7 +5,7 @@ import ( "context" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/devfile/registry-support/registry-library/library" "github.com/redhat-developer/odo/pkg/api" ) diff --git a/pkg/registry/mock.go b/pkg/registry/mock.go index 51003422977..763a735a4db 100644 --- a/pkg/registry/mock.go +++ b/pkg/registry/mock.go @@ -9,7 +9,7 @@ import ( reflect "reflect" v1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - util "github.com/devfile/library/pkg/util" + util "github.com/devfile/library/v2/pkg/util" library "github.com/devfile/registry-support/registry-library/library" gomock "github.com/golang/mock/gomock" api "github.com/redhat-developer/odo/pkg/api" diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index aa9b34abcac..5d38ebad9e7 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -11,7 +11,7 @@ import ( "github.com/blang/semver" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" indexSchema "github.com/devfile/registry-support/index/generator/schema" "github.com/devfile/registry-support/registry-library/library" "k8s.io/klog" diff --git a/pkg/registry/starter_project.go b/pkg/registry/starter_project.go index 4cd7905dee0..505fda99008 100644 --- a/pkg/registry/starter_project.go +++ b/pkg/registry/starter_project.go @@ -8,7 +8,7 @@ import ( "path/filepath" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/transport/http" diff --git a/pkg/segment/context/context.go b/pkg/segment/context/context.go index 46615f2faca..260016234b5 100644 --- a/pkg/segment/context/context.go +++ b/pkg/segment/context/context.go @@ -11,7 +11,7 @@ import ( "github.com/redhat-developer/odo/pkg/kclient" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/klog" ) diff --git a/pkg/service/link.go b/pkg/service/link.go index f4931d4678b..bc8c30fae5d 100644 --- a/pkg/service/link.go +++ b/pkg/service/link.go @@ -3,7 +3,7 @@ package service import ( "fmt" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" appsv1 "k8s.io/api/apps/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/service/service.go b/pkg/service/service.go index fbee140444d..f3cd9c8cbb9 100644 --- a/pkg/service/service.go +++ b/pkg/service/service.go @@ -10,10 +10,10 @@ import ( "github.com/redhat-developer/odo/pkg/log" devfile "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + parsercommon "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/klog" diff --git a/pkg/service/service_test.go b/pkg/service/service_test.go index 152e3ec1e03..6c110a2946f 100644 --- a/pkg/service/service_test.go +++ b/pkg/service/service_test.go @@ -10,9 +10,9 @@ import ( "github.com/redhat-developer/odo/pkg/devfile/consts" devfiletesting "github.com/redhat-developer/odo/pkg/devfile/testing" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - devfileFileSystem "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + devfileFileSystem "github.com/devfile/library/v2/pkg/testingutil/filesystem" ) func TestListDevfileLinks(t *testing.T) { diff --git a/pkg/storage/kubernetes.go b/pkg/storage/kubernetes.go index 5198addfab4..d43235097fe 100644 --- a/pkg/storage/kubernetes.go +++ b/pkg/storage/kubernetes.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/pkg/storage/list.go b/pkg/storage/list.go index 7a1e5126597..96647e37619 100644 --- a/pkg/storage/list.go +++ b/pkg/storage/list.go @@ -2,9 +2,9 @@ package storage import ( devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/generator" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) const ( diff --git a/pkg/storage/list_test.go b/pkg/storage/list_test.go index 5c1dcd954ed..e3390f3740e 100644 --- a/pkg/storage/list_test.go +++ b/pkg/storage/list_test.go @@ -4,8 +4,8 @@ import ( "testing" devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/google/go-cmp/cmp" "github.com/redhat-developer/odo/pkg/testingutil" diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 6a783c832ec..049cb4d9fc0 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -5,7 +5,7 @@ import ( v1 "k8s.io/api/apps/v1" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/kclient" "github.com/redhat-developer/odo/pkg/log" ) diff --git a/pkg/sync/copy.go b/pkg/sync/copy.go index 03d886fa78f..e64efef8272 100644 --- a/pkg/sync/copy.go +++ b/pkg/sync/copy.go @@ -14,7 +14,7 @@ import ( "github.com/redhat-developer/odo/pkg/testingutil/filesystem" "github.com/redhat-developer/odo/pkg/util" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" gitignore "github.com/sabhiram/go-gitignore" "k8s.io/klog" diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index b0daac40df2..c326f9b1f19 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "github.com/devfile/library/pkg/devfile/generator" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/generator" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/exec" "github.com/redhat-developer/odo/pkg/platform" diff --git a/pkg/sync/sync_test.go b/pkg/sync/sync_test.go index fb3a88ef35f..31a54c240f7 100644 --- a/pkg/sync/sync_test.go +++ b/pkg/sync/sync_test.go @@ -9,7 +9,7 @@ import ( "path/filepath" "testing" - "github.com/devfile/library/pkg/devfile/generator" + "github.com/devfile/library/v2/pkg/devfile/generator" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" diff --git a/pkg/testingutil/devfile.go b/pkg/testingutil/devfile.go index 8f57f5170f0..edee6eb0c77 100644 --- a/pkg/testingutil/devfile.go +++ b/pkg/testingutil/devfile.go @@ -8,11 +8,11 @@ import ( v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" devfilepkg "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser" - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/devfile" + "github.com/devfile/library/v2/pkg/devfile/parser" + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" ) // GetFakeContainerComponent returns a fake container component for testing diff --git a/pkg/util/file_indexer.go b/pkg/util/file_indexer.go index 3177869efde..6135e2f1f5f 100644 --- a/pkg/util/file_indexer.go +++ b/pkg/util/file_indexer.go @@ -9,7 +9,7 @@ import ( "strings" "time" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/util/httpcache.go b/pkg/util/httpcache.go index a569308a9ec..53c755fef9b 100644 --- a/pkg/util/httpcache.go +++ b/pkg/util/httpcache.go @@ -3,7 +3,7 @@ package util import ( "path/filepath" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "k8s.io/klog" ) diff --git a/pkg/util/httpcache_test.go b/pkg/util/httpcache_test.go index 1f0073f93e0..7a7ff63f3c0 100644 --- a/pkg/util/httpcache_test.go +++ b/pkg/util/httpcache_test.go @@ -5,8 +5,8 @@ import ( "path/filepath" "testing" - "github.com/devfile/library/pkg/testingutil/filesystem" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" + dfutil "github.com/devfile/library/v2/pkg/util" ) func TestCleanDefaultHTTPCacheDir(t *testing.T) { diff --git a/pkg/util/util.go b/pkg/util/util.go index d1a2ca64eaf..f7ebf13c7ff 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -27,8 +27,8 @@ import ( gitignore "github.com/sabhiram/go-gitignore" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - devfilefs "github.com/devfile/library/pkg/testingutil/filesystem" - dfutil "github.com/devfile/library/pkg/util" + devfilefs "github.com/devfile/library/v2/pkg/testingutil/filesystem" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/redhat-developer/odo/pkg/testingutil/filesystem" diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 57d9dbec1d2..af4ef2ebb22 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/google/go-cmp/cmp" diff --git a/pkg/watch/file_watcher.go b/pkg/watch/file_watcher.go index 00cd03d9f2b..00eda19f2cb 100644 --- a/pkg/watch/file_watcher.go +++ b/pkg/watch/file_watcher.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" "github.com/fsnotify/fsnotify" "github.com/redhat-developer/odo/pkg/util" gitignore "github.com/sabhiram/go-gitignore" diff --git a/pkg/watch/watch.go b/pkg/watch/watch.go index 2add2394cef..e6eeed50eb4 100644 --- a/pkg/watch/watch.go +++ b/pkg/watch/watch.go @@ -10,7 +10,7 @@ import ( "reflect" "time" - "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser" "github.com/redhat-developer/odo/pkg/devfile/adapters" "github.com/redhat-developer/odo/pkg/kclient" diff --git a/tests/examples/source/devfiles/nodejs/devfile-container-override-on-podman.yaml b/tests/examples/source/devfiles/nodejs/devfile-container-override-on-podman.yaml new file mode 100644 index 00000000000..bc916c74ce3 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/devfile-container-override-on-podman.yaml @@ -0,0 +1,82 @@ +commands: +- exec: + commandLine: npm install + component: runtime + group: + isDefault: true + kind: build + workingDir: ${PROJECT_SOURCE} + id: install +- exec: + commandLine: npm start + component: runtime + group: + isDefault: true + kind: run + workingDir: ${PROJECT_SOURCE} + id: run +- exec: + commandLine: npm run debug + component: runtime + group: + isDefault: true + kind: debug + workingDir: ${PROJECT_SOURCE} + id: debug +- exec: + commandLine: npm test + component: runtime + group: + isDefault: true + kind: test + workingDir: ${PROJECT_SOURCE} + id: test +components: +- container: + args: + - tail + - -f + - /dev/null + endpoints: + - name: http-node + targetPort: 3000 + - exposure: none + name: debug + targetPort: 5858 + env: + - name: DEBUG_PORT + value: "5858" + image: registry.access.redhat.com/ubi8/nodejs-16:latest + memoryLimit: 1024Mi + mountSources: true + attributes: + container-overrides: + securityContext: + runAsUser: 1001 + runAsGroup: 1001 + name: runtime +- kubernetes: + inlined: | + apiVersion: v1 + kind: ServiceAccount + metadata: + name: new-service-account + name: service-account +metadata: + description: Stack with Node.js 16 + displayName: Node.js Runtime + icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg + language: JavaScript + name: my-node-app + projectType: Node.js + tags: + - Node.js + - Express + - ubi8 + version: 2.1.1 +schemaVersion: 2.1.0 +starterProjects: +- git: + remotes: + origin: https://github.com/odo-devfiles/nodejs-ex.git + name: nodejs-starter \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/devfile-pod-container-overrides.yaml b/tests/examples/source/devfiles/nodejs/devfile-pod-container-overrides.yaml new file mode 100644 index 00000000000..70b820f350a --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/devfile-pod-container-overrides.yaml @@ -0,0 +1,87 @@ +commands: +- exec: + commandLine: npm install + component: runtime + group: + isDefault: true + kind: build + workingDir: ${PROJECT_SOURCE} + id: install +- exec: + commandLine: npm start + component: runtime + group: + isDefault: true + kind: run + workingDir: ${PROJECT_SOURCE} + id: run +- exec: + commandLine: npm run debug + component: runtime + group: + isDefault: true + kind: debug + workingDir: ${PROJECT_SOURCE} + id: debug +- exec: + commandLine: npm test + component: runtime + group: + isDefault: true + kind: test + workingDir: ${PROJECT_SOURCE} + id: test +components: +- container: + args: + - tail + - -f + - /dev/null + endpoints: + - name: http-node + targetPort: 3000 + - exposure: none + name: debug + targetPort: 5858 + env: + - name: DEBUG_PORT + value: "5858" + image: registry.access.redhat.com/ubi8/nodejs-16:latest + memoryLimit: 1024Mi + mountSources: true + attributes: + container-overrides: + resources: + limits: + memory: 512Mi + cpu: "250m" + name: runtime +- kubernetes: + inlined: | + apiVersion: v1 + kind: ServiceAccount + metadata: + name: new-service-account + name: service-account +metadata: + description: Stack with Node.js 16 + displayName: Node.js Runtime + icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg + language: JavaScript + name: my-node-app + projectType: Node.js + tags: + - Node.js + - Express + - ubi8 + version: 2.1.1 +schemaVersion: 2.1.0 +starterProjects: +- git: + remotes: + origin: https://github.com/odo-devfiles/nodejs-ex.git + name: nodejs-starter +attributes: + pod-overrides: + spec: + serviceAccountName: new-service-account \ No newline at end of file diff --git a/tests/helper/helper_filesystem.go b/tests/helper/helper_filesystem.go index 50e2bf74ff5..09f1fc72e98 100644 --- a/tests/helper/helper_filesystem.go +++ b/tests/helper/helper_filesystem.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/devfile/library/pkg/devfile/parser" - dfutil "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + dfutil "github.com/devfile/library/v2/pkg/util" "k8s.io/utils/pointer" . "github.com/onsi/ginkgo/v2" diff --git a/tests/helper/helper_generic.go b/tests/helper/helper_generic.go index 95ff5352aad..37f26becd73 100644 --- a/tests/helper/helper_generic.go +++ b/tests/helper/helper_generic.go @@ -21,7 +21,7 @@ import ( "github.com/redhat-developer/odo/pkg/preference" "github.com/redhat-developer/odo/pkg/segment" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/tests/helper/kubernetes_utils.go b/tests/helper/kubernetes_utils.go index 9f5c45e84ea..642b4edbff1 100644 --- a/tests/helper/kubernetes_utils.go +++ b/tests/helper/kubernetes_utils.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - dfutil "github.com/devfile/library/pkg/util" + dfutil "github.com/devfile/library/v2/pkg/util" ) // copyKubeConfigFile copies default kubeconfig file into current temporary context config file diff --git a/tests/helper/odo_utils.go b/tests/helper/odo_utils.go index 3e2ff61173f..765cc063134 100644 --- a/tests/helper/odo_utils.go +++ b/tests/helper/odo_utils.go @@ -7,7 +7,7 @@ import ( "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" devfilepkg "github.com/devfile/api/v2/pkg/devfile" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/redhat-developer/odo/pkg/devfile" diff --git a/tests/integration/cmd_delete_test.go b/tests/integration/cmd_delete_test.go index c572aab4cd0..a69ea00f856 100644 --- a/tests/integration/cmd_delete_test.go +++ b/tests/integration/cmd_delete_test.go @@ -141,12 +141,11 @@ var _ = Describe("odo delete command tests", func() { deploymentName = "my-component" serviceName = "my-cs" helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) - helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", - helper.GetExamplePath("source", "devfiles", "nodejs", ctx.devfileName)).ShouldPass() - // Note: component will be automatically bootstrapped when `odo dev` or `odo deploy` is run if ctx.setupFunc != nil { ctx.setupFunc() } + helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", + helper.GetExamplePath("source", "devfiles", "nodejs", ctx.devfileName)).ShouldPass() }) When("the components are not deployed", func() { It("should output that there are no resources to be deleted", func() { diff --git a/tests/integration/cmd_dev_test.go b/tests/integration/cmd_dev_test.go index 9f664cf6536..86eb53e8d99 100644 --- a/tests/integration/cmd_dev_test.go +++ b/tests/integration/cmd_dev_test.go @@ -17,6 +17,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + "k8s.io/utils/pointer" "github.com/redhat-developer/odo/pkg/labels" "github.com/redhat-developer/odo/pkg/remotecmd" @@ -3214,4 +3216,47 @@ CMD ["npm", "start"] })) } } + + for _, ctx := range []struct { + devfile string + checkFunc func(podOut *corev1.Pod) + podman bool + }{ + { + devfile: "devfile-pod-container-overrides.yaml", + checkFunc: func(podOut *corev1.Pod) { + Expect(podOut.Spec.Containers[0].Resources.Limits.Memory().String()).To(ContainSubstring("512Mi")) + Expect(podOut.Spec.Containers[0].Resources.Limits.Cpu().String()).To(ContainSubstring("250m")) + Expect(podOut.Spec.ServiceAccountName).To(ContainSubstring("new-service-account")) + }, + podman: false, + }, + { + devfile: "devfile-container-override-on-podman.yaml", + checkFunc: func(podOut *corev1.Pod) { + Expect(podOut.Spec.Containers[0].SecurityContext.RunAsUser).To(Equal(pointer.Int64(1001))) + Expect(podOut.Spec.Containers[0].SecurityContext.RunAsGroup).To(Equal(pointer.Int64(1001))) + }, + podman: true, + }, + } { + ctx := ctx + Context("Devfile contains pod-overrides and container-overrides attributes", helper.LabelPodmanIf(ctx.podman, func() { + BeforeEach(func() { + helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", ctx.devfile), filepath.Join(commonVar.Context, "devfile.yaml"), helper.DevfileMetadataNameSetter(cmpName)) + }) + It("should override the content in the pod it creates for the component on the cluster", func() { + err := helper.RunDevMode(helper.DevSessionOpts{ + RunOnPodman: ctx.podman, + }, func(session *gexec.Session, outContents, _ []byte, _ map[string]string) { + component := helper.NewComponent(cmpName, "app", labels.ComponentDevMode, commonVar.Project, commonVar.CliRunner) + podOut := component.GetPodDef() + ctx.checkFunc(podOut) + }) + Expect(err).To(BeNil()) + }) + })) + + } }) diff --git a/tests/integration/cmd_devfile_deploy_test.go b/tests/integration/cmd_devfile_deploy_test.go index 3ecd08bbe23..4dd1657439e 100644 --- a/tests/integration/cmd_devfile_deploy_test.go +++ b/tests/integration/cmd_devfile_deploy_test.go @@ -73,13 +73,13 @@ var _ = Describe("odo devfile deploy command tests", func() { deploymentName := "my-component" BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + if ctx.setupFunc != nil { + ctx.setupFunc() + } helper.CopyExampleDevFile( filepath.Join("source", "devfiles", "nodejs", ctx.devfileName), path.Join(commonVar.Context, "devfile.yaml"), helper.DevfileMetadataNameSetter(cmpName)) - if ctx.setupFunc != nil { - ctx.setupFunc() - } }) When("running odo deploy", func() { diff --git a/tests/integration/interactive_init_test.go b/tests/integration/interactive_init_test.go index 353102bff03..3f79af61e2c 100644 --- a/tests/integration/interactive_init_test.go +++ b/tests/integration/interactive_init_test.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "k8s.io/utils/pointer" "github.com/redhat-developer/odo/pkg/odo/cli/messages" diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/fakecontext.go b/vendor/github.com/devfile/library/pkg/devfile/parser/context/fakecontext.go deleted file mode 100644 index 2db3c1bd83d..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/fakecontext.go +++ /dev/null @@ -1,10 +0,0 @@ -package parser - -import "github.com/devfile/library/pkg/testingutil/filesystem" - -func FakeContext(fs filesystem.Filesystem, absPath string) DevfileCtx { - return DevfileCtx{ - fs: fs, - absPath: absPath, - } -} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/fs.go b/vendor/github.com/devfile/library/pkg/devfile/parser/context/fs.go deleted file mode 100644 index d3992483ae1..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/fs.go +++ /dev/null @@ -1,8 +0,0 @@ -package parser - -import "github.com/devfile/library/pkg/testingutil/filesystem" - -// GetFs returns the filesystem object -func (d *DevfileCtx) GetFs() filesystem.Filesystem { - return d.fs -} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/parent.go b/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/parent.go deleted file mode 100644 index 75df021a857..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/parent.go +++ /dev/null @@ -1,15 +0,0 @@ -package v2 - -import ( - v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" -) - -// GetParent returns the Parent object parsed from devfile -func (d *DevfileV2) GetParent() *v1.Parent { - return d.Parent -} - -// SetParent sets the parent for the devfile -func (d *DevfileV2) SetParent(parent *v1.Parent) { - d.Parent = parent -} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/types.go b/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/types.go deleted file mode 100644 index 7a8505baca2..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/types.go +++ /dev/null @@ -1,10 +0,0 @@ -package v2 - -import ( - v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" -) - -// DevfileV2 is the devfile go struct from devfile/api -type DevfileV2 struct { - v1.Devfile -} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/devfileobj.go b/vendor/github.com/devfile/library/pkg/devfile/parser/devfileobj.go deleted file mode 100644 index 65c669c8c1e..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/devfileobj.go +++ /dev/null @@ -1,21 +0,0 @@ -package parser - -import ( - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" -) - -// Default filenames for create devfile -const ( - OutputDevfileYamlPath = "devfile.yaml" -) - -// DevfileObj is the runtime devfile object -type DevfileObj struct { - - // Ctx has devfile context info - Ctx devfileCtx.DevfileCtx - - // Data has the devfile data - Data data.DevfileData -} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/writer.go b/vendor/github.com/devfile/library/pkg/devfile/parser/writer.go deleted file mode 100644 index 78abd8f954e..00000000000 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/writer.go +++ /dev/null @@ -1,32 +0,0 @@ -package parser - -import ( - "sigs.k8s.io/yaml" - - "github.com/devfile/library/pkg/testingutil/filesystem" - "github.com/pkg/errors" - "k8s.io/klog" -) - -// WriteYamlDevfile creates a devfile.yaml file -func (d *DevfileObj) WriteYamlDevfile() error { - - // Encode data into YAML format - yamlData, err := yaml.Marshal(d.Data) - if err != nil { - return errors.Wrapf(err, "failed to marshal devfile object into yaml") - } - // Write to devfile.yaml - fs := d.Ctx.GetFs() - if fs == nil { - fs = filesystem.DefaultFs{} - } - err = fs.WriteFile(d.Ctx.GetAbsPath(), yamlData, 0644) - if err != nil { - return errors.Wrapf(err, "failed to create devfile yaml file") - } - - // Successful - klog.V(2).Infof("devfile yaml created at: '%s'", OutputDevfileYamlPath) - return nil -} diff --git a/vendor/github.com/devfile/library/pkg/testingutil/containers.go b/vendor/github.com/devfile/library/pkg/testingutil/containers.go deleted file mode 100644 index 3c9433bb940..00000000000 --- a/vendor/github.com/devfile/library/pkg/testingutil/containers.go +++ /dev/null @@ -1,10 +0,0 @@ -package testingutil - -import corev1 "k8s.io/api/core/v1" - -// CreateFakeContainer creates a container with the given containerName -func CreateFakeContainer(containerName string) corev1.Container { - return corev1.Container{ - Name: containerName, - } -} diff --git a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/singleton.go b/vendor/github.com/devfile/library/pkg/testingutil/filesystem/singleton.go deleted file mode 100644 index a8dcea8f21d..00000000000 --- a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/singleton.go +++ /dev/null @@ -1,10 +0,0 @@ -package filesystem - -var singleFs Filesystem - -func Get() Filesystem { - if singleFs == nil { - singleFs = &DefaultFs{} - } - return singleFs -} diff --git a/vendor/github.com/devfile/library/LICENSE b/vendor/github.com/devfile/library/v2/LICENSE similarity index 100% rename from vendor/github.com/devfile/library/LICENSE rename to vendor/github.com/devfile/library/v2/LICENSE diff --git a/vendor/github.com/devfile/library/pkg/devfile/generator/generators.go b/vendor/github.com/devfile/library/v2/pkg/devfile/generator/generators.go similarity index 90% rename from vendor/github.com/devfile/library/pkg/devfile/generator/generators.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/generator/generators.go index 7ceafc19320..42d6cd8c70e 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/generator/generators.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/generator/generators.go @@ -1,11 +1,30 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package generator import ( "fmt" + + "github.com/devfile/api/v2/pkg/attributes" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" - "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/util" buildv1 "github.com/openshift/api/build/v1" imagev1 "github.com/openshift/api/image/v1" routev1 "github.com/openshift/api/route/v1" @@ -169,9 +188,23 @@ func GetDeployment(devfileObj parser.DevfileObj, deployParams DeploymentParams) Containers: deployParams.Containers, Volumes: deployParams.Volumes, } - + var globalAttributes attributes.Attributes + // attributes is not supported in versions less than 2.1.0, so we skip it + if devfileObj.Data.GetSchemaVersion() > string(data.APISchemaVersion200) { + // the only time GetAttributes will return an error is if DevfileSchemaVersion is 2.0.0, a case we've already covered; + // so we'll skip checking for error here + globalAttributes, _ = devfileObj.Data.GetAttributes() + } + components, err := devfileObj.Data.GetDevfileContainerComponents(common.DevfileOptions{}) + if err != nil { + return nil, err + } + podTemplateSpec, err := getPodTemplateSpec(globalAttributes, components, podTemplateSpecParams) + if err != nil { + return nil, err + } deploySpecParams := deploymentSpecParams{ - PodTemplateSpec: *getPodTemplateSpec(podTemplateSpecParams), + PodTemplateSpec: *podTemplateSpec, PodSelectorLabels: deployParams.PodSelectorLabels, Replicas: deployParams.Replicas, } diff --git a/vendor/github.com/devfile/library/pkg/devfile/generator/utils.go b/vendor/github.com/devfile/library/v2/pkg/devfile/generator/utils.go similarity index 68% rename from vendor/github.com/devfile/library/pkg/devfile/generator/utils.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/generator/utils.go index 35af324302d..1ea3b499765 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/generator/utils.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/generator/utils.go @@ -1,24 +1,49 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package generator import ( + "encoding/json" "fmt" - "github.com/hashicorp/go-multierror" "path/filepath" "reflect" "strings" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/api/v2/pkg/attributes" + + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/hashicorp/go-multierror" buildv1 "github.com/openshift/api/build/v1" routev1 "github.com/openshift/api/route/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" extensionsv1 "k8s.io/api/extensions/v1beta1" networkingv1 "k8s.io/api/networking/v1" + apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/apimachinery/pkg/util/strategicpatch" +) + +const ( + ContainerOverridesAttribute = "container-overrides" + PodOverridesAttribute = "pod-overrides" ) // convertEnvs converts environment variables from the devfile structure to kubernetes structure @@ -216,7 +241,7 @@ type podTemplateSpecParams struct { } // getPodTemplateSpec gets a pod template spec that can be used to create a deployment spec -func getPodTemplateSpec(podTemplateSpecParams podTemplateSpecParams) *corev1.PodTemplateSpec { +func getPodTemplateSpec(globalAttributes attributes.Attributes, components []v1.Component, podTemplateSpecParams podTemplateSpecParams) (*corev1.PodTemplateSpec, error) { podTemplateSpec := &corev1.PodTemplateSpec{ ObjectMeta: podTemplateSpecParams.ObjectMeta, Spec: corev1.PodSpec{ @@ -225,8 +250,115 @@ func getPodTemplateSpec(podTemplateSpecParams podTemplateSpecParams) *corev1.Pod Volumes: podTemplateSpecParams.Volumes, }, } + if len(globalAttributes) != 0 && needsPodOverrides(globalAttributes, components) { + patchedPodTemplateSpec, err := applyPodOverrides(globalAttributes, components, podTemplateSpec) + if err != nil { + return nil, err + } + patchedPodTemplateSpec.ObjectMeta = podTemplateSpecParams.ObjectMeta + podTemplateSpec = patchedPodTemplateSpec + } + + return podTemplateSpec, nil +} + +// needsPodOverrides returns true if PodOverridesAttribute is present at Devfile or Container level attributes +func needsPodOverrides(globalAttributes attributes.Attributes, components []v1.Component) bool { + if globalAttributes.Exists(PodOverridesAttribute) { + return true + } + for _, component := range components { + if component.Attributes.Exists(PodOverridesAttribute) { + return true + } + } + return false +} + +// applyPodOverrides returns a list of all the PodOverridesAttribute set at Devfile and Container level attributes +func applyPodOverrides(globalAttributes attributes.Attributes, components []v1.Component, podTemplateSpec *corev1.PodTemplateSpec) (*corev1.PodTemplateSpec, error) { + overrides, err := getPodOverrides(globalAttributes, components) + if err != nil { + return nil, err + } + // Workaround: the definition for corev1.PodSpec does not make containers optional, so even a nil list + // will be interpreted as "delete all containers" as the serialized patch will include "containers": null. + // To avoid this, save the original containers and reset them at the end. + originalContainers := podTemplateSpec.Spec.Containers + // Save fields we do not allow to be configured in pod-overrides + originalInitContainers := podTemplateSpec.Spec.InitContainers + originalVolumes := podTemplateSpec.Spec.Volumes + + patchedTemplateBytes, err := json.Marshal(podTemplateSpec) + if err != nil { + return nil, fmt.Errorf("failed to marshal deployment to yaml: %w", err) + } + for _, override := range overrides { + patchedTemplateBytes, err = strategicpatch.StrategicMergePatch(patchedTemplateBytes, override.Raw, &corev1.PodTemplateSpec{}) + if err != nil { + return nil, fmt.Errorf("error applying pod overrides: %w", err) + } + } + patchedPodTemplateSpec := corev1.PodTemplateSpec{} + if err := json.Unmarshal(patchedTemplateBytes, &patchedPodTemplateSpec); err != nil { + return nil, fmt.Errorf("error applying pod overrides: %w", err) + } + patchedPodTemplateSpec.Spec.Containers = originalContainers + patchedPodTemplateSpec.Spec.InitContainers = originalInitContainers + patchedPodTemplateSpec.Spec.Volumes = originalVolumes + return &patchedPodTemplateSpec, nil +} + +// getPodOverrides returns PodTemplateSpecOverrides for every instance of the pod overrides attribute +// present in the DevWorkspace. The order of elements is +// 1. Pod overrides defined on Container components, in the order they appear in the DevWorkspace +// 2. Pod overrides defined in the global attributes field (.spec.template.attributes) +func getPodOverrides(globalAttributes attributes.Attributes, components []v1.Component) ([]apiext.JSON, error) { + var allOverrides []apiext.JSON + + for _, component := range components { + if component.Attributes.Exists(PodOverridesAttribute) { + override := corev1.PodTemplateSpec{} + // Check format of pod-overrides to detect errors early + if err := component.Attributes.GetInto(PodOverridesAttribute, &override); err != nil { + return nil, fmt.Errorf("failed to parse %s attribute on component %s: %w", PodOverridesAttribute, component.Name, err) + } + // Do not allow overriding containers or volumes + if override.Spec.Containers != nil { + return nil, fmt.Errorf("cannot use %s to override pod containers (component %s)", PodOverridesAttribute, component.Name) + } + if override.Spec.InitContainers != nil { + return nil, fmt.Errorf("cannot use %s to override pod initContainers (component %s)", PodOverridesAttribute, component.Name) + } + if override.Spec.Volumes != nil { + return nil, fmt.Errorf("cannot use %s to override pod volumes (component %s)", PodOverridesAttribute, component.Name) + } + patchData := component.Attributes[PodOverridesAttribute] + allOverrides = append(allOverrides, patchData) + } + } + + if globalAttributes.Exists(PodOverridesAttribute) { + override := corev1.PodTemplateSpec{} + err := globalAttributes.GetInto(PodOverridesAttribute, &override) + if err != nil { + return nil, fmt.Errorf("failed to parse %s attribute for pod: %w", PodOverridesAttribute, err) + } + // Do not allow overriding containers or volumes + if override.Spec.Containers != nil { + return nil, fmt.Errorf("cannot use %s to override pod containers", PodOverridesAttribute) + } + if override.Spec.InitContainers != nil { + return nil, fmt.Errorf("cannot use %s to override pod initContainers", PodOverridesAttribute) + } + if override.Spec.Volumes != nil { + return nil, fmt.Errorf("cannot use %s to override pod volumes", PodOverridesAttribute) + } + patchData := globalAttributes[PodOverridesAttribute] + allOverrides = append(allOverrides, patchData) + } - return podTemplateSpec + return allOverrides, nil } // deploymentSpecParams is a struct that contains the required data to create a deployment spec object @@ -407,7 +539,7 @@ func getNetworkingV1IngressSpec(ingressSpecParams IngressSpecParams) *networking }, }, }, - //Field is required to be set based on attempt to create the ingress + // Field is required to be set based on attempt to create the ingress PathType: &pathTypeImplementationSpecific, }, }, @@ -604,11 +736,87 @@ func getAllContainers(devfileObj parser.DevfileObj, options common.DevfileOption return nil, err } } - containers = append(containers, *container) + // Check if there is an override attribute + if comp.Attributes.Exists(ContainerOverridesAttribute) { + patched, err := containerOverridesHandler(comp, container) + if err != nil { + return nil, err + } + containers = append(containers, *patched) + } else { + containers = append(containers, *container) + } } return containers, nil } +// containerOverridesHandler overrides the attributes of a container component as defined inside ContainerOverridesAttribute by a strategic merge patch. +func containerOverridesHandler(comp v1.Component, container *corev1.Container) (*corev1.Container, error) { + // Apply the override + override := &corev1.Container{} + if err := comp.Attributes.GetInto(ContainerOverridesAttribute, override); err != nil { + return nil, fmt.Errorf("failed to parse %s attribute on component %s: %w", ContainerOverridesAttribute, comp.Name, err) + } + + restrictContainerOverride := func(override *corev1.Container) error { + var invalidFields []string + if override.Name != "" { + invalidFields = append(invalidFields, "name") + } + if override.Image != "" { + invalidFields = append(invalidFields, "image") + } + if override.Command != nil { + invalidFields = append(invalidFields, "command") + + } + if override.Args != nil { + invalidFields = append(invalidFields, "args") + + } + if override.Ports != nil { + invalidFields = append(invalidFields, "ports") + + } + if override.VolumeMounts != nil { + invalidFields = append(invalidFields, "volumeMounts") + + } + if override.Env != nil { + invalidFields = append(invalidFields, "env") + } + if len(invalidFields) != 0 { + return fmt.Errorf("cannot use %s to override container %s", ContainerOverridesAttribute, strings.Join(invalidFields, ", ")) + } + return nil + } + // check if the override key is allowed + if err := restrictContainerOverride(override); err != nil { + return nil, fmt.Errorf("failed to parse %s attribute on component %s: %w", ContainerOverridesAttribute, comp.Name, err) + } + + // get the container-overrides data + overrideJSON := comp.Attributes[ContainerOverridesAttribute] + + originalBytes, err := json.Marshal(container) + if err != nil { + return nil, fmt.Errorf("failed to marshal container to yaml: %w", err) + } + patchedBytes, err := strategicpatch.StrategicMergePatch(originalBytes, overrideJSON.Raw, &corev1.Container{}) + if err != nil { + return nil, fmt.Errorf("failed to apply container overrides: %w", err) + } + patched := &corev1.Container{} + if err := json.Unmarshal(patchedBytes, patched); err != nil { + return nil, fmt.Errorf("error applying container overrides: %w", err) + } + // Applying the patch will overwrite the container's name and image as corev1.Container.Name + // does not have the omitempty json tag. + patched.Name = container.Name + patched.Image = container.Image + return patched, nil +} + // getContainerAnnotations iterates through container components and returns all annotations func getContainerAnnotations(devfileObj parser.DevfileObj, options common.DevfileOptions) (v1.Annotation, error) { options.ComponentOptions = common.ComponentOptions{ diff --git a/vendor/github.com/devfile/library/pkg/devfile/parse.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parse.go similarity index 81% rename from vendor/github.com/devfile/library/pkg/devfile/parse.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parse.go index 64c2890af11..1a2b0aa3190 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parse.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parse.go @@ -1,9 +1,24 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + 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" + "github.com/devfile/library/v2/pkg/devfile/parser" + "github.com/devfile/library/v2/pkg/devfile/validate" ) // ParseFromURLAndValidate func parses the devfile data from the url diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/configurables.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/configurables.go similarity index 83% rename from vendor/github.com/devfile/library/pkg/devfile/parser/configurables.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/configurables.go index e05b46463b0..5d53c482923 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/configurables.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/configurables.go @@ -1,8 +1,23 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) const ( @@ -90,7 +105,7 @@ func (d DevfileObj) SetMemory(memory string) error { for _, component := range components { if component.Container != nil { component.Container.MemoryLimit = memory - d.Data.UpdateComponent(component) + _ = d.Data.UpdateComponent(component) } } return d.WriteYamlDevfile() diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/apiVersion.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/apiVersion.go similarity index 70% rename from vendor/github.com/devfile/library/pkg/devfile/parser/context/apiVersion.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/apiVersion.go index e07d706dc9f..5cea0ce48d4 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/apiVersion.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/apiVersion.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( @@ -5,7 +20,7 @@ import ( "fmt" "strings" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/pkg/errors" "k8s.io/klog" ) diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/content.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/content.go similarity index 71% rename from vendor/github.com/devfile/library/pkg/devfile/parser/context/content.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/content.go index a4a4ddf163c..3bab1fa08e1 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/content.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/content.go @@ -1,10 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( "bytes" "unicode" - "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/util" "github.com/pkg/errors" "k8s.io/klog" "sigs.k8s.io/yaml" @@ -52,7 +67,9 @@ func (d *DevfileCtx) SetDevfileContent() error { var err error var data []byte if d.url != "" { - data, err = util.DownloadFileInMemory(d.url) + // set the client identifier for telemetry + params := util.HTTPRequestParams{URL: d.url, TelemetryClientName: util.TelemetryClientName} + data, err = util.DownloadInMemory(params) if err != nil { return errors.Wrap(err, "error getting devfile info from url") } diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/context.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/context.go similarity index 74% rename from vendor/github.com/devfile/library/pkg/devfile/parser/context/context.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/context.go index 64e3b5d4cc6..bd2e6d6d588 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/context.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/context.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( @@ -7,8 +22,8 @@ import ( "path/filepath" "strings" - "github.com/devfile/library/pkg/testingutil/filesystem" - "github.com/devfile/library/pkg/util" + "github.com/devfile/library/v2/pkg/testingutil/filesystem" + "github.com/devfile/library/v2/pkg/util" "k8s.io/klog" ) @@ -35,6 +50,9 @@ type DevfileCtx struct { // filesystem for devfile fs filesystem.Filesystem + + // devfile kubernetes components has been coverted from uri to inlined in memory + convertUriToInlined bool } // NewDevfileCtx returns a new DevfileCtx type object @@ -143,3 +161,13 @@ func (d *DevfileCtx) SetAbsPath() (err error) { return nil } + +// GetConvertUriToInlined func returns if the devfile kubernetes comp has been converted from uri to inlined +func (d *DevfileCtx) GetConvertUriToInlined() bool { + return d.convertUriToInlined +} + +// SetConvertUriToInlined sets if the devfile kubernetes comp has been converted from uri to inlined +func (d *DevfileCtx) SetConvertUriToInlined(value bool) { + d.convertUriToInlined = value +} diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fakecontext.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fakecontext.go new file mode 100644 index 00000000000..8c286a47c0d --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fakecontext.go @@ -0,0 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import "github.com/devfile/library/v2/pkg/testingutil/filesystem" + +func FakeContext(fs filesystem.Filesystem, absPath string) DevfileCtx { + return DevfileCtx{ + fs: fs, + absPath: absPath, + } +} diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fs.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fs.go new file mode 100644 index 00000000000..56f1fde3866 --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/fs.go @@ -0,0 +1,23 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import "github.com/devfile/library/v2/pkg/testingutil/filesystem" + +// GetFs returns the filesystem object +func (d *DevfileCtx) GetFs() filesystem.Filesystem { + return d.fs +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/context/schema.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/schema.go similarity index 64% rename from vendor/github.com/devfile/library/pkg/devfile/parser/context/schema.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/schema.go index 13326e96bc4..ca8f37cf6ce 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/context/schema.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/context/schema.go @@ -1,9 +1,24 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( "fmt" - "github.com/devfile/library/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data" "github.com/pkg/errors" "github.com/xeipuuv/gojsonschema" "k8s.io/klog" diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/helper.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/helper.go similarity index 72% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/helper.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/helper.go index 190acbc21d5..7ce98456396 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/helper.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package data import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/interface.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/interface.go similarity index 81% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/interface.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/interface.go index 743077e8b43..a24a06ed93c 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/interface.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/interface.go @@ -1,10 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + 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" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) // Generate mock interfaces for DevfileData by executing the following cmd in pkg/devfile/parser/data diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/mock_interface.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/mock_interface.go similarity index 99% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/mock_interface.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/mock_interface.go index fb21d6a13f7..43836cbaa6a 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/mock_interface.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/mock_interface.go @@ -10,7 +10,7 @@ import ( v1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" attributes "github.com/devfile/api/v2/pkg/attributes" devfile "github.com/devfile/api/v2/pkg/devfile" - common "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + common "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" gomock "github.com/golang/mock/gomock" ) diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go similarity index 99% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go index b4c2cd50fe5..431d5fc027f 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.0.0/devfileJsonSchema200.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package version200 // https://raw.githubusercontent.com/devfile/api/2.0.x/schemas/latest/devfile.json diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go similarity index 99% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go index 7145fd0bed1..c92b7a75584 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.1.0/devfileJsonSchema210.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package version210 // https://raw.githubusercontent.com/devfile/api/2.1.x/schemas/latest/devfile.json diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go similarity index 98% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go index d729f7cfd98..f485c74477f 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package version220 // https://raw.githubusercontent.com/devfile/api/main/schemas/latest/devfile.json @@ -372,7 +387,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, @@ -491,7 +506,7 @@ const JsonSchema220 = `{ } }, "buildContext": { - "description": "Path of source directory to establish build context. Defaults to ${PROJECT_ROOT} in the container", + "description": "Path of source directory to establish build context. Defaults to ${PROJECT_SOURCE} in the container", "type": "string" }, "devfileRegistry": { @@ -644,7 +659,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, @@ -746,7 +761,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, @@ -1258,7 +1273,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, @@ -1377,7 +1392,7 @@ const JsonSchema220 = `{ } }, "buildContext": { - "description": "Path of source directory to establish build context. Defaults to ${PROJECT_ROOT} in the container", + "description": "Path of source directory to establish build context. Defaults to ${PROJECT_SOURCE} in the container", "type": "string" }, "devfileRegistry": { @@ -1521,7 +1536,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, @@ -1620,7 +1635,7 @@ const JsonSchema220 = `{ "type": "boolean" }, "targetPort": { - "description": "The port number should be unique.", + "description": "Port number to be used within the container component. The same port cannot be used by two different container components.", "type": "integer" } }, diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/attributes.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/attributes.go similarity index 73% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/attributes.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/attributes.go index d241a1b5b05..6d7ba88a626 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/attributes.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/attributes.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/commands.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/commands.go similarity index 81% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/commands.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/commands.go index 8b45991fd2c..02e4b57a5e1 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/commands.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/commands.go @@ -1,9 +1,24 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( "fmt" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "reflect" "strings" ) diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/command_helper.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/command_helper.go similarity index 80% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/command_helper.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/command_helper.go index b3bf8a0addd..f4a5cabf311 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/command_helper.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/command_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package common import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/component_helper.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/component_helper.go similarity index 64% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/component_helper.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/component_helper.go index 1a5ba3323ca..fdb34371602 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/component_helper.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/component_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package common import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/errors.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/errors.go similarity index 52% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/errors.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/errors.go index ed5050ee011..fd192d3d5d9 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/errors.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/errors.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package common import "fmt" diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/options.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/options.go similarity index 79% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/options.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/options.go index 64c93219b22..4817788e303 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/options.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/options.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package common import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/project_helper.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/project_helper.go similarity index 74% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/project_helper.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/project_helper.go index b8df56e7d4d..13291a878f4 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/common/project_helper.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common/project_helper.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package common import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/components.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/components.go similarity index 85% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/components.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/components.go index 6b88034f8fe..1ea32835ee2 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/components.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/components.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( @@ -6,7 +21,7 @@ import ( "strings" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) // GetComponents returns the slice of Component objects parsed from the Devfile diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/containers.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/containers.go similarity index 91% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/containers.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/containers.go index 7671f180bcc..c62ea195cfd 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/containers.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/containers.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( @@ -6,7 +21,7 @@ import ( "strings" v1alpha2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" corev1 "k8s.io/api/core/v1" ) @@ -21,7 +36,7 @@ func (d *DevfileV2) AddEnvVars(containerEnvMap map[string][]v1alpha2.EnvVar) err for _, component := range components { if component.Container != nil { component.Container.Env = merge(component.Container.Env, containerEnvMap[component.Name]) - d.UpdateComponent(component) + _ = d.UpdateComponent(component) } } return nil @@ -40,7 +55,7 @@ func (d *DevfileV2) RemoveEnvVars(containerEnvMap map[string][]string) error { if err != nil { return err } - d.UpdateComponent(component) + _ = d.UpdateComponent(component) } } return nil @@ -61,7 +76,7 @@ func (d *DevfileV2) SetPorts(containerPortsMap map[string][]string) error { } if component.Container != nil { component.Container.Endpoints = addEndpoints(component.Container.Endpoints, endpoints) - d.UpdateComponent(component) + _ = d.UpdateComponent(component) } } @@ -82,7 +97,7 @@ func (d *DevfileV2) RemovePorts(containerPortsMap map[string][]string) error { if err != nil { return err } - d.UpdateComponent(component) + _ = d.UpdateComponent(component) } } diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/events.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/events.go similarity index 76% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/events.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/events.go index 15c88b00752..d7caf1a80b8 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/events.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/events.go @@ -1,9 +1,24 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( "fmt" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "strings" ) diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/header.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/header.go similarity index 51% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/header.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/header.go index b005fd447bd..5bc4854b33b 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/header.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/header.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/parent.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/parent.go new file mode 100644 index 00000000000..932f932310b --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/parent.go @@ -0,0 +1,30 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v2 + +import ( + v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" +) + +// GetParent returns the Parent object parsed from devfile +func (d *DevfileV2) GetParent() *v1.Parent { + return d.Parent +} + +// SetParent sets the parent for the devfile +func (d *DevfileV2) SetParent(parent *v1.Parent) { + d.Parent = parent +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/projects.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/projects.go similarity index 89% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/projects.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/projects.go index 714ed5be791..d5ae17e4387 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/projects.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/projects.go @@ -1,9 +1,24 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( "fmt" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "reflect" "strings" ) diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/types.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/types.go new file mode 100644 index 00000000000..c35b0d7ed14 --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/types.go @@ -0,0 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v2 + +import ( + v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" +) + +// DevfileV2 is the devfile go struct from devfile/api +type DevfileV2 struct { + v1.Devfile +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/volumes.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/volumes.go similarity index 83% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/volumes.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/volumes.go index 37a29fc70d2..8f3a5d15ef5 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/volumes.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/volumes.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( @@ -5,7 +20,7 @@ import ( "strings" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" ) // AddVolumeMounts adds the volume mounts to the specified container component diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/workspace.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/workspace.go similarity index 57% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/workspace.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/workspace.go index 6cf94d56b6f..a1793e1a30d 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/v2/workspace.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/v2/workspace.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v2 import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/data/versions.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/versions.go similarity index 68% rename from vendor/github.com/devfile/library/pkg/devfile/parser/data/versions.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/versions.go index e85a026e27e..0a92dc32f6f 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/data/versions.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/data/versions.go @@ -1,12 +1,27 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package data import ( "reflect" - v2 "github.com/devfile/library/pkg/devfile/parser/data/v2" - v200 "github.com/devfile/library/pkg/devfile/parser/data/v2/2.0.0" - v210 "github.com/devfile/library/pkg/devfile/parser/data/v2/2.1.0" - v220 "github.com/devfile/library/pkg/devfile/parser/data/v2/2.2.0" + v2 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2" + v200 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.0.0" + v210 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.1.0" + v220 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.2.0" ) // SupportedApiVersions stores the supported devfile API versions diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/devfileobj.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/devfileobj.go new file mode 100644 index 00000000000..1043896047b --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/devfileobj.go @@ -0,0 +1,37 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" +) + +// Default filenames for create devfile +const ( + OutputDevfileYamlPath = "devfile.yaml" + K8sLikeComponentOriginalURIKey = "api.devfile.io/k8sLikeComponent-originalURI" +) + +// DevfileObj is the runtime devfile object +type DevfileObj struct { + + // Ctx has devfile context info + Ctx devfileCtx.DevfileCtx + + // Data has the devfile data + Data data.DevfileData +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/parse.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go similarity index 69% rename from vendor/github.com/devfile/library/pkg/devfile/parser/parse.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go index a4ba3820218..5523d39bbed 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/parse.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/parse.go @@ -1,24 +1,43 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( "context" "encoding/json" "fmt" + "io/ioutil" "net/url" + "os" "path" "strings" - "github.com/devfile/library/pkg/util" + "github.com/devfile/api/v2/pkg/attributes" + registryLibrary "github.com/devfile/registry-support/registry-library/library" + + "reflect" + + devfileCtx "github.com/devfile/library/v2/pkg/devfile/parser/context" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "github.com/devfile/library/v2/pkg/util" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/clientcmd" - "sigs.k8s.io/controller-runtime/pkg/client" - - devfileCtx "github.com/devfile/library/pkg/devfile/parser/context" - "github.com/devfile/library/pkg/devfile/parser/data" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" "k8s.io/klog" - - "reflect" + "sigs.k8s.io/controller-runtime/pkg/client" v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" apiOverride "github.com/devfile/api/v2/pkg/utils/overriding" @@ -72,6 +91,9 @@ type ParserArgs struct { // FlattenedDevfile defines if the returned devfileObj is flattened content (true) or raw content (false). // The value is default to be true. FlattenedDevfile *bool + // ConvertKubernetesContentInUri defines if the kubernetes resources definition from uri will be converted to inlined in devObj(true) or not (false). + // The value is default to be true. + ConvertKubernetesContentInUri *bool // RegistryURLs is a list of registry hosts which parser should pull parent devfile from. // If registryUrl is defined in devfile, this list will be ignored. RegistryURLs []string @@ -84,6 +106,8 @@ type ParserArgs struct { K8sClient client.Client // ExternalVariables override variables defined in the Devfile ExternalVariables map[string]string + // HTTPTimeout overrides the request and response timeout values for reading a parent devfile reference from the registry. If a negative value is specified, the default timeout will be used. + HTTPTimeout *int } // ParseDevfile func populates the devfile data, parses and validates the devfile integrity. @@ -107,6 +131,7 @@ func ParseDevfile(args ParserArgs) (d DevfileObj, err error) { registryURLs: args.RegistryURLs, context: args.Context, k8sClient: args.K8sClient, + httpTimeout: args.HTTPTimeout, } flattenedDevfile := true @@ -127,6 +152,19 @@ func ParseDevfile(args ParserArgs) (d DevfileObj, err error) { } } + convertUriToInlined := true + if args.ConvertKubernetesContentInUri != nil { + convertUriToInlined = *args.ConvertKubernetesContentInUri + } + + if convertUriToInlined { + d.Ctx.SetConvertUriToInlined(true) + err = parseKubeResourceFromURI(d) + if err != nil { + return d, errors.Wrapf(err, "failed to parse kubernetes/openshift component from uri to inlined") + } + } + return d, err } @@ -141,6 +179,8 @@ type resolverTools struct { context context.Context // K8sClient is the Kubernetes client instance used for interacting with a cluster k8sClient client.Client + // httpTimeout is the timeout value in seconds passed in from the client. + httpTimeout *int } func populateAndParseDevfile(d DevfileObj, resolveCtx *resolutionContextTree, tool resolverTools, flattenedDevfile bool) (DevfileObj, error) { @@ -357,19 +397,45 @@ func parseFromURI(importReference v1.ImportReference, curDevfileCtx devfileCtx.D if !absoluteURL && curDevfileCtx.GetAbsPath() != "" { newUri = path.Join(path.Dir(curDevfileCtx.GetAbsPath()), uri) d.Ctx = devfileCtx.NewDevfileCtx(newUri) - } else if absoluteURL { - // absolute URL address - newUri = uri - d.Ctx = devfileCtx.NewURLDevfileCtx(newUri) - } else if curDevfileCtx.GetURL() != "" { - // relative path to a URL - u, err := url.Parse(curDevfileCtx.GetURL()) - if err != nil { - return DevfileObj{}, err + if util.ValidateFile(newUri) != nil { + return DevfileObj{}, fmt.Errorf("the provided path is not a valid filepath %s", newUri) + } + srcDir := path.Dir(newUri) + destDir := path.Dir(curDevfileCtx.GetAbsPath()) + if srcDir != destDir { + err := util.CopyAllDirFiles(srcDir, destDir) + if err != nil { + return DevfileObj{}, err + } } - u.Path = path.Join(path.Dir(u.Path), uri) - newUri = u.String() + } else { + if absoluteURL { + // absolute URL address + newUri = uri + } else if curDevfileCtx.GetURL() != "" { + // relative path to a URL + u, err := url.Parse(curDevfileCtx.GetURL()) + if err != nil { + return DevfileObj{}, err + } + u.Path = path.Join(u.Path, uri) + newUri = u.String() + } else { + return DevfileObj{}, fmt.Errorf("failed to resolve parent uri, devfile context is missing absolute url and path to devfile. %s", resolveImportReference(importReference)) + } + d.Ctx = devfileCtx.NewURLDevfileCtx(newUri) + if strings.Contains(newUri, "raw.githubusercontent.com") { + urlComponents, err := util.GetGitUrlComponentsFromRaw(newUri) + if err != nil { + return DevfileObj{}, err + } + destDir := path.Dir(curDevfileCtx.GetAbsPath()) + err = getResourcesFromGit(urlComponents, destDir) + if err != nil { + return DevfileObj{}, err + } + } } importReference.Uri = newUri newResolveCtx := resolveCtx.appendNode(importReference) @@ -377,11 +443,34 @@ func parseFromURI(importReference v1.ImportReference, curDevfileCtx devfileCtx.D return populateAndParseDevfile(d, newResolveCtx, tool, true) } +func getResourcesFromGit(gitUrlComponents map[string]string, destDir string) error { + stackDir, err := ioutil.TempDir(os.TempDir(), fmt.Sprintf("git-resources")) + if err != nil { + return fmt.Errorf("failed to create dir: %s, error: %v", stackDir, err) + } + defer os.RemoveAll(stackDir) + + err = util.CloneGitRepo(gitUrlComponents, stackDir) + if err != nil { + return err + } + + dir := path.Dir(path.Join(stackDir, gitUrlComponents["file"])) + err = util.CopyAllDirFiles(dir, destDir) + if err != nil { + return err + } + + return nil +} + func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutionContextTree, tool resolverTools) (d DevfileObj, err error) { id := importReference.Id registryURL := importReference.RegistryUrl + destDir := path.Dir(d.Ctx.GetAbsPath()) + if registryURL != "" { - devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version) + devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version, tool.httpTimeout) if err != nil { return DevfileObj{}, err } @@ -391,11 +480,16 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio } newResolveCtx := resolveCtx.appendNode(importReference) + err = getResourcesFromRegistry(id, registryURL, destDir) + if err != nil { + return DevfileObj{}, err + } + return populateAndParseDevfile(d, newResolveCtx, tool, true) } else if tool.registryURLs != nil { for _, registryURL := range tool.registryURLs { - devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version) + devfileContent, err := getDevfileFromRegistry(id, registryURL, importReference.Version, tool.httpTimeout) if devfileContent != nil && err == nil { d.Ctx, err = devfileCtx.NewByteContentDevfileCtx(devfileContent) if err != nil { @@ -404,6 +498,11 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio importReference.RegistryUrl = registryURL newResolveCtx := resolveCtx.appendNode(importReference) + err := getResourcesFromRegistry(id, registryURL, destDir) + if err != nil { + return DevfileObj{}, err + } + return populateAndParseDevfile(d, newResolveCtx, tool, true) } } @@ -414,16 +513,40 @@ func parseFromRegistry(importReference v1.ImportReference, resolveCtx *resolutio return DevfileObj{}, fmt.Errorf("failed to get id: %s from registry URLs provided", id) } -func getDevfileFromRegistry(id, registryURL, version string) ([]byte, error) { +func getDevfileFromRegistry(id, registryURL, version string, httpTimeout *int) ([]byte, error) { if !strings.HasPrefix(registryURL, "http://") && !strings.HasPrefix(registryURL, "https://") { return nil, fmt.Errorf("the provided registryURL: %s is not a valid URL", registryURL) } param := util.HTTPRequestParams{ URL: fmt.Sprintf("%s/devfiles/%s/%s", registryURL, id, version), } + + param.Timeout = httpTimeout + //suppress telemetry for parent uri references + param.TelemetryClientName = util.TelemetryIndirectDevfileCall return util.HTTPGetRequest(param, 0) } +func getResourcesFromRegistry(id, registryURL, destDir string) error { + stackDir, err := ioutil.TempDir(os.TempDir(), fmt.Sprintf("registry-resources-%s", id)) + if err != nil { + return fmt.Errorf("failed to create dir: %s, error: %v", stackDir, err) + } + defer os.RemoveAll(stackDir) + //suppress telemetry for downloading resources from parent reference + err = registryLibrary.PullStackFromRegistry(registryURL, id, stackDir, registryLibrary.RegistryOptions{Telemetry: registryLibrary.TelemetryData{Client: util.TelemetryIndirectDevfileCall}}) + if err != nil { + return fmt.Errorf("failed to pull stack from registry %s", registryURL) + } + + err = util.CopyAllDirFiles(stackDir, destDir) + if err != nil { + return err + } + + return nil +} + func parseFromKubeCRD(importReference v1.ImportReference, resolveCtx *resolutionContextTree, tool resolverTools) (d DevfileObj, err error) { if tool.k8sClient == nil || tool.context == nil { @@ -599,3 +722,120 @@ func setEndpoints(endpoints []v1.Endpoint) { endpoints[i].Secure = &val } } + +//parseKubeResourceFromURI iterate through all kubernetes & openshift components, and parse from uri and update the content to inlined field in devfileObj +func parseKubeResourceFromURI(devObj DevfileObj) error { + getKubeCompOptions := common.DevfileOptions{ + ComponentOptions: common.ComponentOptions{ + ComponentType: v1.KubernetesComponentType, + }, + } + getOpenshiftCompOptions := common.DevfileOptions{ + ComponentOptions: common.ComponentOptions{ + ComponentType: v1.OpenshiftComponentType, + }, + } + kubeComponents, err := devObj.Data.GetComponents(getKubeCompOptions) + if err != nil { + return err + } + openshiftComponents, err := devObj.Data.GetComponents(getOpenshiftCompOptions) + if err != nil { + return err + } + for _, kubeComp := range kubeComponents { + if kubeComp.Kubernetes != nil && kubeComp.Kubernetes.Uri != "" { + /* #nosec G601 -- not an issue, kubeComp is de-referenced in sequence*/ + err := convertK8sLikeCompUriToInlined(&kubeComp, devObj.Ctx) + if err != nil { + return errors.Wrapf(err, "failed to convert Kubernetes Uri to inlined for component '%s'", kubeComp.Name) + } + err = devObj.Data.UpdateComponent(kubeComp) + if err != nil { + return err + } + } + } + for _, openshiftComp := range openshiftComponents { + if openshiftComp.Openshift != nil && openshiftComp.Openshift.Uri != "" { + /* #nosec G601 -- not an issue, openshiftComp is de-referenced in sequence*/ + err := convertK8sLikeCompUriToInlined(&openshiftComp, devObj.Ctx) + if err != nil { + return errors.Wrapf(err, "failed to convert Openshift Uri to inlined for component '%s'", openshiftComp.Name) + } + err = devObj.Data.UpdateComponent(openshiftComp) + if err != nil { + return err + } + } + } + return nil +} + +//convertK8sLikeCompUriToInlined read in kubernetes resources definition from uri and converts to kubernetest inlined field +func convertK8sLikeCompUriToInlined(component *v1.Component, d devfileCtx.DevfileCtx) error { + var uri string + if component.Kubernetes != nil { + uri = component.Kubernetes.Uri + } else if component.Openshift != nil { + uri = component.Openshift.Uri + } + data, err := getKubernetesDefinitionFromUri(uri, d) + if err != nil { + return err + } + if component.Kubernetes != nil { + component.Kubernetes.Inlined = string(data) + component.Kubernetes.Uri = "" + } else if component.Openshift != nil { + component.Openshift.Inlined = string(data) + component.Openshift.Uri = "" + } + if component.Attributes == nil { + component.Attributes = attributes.Attributes{} + } + component.Attributes.PutString(K8sLikeComponentOriginalURIKey, uri) + + return nil +} + +//getKubernetesDefinitionFromUri read in kubernetes resources definition from uri and returns the raw content +func getKubernetesDefinitionFromUri(uri string, d devfileCtx.DevfileCtx) ([]byte, error) { + // validate URI + err := validation.ValidateURI(uri) + if err != nil { + return nil, err + } + + absoluteURL := strings.HasPrefix(uri, "http://") || strings.HasPrefix(uri, "https://") + var newUri string + var data []byte + // relative path on disk + if !absoluteURL && d.GetAbsPath() != "" { + newUri = path.Join(path.Dir(d.GetAbsPath()), uri) + fs := d.GetFs() + data, err = fs.ReadFile(newUri) + if err != nil { + return nil, errors.Wrapf(err, "failed to read kubernetes resources definition from path '%s'", newUri) + } + } else if absoluteURL || d.GetURL() != "" { + if d.GetURL() != "" { + // relative path to a URL + u, err := url.Parse(d.GetURL()) + if err != nil { + return nil, err + } + u.Path = path.Join(path.Dir(u.Path), uri) + newUri = u.String() + } else { + // absolute URL address + newUri = uri + } + params := util.HTTPRequestParams{URL: newUri} + data, err = util.DownloadInMemory(params) + if err != nil { + return nil, errors.Wrapf(err, "error getting kubernetes resources definition info from url '%s'", newUri) + } + } + return data, nil +} diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/reader.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/reader.go new file mode 100644 index 00000000000..d55c2f270ac --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/reader.go @@ -0,0 +1,157 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "bytes" + "fmt" + "io" + + "github.com/devfile/library/v2/pkg/util" + "github.com/pkg/errors" + "github.com/spf13/afero" + "gopkg.in/yaml.v3" + k8yaml "sigs.k8s.io/yaml" + + routev1 "github.com/openshift/api/route/v1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + networkingv1 "k8s.io/api/networking/v1" +) + +// YamlSrc specifies the src of the yaml in either Path, URL or Data format +type YamlSrc struct { + // Path to the yaml file + Path string + // URL of the yaml file + URL string + // Data is the yaml content in []byte format + Data []byte +} + +// KubernetesResources struct contains the Deployments, Services, +// Routes and Ingresses resources +type KubernetesResources struct { + Deployments []appsv1.Deployment + Services []corev1.Service + Routes []routev1.Route + Ingresses []networkingv1.Ingress + Others []interface{} +} + +// ReadKubernetesYaml reads a yaml Kubernetes file from either the Path, URL or Data provided. +// It returns all the parsed Kubernetes objects as an array of interface. +// Consumers interested in the Kubernetes resources are expected to Unmarshal +// it to the struct of the respective Kubernetes resource. If a Path is being passed, +// provide a filesystem, otherwise nil can be passed in +func ReadKubernetesYaml(src YamlSrc, fs *afero.Afero) ([]interface{}, error) { + + var data []byte + var err error + + if src.URL != "" { + params := util.HTTPRequestParams{URL: src.URL} + data, err = util.DownloadInMemory(params) + if err != nil { + return nil, errors.Wrapf(err, "failed to download file %q", src.URL) + } + } else if src.Path != "" { + if fs == nil { + return nil, fmt.Errorf("cannot read from %s because fs passed in was nil", src.Path) + } + data, err = fs.ReadFile(src.Path) + if err != nil { + return nil, errors.Wrapf(err, "failed to read yaml from path %q", src.Path) + } + } else if len(src.Data) > 0 { + data = src.Data + } + + var values []interface{} + dec := yaml.NewDecoder(bytes.NewReader(data)) + for { + var value interface{} + err = dec.Decode(&value) + if err != nil { + if err == io.EOF { + break + } + return nil, err + } + values = append(values, value) + } + + return values, nil +} + +// ParseKubernetesYaml Unmarshals the interface array of the Kubernetes resources +// and returns it as a KubernetesResources struct. Only Deployment, Service, Route +// and Ingress are processed. Consumers interested in other Kubernetes resources +// are expected to parse the values interface array an Unmarshal it to their +// desired Kuberenetes struct +func ParseKubernetesYaml(values []interface{}) (KubernetesResources, error) { + var deployments []appsv1.Deployment + var services []corev1.Service + var routes []routev1.Route + var ingresses []networkingv1.Ingress + var otherResources []interface{} + + for _, value := range values { + var deployment appsv1.Deployment + var service corev1.Service + var route routev1.Route + var ingress networkingv1.Ingress + var otherResource interface{} + + byteData, err := k8yaml.Marshal(value) + if err != nil { + return KubernetesResources{}, err + } + + kubernetesMap := value.(map[string]interface{}) + kind := kubernetesMap["kind"] + + switch kind { + case "Deployment": + err = k8yaml.Unmarshal(byteData, &deployment) + deployments = append(deployments, deployment) + case "Service": + err = k8yaml.Unmarshal(byteData, &service) + services = append(services, service) + case "Route": + err = k8yaml.Unmarshal(byteData, &route) + routes = append(routes, route) + case "Ingress": + err = k8yaml.Unmarshal(byteData, &ingress) + ingresses = append(ingresses, ingress) + default: + err = k8yaml.Unmarshal(byteData, &otherResource) + otherResources = append(otherResources, otherResource) + } + + if err != nil { + return KubernetesResources{}, err + } + } + + return KubernetesResources{ + Deployments: deployments, + Services: services, + Routes: routes, + Ingresses: ingresses, + Others: otherResources, + }, nil +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/resolutionContext.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/resolutionContext.go similarity index 76% rename from vendor/github.com/devfile/library/pkg/devfile/parser/resolutionContext.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/resolutionContext.go index 5bb0d4bf46e..799ecd64e24 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/resolutionContext.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/resolutionContext.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( diff --git a/vendor/github.com/devfile/library/pkg/devfile/parser/sourceAttribute.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/sourceAttribute.go similarity index 89% rename from vendor/github.com/devfile/library/pkg/devfile/parser/sourceAttribute.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/parser/sourceAttribute.go index dd7608fc0ba..b8949092760 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/parser/sourceAttribute.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/sourceAttribute.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/utils.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/utils.go new file mode 100644 index 00000000000..d65ce6ff541 --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/utils.go @@ -0,0 +1,112 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "fmt" + "reflect" + + devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" + "github.com/devfile/library/v2/pkg/devfile/parser/data" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" +) + +// GetDeployComponents gets the default deploy command associated components +func GetDeployComponents(devfileData data.DevfileData) (map[string]string, error) { + deployCommandFilter := common.DevfileOptions{ + CommandOptions: common.CommandOptions{ + CommandGroupKind: devfilev1.DeployCommandGroupKind, + }, + } + deployCommands, err := devfileData.GetCommands(deployCommandFilter) + if err != nil { + return nil, err + } + + deployAssociatedComponents := make(map[string]string) + var deployAssociatedSubCommands []string + + for _, command := range deployCommands { + if command.Apply != nil { + if len(deployCommands) > 1 && command.Apply.Group.IsDefault != nil && !*command.Apply.Group.IsDefault { + continue + } + deployAssociatedComponents[command.Apply.Component] = command.Apply.Component + } else if command.Composite != nil { + if len(deployCommands) > 1 && command.Composite.Group.IsDefault != nil && !*command.Composite.Group.IsDefault { + continue + } + deployAssociatedSubCommands = append(deployAssociatedSubCommands, command.Composite.Commands...) + } + } + + applyCommandFilter := common.DevfileOptions{ + CommandOptions: common.CommandOptions{ + CommandType: devfilev1.ApplyCommandType, + }, + } + applyCommands, err := devfileData.GetCommands(applyCommandFilter) + if err != nil { + return nil, err + } + + for _, command := range applyCommands { + if command.Apply != nil { + for _, deployCommand := range deployAssociatedSubCommands { + if deployCommand == command.Id { + deployAssociatedComponents[command.Apply.Component] = command.Apply.Component + } + } + + } + } + + return deployAssociatedComponents, nil +} + +// GetImageBuildComponent gets the image build component from the deploy associated components +func GetImageBuildComponent(devfileData data.DevfileData, deployAssociatedComponents map[string]string) (devfilev1.Component, error) { + imageComponentFilter := common.DevfileOptions{ + ComponentOptions: common.ComponentOptions{ + ComponentType: devfilev1.ImageComponentType, + }, + } + + imageComponents, err := devfileData.GetComponents(imageComponentFilter) + if err != nil { + return devfilev1.Component{}, err + } + + var imageBuildComponent devfilev1.Component + for _, component := range imageComponents { + if _, ok := deployAssociatedComponents[component.Name]; ok && component.Image != nil { + if reflect.DeepEqual(imageBuildComponent, devfilev1.Component{}) { + imageBuildComponent = component + } else { + errMsg := "expected to find one devfile image component with a deploy command for build. Currently there is more than one image component" + return devfilev1.Component{}, fmt.Errorf(errMsg) + } + } + } + + // If there is not one image component defined in the deploy command, err out + if reflect.DeepEqual(imageBuildComponent, devfilev1.Component{}) { + errMsg := "expected to find one devfile image component with a deploy command for build. Currently there is no image component" + return devfilev1.Component{}, fmt.Errorf(errMsg) + } + + return imageBuildComponent, nil +} diff --git a/vendor/github.com/devfile/library/v2/pkg/devfile/parser/writer.go b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/writer.go new file mode 100644 index 00000000000..ed3f287030e --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/parser/writer.go @@ -0,0 +1,115 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" + apiAttributes "github.com/devfile/api/v2/pkg/attributes" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" + "sigs.k8s.io/yaml" + + "github.com/devfile/library/v2/pkg/testingutil/filesystem" + "github.com/pkg/errors" + "k8s.io/klog" +) + +// WriteYamlDevfile creates a devfile.yaml file +func (d *DevfileObj) WriteYamlDevfile() error { + + // Check kubernetes components, and restore original uri content + if d.Ctx.GetConvertUriToInlined() { + err := restoreK8sCompURI(d) + if err != nil { + return errors.Wrapf(err, "failed to restore kubernetes component uri field") + } + } + // Encode data into YAML format + yamlData, err := yaml.Marshal(d.Data) + if err != nil { + return errors.Wrapf(err, "failed to marshal devfile object into yaml") + } + // Write to devfile.yaml + fs := d.Ctx.GetFs() + if fs == nil { + fs = filesystem.DefaultFs{} + } + err = fs.WriteFile(d.Ctx.GetAbsPath(), yamlData, 0644) + if err != nil { + return errors.Wrapf(err, "failed to create devfile yaml file") + } + + // Successful + klog.V(2).Infof("devfile yaml created at: '%s'", OutputDevfileYamlPath) + return nil +} + +func restoreK8sCompURI(devObj *DevfileObj) error { + getKubeCompOptions := common.DevfileOptions{ + ComponentOptions: common.ComponentOptions{ + ComponentType: v1.KubernetesComponentType, + }, + } + getOpenshiftCompOptions := common.DevfileOptions{ + ComponentOptions: common.ComponentOptions{ + ComponentType: v1.OpenshiftComponentType, + }, + } + kubeComponents, err := devObj.Data.GetComponents(getKubeCompOptions) + if err != nil { + return err + } + openshiftComponents, err := devObj.Data.GetComponents(getOpenshiftCompOptions) + if err != nil { + return err + } + + for _, kubeComp := range kubeComponents { + uri := kubeComp.Attributes.GetString(K8sLikeComponentOriginalURIKey, &err) + if err != nil { + if _, ok := err.(*apiAttributes.KeyNotFoundError); !ok { + return err + } + } + if uri != "" { + kubeComp.Kubernetes.Uri = uri + kubeComp.Kubernetes.Inlined = "" + delete(kubeComp.Attributes, K8sLikeComponentOriginalURIKey) + err = devObj.Data.UpdateComponent(kubeComp) + if err != nil { + return err + } + } + } + + for _, openshiftComp := range openshiftComponents { + uri := openshiftComp.Attributes.GetString(K8sLikeComponentOriginalURIKey, &err) + if err != nil { + if _, ok := err.(*apiAttributes.KeyNotFoundError); !ok { + return err + } + } + if uri != "" { + openshiftComp.Openshift.Uri = uri + openshiftComp.Openshift.Inlined = "" + delete(openshiftComp.Attributes, K8sLikeComponentOriginalURIKey) + err = devObj.Data.UpdateComponent(openshiftComp) + if err != nil { + return err + } + } + } + return nil +} diff --git a/vendor/github.com/devfile/library/pkg/devfile/validate/validate.go b/vendor/github.com/devfile/library/v2/pkg/devfile/validate/validate.go similarity index 65% rename from vendor/github.com/devfile/library/pkg/devfile/validate/validate.go rename to vendor/github.com/devfile/library/v2/pkg/devfile/validate/validate.go index a1fa0026552..e40d89ab66a 100644 --- a/vendor/github.com/devfile/library/pkg/devfile/validate/validate.go +++ b/vendor/github.com/devfile/library/v2/pkg/devfile/validate/validate.go @@ -1,11 +1,26 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package validate import ( "fmt" v2Validation "github.com/devfile/api/v2/pkg/validation" - devfileData "github.com/devfile/library/pkg/devfile/parser/data" - v2 "github.com/devfile/library/pkg/devfile/parser/data/v2" - "github.com/devfile/library/pkg/devfile/parser/data/v2/common" + devfileData "github.com/devfile/library/v2/pkg/devfile/parser/data" + v2 "github.com/devfile/library/v2/pkg/devfile/parser/data/v2" + "github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common" "github.com/hashicorp/go-multierror" ) diff --git a/vendor/github.com/devfile/library/v2/pkg/testingutil/containers.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/containers.go new file mode 100644 index 00000000000..00720ea1ef4 --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/testingutil/containers.go @@ -0,0 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testingutil + +import corev1 "k8s.io/api/core/v1" + +// CreateFakeContainer creates a container with the given containerName +func CreateFakeContainer(containerName string) corev1.Container { + return corev1.Container{ + Name: containerName, + } +} diff --git a/vendor/github.com/devfile/library/pkg/testingutil/devfile.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/devfile.go similarity index 91% rename from vendor/github.com/devfile/library/pkg/testingutil/devfile.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/devfile.go index 74831a2b2bf..21a9ec2cb48 100644 --- a/vendor/github.com/devfile/library/pkg/testingutil/devfile.go +++ b/vendor/github.com/devfile/library/v2/pkg/testingutil/devfile.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package testingutil import ( diff --git a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/default_fs.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/default_fs.go similarity index 100% rename from vendor/github.com/devfile/library/pkg/testingutil/filesystem/default_fs.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/default_fs.go diff --git a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/fake_fs.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/fake_fs.go similarity index 100% rename from vendor/github.com/devfile/library/pkg/testingutil/filesystem/fake_fs.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/fake_fs.go diff --git a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/filesystem.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/filesystem.go similarity index 100% rename from vendor/github.com/devfile/library/pkg/testingutil/filesystem/filesystem.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/filesystem.go diff --git a/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/singleton.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/singleton.go new file mode 100644 index 00000000000..1d16ade79d0 --- /dev/null +++ b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/singleton.go @@ -0,0 +1,25 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package filesystem + +var singleFs Filesystem + +func Get() Filesystem { + if singleFs == nil { + singleFs = &DefaultFs{} + } + return singleFs +} diff --git a/vendor/github.com/devfile/library/pkg/testingutil/filesystem/watcher.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/watcher.go similarity index 100% rename from vendor/github.com/devfile/library/pkg/testingutil/filesystem/watcher.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/filesystem/watcher.go diff --git a/vendor/github.com/devfile/library/pkg/testingutil/k8sClient.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/k8sClient.go similarity index 60% rename from vendor/github.com/devfile/library/pkg/testingutil/k8sClient.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/k8sClient.go index 93394fd3206..68f877c2bec 100644 --- a/vendor/github.com/devfile/library/pkg/testingutil/k8sClient.go +++ b/vendor/github.com/devfile/library/v2/pkg/testingutil/k8sClient.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package testingutil import ( diff --git a/vendor/github.com/devfile/library/pkg/testingutil/resources.go b/vendor/github.com/devfile/library/v2/pkg/testingutil/resources.go similarity index 60% rename from vendor/github.com/devfile/library/pkg/testingutil/resources.go rename to vendor/github.com/devfile/library/v2/pkg/testingutil/resources.go index e6495a711ae..7e70cf9fe5c 100644 --- a/vendor/github.com/devfile/library/pkg/testingutil/resources.go +++ b/vendor/github.com/devfile/library/v2/pkg/testingutil/resources.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package testingutil import ( diff --git a/vendor/github.com/devfile/library/pkg/util/httpcache.go b/vendor/github.com/devfile/library/v2/pkg/util/httpcache.go similarity index 51% rename from vendor/github.com/devfile/library/pkg/util/httpcache.go rename to vendor/github.com/devfile/library/v2/pkg/util/httpcache.go index 8c1406016c3..8efa0a94105 100644 --- a/vendor/github.com/devfile/library/pkg/util/httpcache.go +++ b/vendor/github.com/devfile/library/v2/pkg/util/httpcache.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package util import ( diff --git a/vendor/github.com/devfile/library/pkg/util/util.go b/vendor/github.com/devfile/library/v2/pkg/util/util.go similarity index 83% rename from vendor/github.com/devfile/library/pkg/util/util.go rename to vendor/github.com/devfile/library/v2/pkg/util/util.go index 7d10a9b78d6..bdcdb4d139e 100644 --- a/vendor/github.com/devfile/library/pkg/util/util.go +++ b/vendor/github.com/devfile/library/v2/pkg/util/util.go @@ -1,3 +1,18 @@ +// +// Copyright 2022 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package util import ( @@ -26,8 +41,11 @@ import ( "syscall" "time" - "github.com/devfile/library/pkg/testingutil/filesystem" + "github.com/go-git/go-git/v5/plumbing" + + "github.com/devfile/library/v2/pkg/testingutil/filesystem" "github.com/fatih/color" + gitpkg "github.com/go-git/go-git/v5" "github.com/gobwas/glob" "github.com/gregjones/httpcache" "github.com/gregjones/httpcache/diskcache" @@ -40,10 +58,11 @@ import ( ) const ( - HTTPRequestTimeout = 30 * time.Second // HTTPRequestTimeout configures timeout of all HTTP requests - ResponseHeaderTimeout = 30 * time.Second // ResponseHeaderTimeout is the timeout to retrieve the server's response headers - ModeReadWriteFile = 0600 // default Permission for a file - CredentialPrefix = "odo-" // CredentialPrefix is the prefix of the credential that uses to access secure registry + HTTPRequestResponseTimeout = 30 * time.Second // HTTPRequestTimeout configures timeout of all HTTP requests + ModeReadWriteFile = 0600 // default Permission for a file + CredentialPrefix = "odo-" // CredentialPrefix is the prefix of the credential that uses to access secure registry + TelemetryClientName = "devfile-library" //TelemetryClientName is the name of the devfile library client + TelemetryIndirectDevfileCall = "devfile-library-indirect" //TelemetryIndirectDevfileCall is used to identify calls made to retrieve the parent or plugin devfile ) // httpCacheDir determines directory where odo will cache HTTP respones @@ -70,8 +89,10 @@ type ResourceRequirementInfo struct { // HTTPRequestParams holds parameters of forming http request type HTTPRequestParams struct { - URL string - Token string + URL string + Token string + Timeout *int + TelemetryClientName string //optional client name for telemetry } // DownloadParams holds parameters of forming file download request @@ -421,7 +442,11 @@ func FetchResourceQuantity(resourceType corev1.ResourceName, min string, max str // CheckPathExists checks if a path exists or not func CheckPathExists(path string) bool { - if _, err := os.Stat(path); !os.IsNotExist(err) { + return checkPathExistsOnFS(path, filesystem.DefaultFs{}) +} + +func checkPathExistsOnFS(path string, fs filesystem.Filesystem) bool { + if _, err := fs.Stat(path); !os.IsNotExist(err) { // path to file does exist return true } @@ -473,7 +498,7 @@ func GetIgnoreRulesFromDirectory(directory string) ([]string, error) { } } - file, err := os.Open(pathIgnore) + file, err := os.Open(filepath.Clean(pathIgnore)) if err != nil { return nil, err } @@ -686,7 +711,7 @@ func HTTPGetFreePort() (int, error) { // shamelessly taken from: https://stackoverflow.com/questions/30697324/how-to-check-if-directory-on-path-is-empty // this helps detect any edge cases where an empty directory is copied over func IsEmpty(name string) (bool, error) { - f, err := os.Open(name) + f, err := os.Open(filepath.Clean(name)) if err != nil { return false, err } @@ -723,11 +748,29 @@ func HTTPGetRequest(request HTTPRequestParams, cacheFor int) ([]byte, error) { req.Header.Add("Authorization", bearer) } + //add the telemetry client name + req.Header.Add("Client", request.TelemetryClientName) + + overriddenTimeout := HTTPRequestResponseTimeout + timeout := request.Timeout + if timeout != nil { + //if value is invalid, the default will be used + if *timeout > 0 { + //convert timeout to seconds + overriddenTimeout = time.Duration(*timeout) * time.Second + klog.V(4).Infof("HTTP request and response timeout overridden value is %v ", overriddenTimeout) + } else { + klog.V(4).Infof("Invalid httpTimeout is passed in, using default value") + } + + } + httpClient := &http.Client{ Transport: &http.Transport{ - ResponseHeaderTimeout: ResponseHeaderTimeout, + Proxy: http.ProxyFromEnvironment, + ResponseHeaderTimeout: overriddenTimeout, }, - Timeout: HTTPRequestTimeout, + Timeout: overriddenTimeout, } klog.V(4).Infof("HTTPGetRequest: %s", req.URL.String()) @@ -961,7 +1004,7 @@ func Unzip(src, dest, pathToUnzip string) ([]string, error) { return filenames, err } - outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, ModeReadWriteFile) + outFile, err := os.OpenFile(filepath.Clean(fpath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, ModeReadWriteFile) if err != nil { return filenames, err } @@ -979,8 +1022,8 @@ func Unzip(src, dest, pathToUnzip string) ([]string, error) { _, err = io.Copy(outFile, limited) // Close the file without defer to close before next iteration of loop - outFile.Close() - rc.Close() + _ = outFile.Close() + _ = rc.Close() if err != nil { return filenames, err @@ -1020,10 +1063,11 @@ func DownloadFile(params DownloadParams) error { } // DownloadFileInMemory uses the url to download the file and return bytes +// Deprecated, use DownloadInMemory() instead func DownloadFileInMemory(url string) ([]byte, error) { var httpClient = &http.Client{Transport: &http.Transport{ - ResponseHeaderTimeout: ResponseHeaderTimeout, - }, Timeout: HTTPRequestTimeout} + ResponseHeaderTimeout: HTTPRequestResponseTimeout, + }, Timeout: HTTPRequestResponseTimeout} resp, err := httpClient.Get(url) if err != nil { return nil, err @@ -1037,6 +1081,34 @@ func DownloadFileInMemory(url string) ([]byte, error) { return ioutil.ReadAll(resp.Body) } +// DownloadInMemory uses HTTPRequestParams to download the file and return bytes +func DownloadInMemory(params HTTPRequestParams) ([]byte, error) { + + var httpClient = &http.Client{Transport: &http.Transport{ + ResponseHeaderTimeout: HTTPRequestResponseTimeout, + }, Timeout: HTTPRequestResponseTimeout} + + url := params.URL + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + + //add the telemetry client name in the header + req.Header.Add("Client", params.TelemetryClientName) + resp, err := httpClient.Do(req) + if err != nil { + return nil, err + } + // We have a non 1xx / 2xx status, return an error + if (resp.StatusCode - 300) > 0 { + return nil, errors.Errorf("failed to retrieve %s, %v: %s", url, resp.StatusCode, http.StatusText(resp.StatusCode)) + } + defer resp.Body.Close() + + return ioutil.ReadAll(resp.Body) +} + // ValidateK8sResourceName sanitizes kubernetes resource name with the following requirements: // - Contain at most 63 characters // - Contain only lowercase alphanumeric characters or ‘-’ @@ -1114,6 +1186,57 @@ func ValidateFile(filePath string) error { return nil } +// GetGitUrlComponentsFromRaw converts a raw GitHub file link to a map of the url components +func GetGitUrlComponentsFromRaw(rawGitURL string) (map[string]string, error) { + var urlComponents map[string]string + + err := ValidateURL(rawGitURL) + if err != nil { + return nil, err + } + + u, _ := url.Parse(rawGitURL) + // the url scheme (e.g. https://) is removed before splitting into the 5 components + urlPath := strings.SplitN(u.Host+u.Path, "/", 5) + + // raw GitHub url: https://raw.githubusercontent.com/devfile/registry/main/stacks/nodejs/devfile.yaml + // host: raw.githubusercontent.com + // username: devfile + // project: registry + // branch: main + // file: stacks/nodejs/devfile.yaml + if len(urlPath) == 5 { + urlComponents = map[string]string{ + "host": urlPath[0], + "username": urlPath[1], + "project": urlPath[2], + "branch": urlPath[3], + "file": urlPath[4], + } + } + + return urlComponents, nil +} + +// CloneGitRepo clones a GitHub repo to a destination directory +func CloneGitRepo(gitUrlComponents map[string]string, destDir string) error { + gitUrl := fmt.Sprintf("https://github.com/%s/%s.git", gitUrlComponents["username"], gitUrlComponents["project"]) + branch := fmt.Sprintf("refs/heads/%s", gitUrlComponents["branch"]) + + cloneOptions := &gitpkg.CloneOptions{ + URL: gitUrl, + ReferenceName: plumbing.ReferenceName(branch), + SingleBranch: true, + Depth: 1, + } + + _, err := gitpkg.PlainClone(destDir, false, cloneOptions) + if err != nil { + return err + } + return nil +} + // CopyFile copies file from source path to destination path func CopyFile(srcPath string, dstPath string, info os.FileInfo) error { // In order to avoid file overriding issue, do nothing if source path is equal to destination path @@ -1127,14 +1250,14 @@ func CopyFile(srcPath string, dstPath string, info os.FileInfo) error { } // Open source file - srcFile, err := os.Open(srcPath) + srcFile, err := os.Open(filepath.Clean(srcPath)) if err != nil { return err } defer srcFile.Close() // #nosec G307 // Create destination file - dstFile, err := os.Create(dstPath) + dstFile, err := os.Create(filepath.Clean(dstPath)) if err != nil { return err } @@ -1155,6 +1278,82 @@ func CopyFile(srcPath string, dstPath string, info os.FileInfo) error { return nil } +// CopyAllDirFiles recursively copies a source directory to a destination directory +func CopyAllDirFiles(srcDir, destDir string) error { + return copyAllDirFilesOnFS(srcDir, destDir, filesystem.DefaultFs{}) +} + +func copyAllDirFilesOnFS(srcDir, destDir string, fs filesystem.Filesystem) error { + var info os.FileInfo + + files, err := fs.ReadDir(srcDir) + if err != nil { + return errors.Wrapf(err, "failed reading dir %v", srcDir) + } + + for _, file := range files { + srcPath := path.Join(srcDir, file.Name()) + destPath := path.Join(destDir, file.Name()) + + if file.IsDir() { + if info, err = fs.Stat(srcPath); err != nil { + return err + } + if err = fs.MkdirAll(destPath, info.Mode()); err != nil { + return err + } + if err = copyAllDirFilesOnFS(srcPath, destPath, fs); err != nil { + return err + } + } else { + if file.Name() == "devfile.yaml" { + continue + } + // Only copy files that do not exist in the destination directory + if !checkPathExistsOnFS(destPath, fs) { + if err := copyFileOnFs(srcPath, destPath, fs); err != nil { + return errors.Wrapf(err, "failed to copy %s to %s", srcPath, destPath) + } + } + } + } + return nil +} + +// copied from: https://github.com/devfile/registry-support/blob/main/index/generator/library/util.go +func copyFileOnFs(src, dst string, fs filesystem.Filesystem) error { + var err error + var srcinfo os.FileInfo + + srcfd, err := fs.Open(src) + if err != nil { + return err + } + defer func() { + if e := srcfd.Close(); e != nil { + fmt.Printf("err occurred while closing file: %v", e) + } + }() + + dstfd, err := fs.Create(dst) + if err != nil { + return err + } + defer func() { + if e := dstfd.Close(); e != nil { + fmt.Printf("err occurred while closing file: %v", e) + } + }() + + if _, err = io.Copy(dstfd, srcfd); err != nil { + return err + } + if srcinfo, err = fs.Stat(src); err != nil { + return err + } + return fs.Chmod(dst, srcinfo.Mode()) +} + // PathEqual compare the paths to determine if they are equal func PathEqual(firstPath string, secondPath string) bool { firstAbsPath, _ := GetAbsPath(firstPath) diff --git a/vendor/modules.txt b/vendor/modules.txt index ae71ab3d1f0..cf75c54770b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,20 +153,22 @@ github.com/devfile/api/v2/pkg/validation github.com/devfile/api/v2/pkg/validation/variables # github.com/devfile/library v1.2.1-0.20220602130922-85a4805bd59c ## explicit; go 1.15 -github.com/devfile/library/pkg/devfile -github.com/devfile/library/pkg/devfile/generator -github.com/devfile/library/pkg/devfile/parser -github.com/devfile/library/pkg/devfile/parser/context -github.com/devfile/library/pkg/devfile/parser/data -github.com/devfile/library/pkg/devfile/parser/data/v2 -github.com/devfile/library/pkg/devfile/parser/data/v2/2.0.0 -github.com/devfile/library/pkg/devfile/parser/data/v2/2.1.0 -github.com/devfile/library/pkg/devfile/parser/data/v2/2.2.0 -github.com/devfile/library/pkg/devfile/parser/data/v2/common -github.com/devfile/library/pkg/devfile/validate -github.com/devfile/library/pkg/testingutil -github.com/devfile/library/pkg/testingutil/filesystem -github.com/devfile/library/pkg/util +# github.com/devfile/library/v2 v2.2.1-0.20230118161058-0d04f791d801 +## explicit; go 1.15 +github.com/devfile/library/v2/pkg/devfile +github.com/devfile/library/v2/pkg/devfile/generator +github.com/devfile/library/v2/pkg/devfile/parser +github.com/devfile/library/v2/pkg/devfile/parser/context +github.com/devfile/library/v2/pkg/devfile/parser/data +github.com/devfile/library/v2/pkg/devfile/parser/data/v2 +github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.0.0 +github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.1.0 +github.com/devfile/library/v2/pkg/devfile/parser/data/v2/2.2.0 +github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common +github.com/devfile/library/v2/pkg/devfile/validate +github.com/devfile/library/v2/pkg/testingutil +github.com/devfile/library/v2/pkg/testingutil/filesystem +github.com/devfile/library/v2/pkg/util # github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273 ## explicit; go 1.14 github.com/devfile/registry-support/index/generator/schema