Skip to content

Commit

Permalink
fix yaml unmarshal of module template
Browse files Browse the repository at this point in the history
  • Loading branch information
lindnerby committed Sep 5, 2024
1 parent 6a6fd87 commit c6967c7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test-e2e-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ jobs:
--registry http://k3d-oci.localhost:5001 \
--insecure \
--module-config-file ./module-config.yaml \
--version $MODULE_TEMPLATE_VERSION -v \
--version $MODULE_TEMPLATE_VERSION \
--sec-scanners-config sec-scanners-config.yaml \
--output /tmp/module-config-template.yaml
--output /tmp/module-config-template.yaml \
--verbose
echo "MODULE_TEMPLATE_PATH=/tmp/module-config-template.yaml" >> "$GITHUB_ENV"
- name: Create a different security scanners config file for different layers
if: ${{matrix.e2e-test == 'test-module-create-same-version' }}
Expand All @@ -79,7 +80,7 @@ jobs:
- \"**/test/**\"
- \"**/*_test.go\"" > sec-scanners-config-changed.yaml
cat sec-scanners-config-changed.yaml
- name: Verify module template
- name: Verify created module template
if: ${{ matrix.e2e-test == 'test-module-create' }}
run: |
echo $MODULE_TEMPLATE_PATH
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ go 1.22.6

require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240903130243-695e809e05b7
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240905061843-1557b7ab0962
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/open-component-model/ocm v0.13.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.31.0
)

require (
Expand Down Expand Up @@ -114,6 +115,7 @@ require (
github.com/elliotchance/orderedmap v1.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.1 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down Expand Up @@ -297,6 +299,7 @@ require (
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.24.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/api v0.188.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
Expand All @@ -310,13 +313,13 @@ require (
helm.sh/helm/v3 v3.15.3 // indirect
k8s.io/api v0.31.0 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/apimachinery v0.31.0 // indirect
k8s.io/cli-runtime v0.30.3 // indirect
k8s.io/client-go v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/controller-runtime v0.19.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.17.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.0 // indirect
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI=
github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down Expand Up @@ -391,6 +393,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU=
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w=
Expand Down Expand Up @@ -626,8 +630,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240903130243-695e809e05b7 h1:WTUspXigXUhzUd5a0JxC73UMCLd5XqoRkGwyt6uE2t8=
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240903130243-695e809e05b7/go.mod h1:bJcxlY2l9sLJmb6ELl/8/p5Nl3EmL2zMPGL329i4uAs=
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240905061843-1557b7ab0962 h1:Pg8hgOjtNp8z6lvyuskozWo9XNtoowJwBucNUq4iMP4=
github.com/kyma-project/lifecycle-manager/api v0.0.0-20240905061843-1557b7ab0962/go.mod h1:bJcxlY2l9sLJmb6ELl/8/p5Nl3EmL2zMPGL329i4uAs=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec h1:2tTW6cDth2TSgRbAhD7yjZzTQmcN25sDRPEeinR51yQ=
Expand Down Expand Up @@ -1165,6 +1169,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
google.golang.org/api v0.188.0 h1:51y8fJ/b1AaaBRJr4yWm96fPcuxSo0JcegXE3DaHQHw=
google.golang.org/api v0.188.0/go.mod h1:VR0d+2SIiWOYG3r/jdm7adPW9hI2aRv9ETOSCQ9Beag=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
Expand Down Expand Up @@ -1258,6 +1264,8 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo=
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kustomize/api v0.17.1 h1:MYJBOP/yQ3/5tp4/sf6HiiMfNNyO97LmtnirH9SLNr4=
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/create/create_new_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package create

Check failure on line 1 in tests/e2e/create/create_new_test.go

View workflow job for this annotation

GitHub Actions / lint

package should be `create_test` instead of `create` (testpackage)
14 changes: 11 additions & 3 deletions tests/e2e/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/kyma-project/lifecycle-manager/api/v1beta2"
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc"
"gopkg.in/yaml.v3"
"k8s.io/apimachinery/pkg/util/yaml"

"github.com/kyma-project/lifecycle-manager/api/shared"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
Expand All @@ -28,6 +28,12 @@ const (
)

func Test_ModuleTemplate(t *testing.T) {
// TODO remove debugging env
//err := os.Setenv("OCI_REPOSITORY_URL", "http://k3d-oci.localhost:5001")

Check failure on line 32 in tests/e2e/create/create_test.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
//err = os.Setenv("TEST_REPOSITORY_URL", "https://github.com/lindnerby/template-operator.git")
//err = os.Setenv("MODULE_TEMPLATE_PATH", "/tmp/module-config-template.yaml")
//err = os.Setenv("MODULE_TEMPLATE_VERSION", "1.0.0")

ociRepoURL := os.Getenv("OCI_REPOSITORY_URL")
testRepoURL := os.Getenv("TEST_REPOSITORY_URL")
templatePath := os.Getenv("MODULE_TEMPLATE_PATH")
Expand Down Expand Up @@ -121,11 +127,13 @@ func Test_ModuleTemplate(t *testing.T) {
func readModuleTemplate(filepath string) (*v1beta2.ModuleTemplate, error) {
moduleTemplate := &v1beta2.ModuleTemplate{}
moduleFile, err := os.ReadFile(filepath)
if err != nil && len(moduleFile) > 0 {
return nil, err
}
err = yaml.Unmarshal(moduleFile, moduleTemplate)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(moduleFile, &moduleTemplate)

return moduleTemplate, err
}

Expand Down

0 comments on commit c6967c7

Please sign in to comment.