Skip to content

Commit

Permalink
release 2.19.2 (#1818)
Browse files Browse the repository at this point in the history
* cleanup serverless chart config (#1798)

* test: CLI E2E tests with template operator (#1792)

* Setup e2e tests action

* Forcing an empty commit.

* Add go file + make target

* add Run E2E tests step

* add e2e test

* refactor existing E2E tests

* remove redundant step in e2e yaml

* trigger the pipeline

* editing go file to trigger pipeline

* fix yaml file

* remove unneeded expect statement

* some fixes

* some fixes

* add suite_test.go

* ginkgo bootstrap

* add e2e_suite_test

* remove unnecessary log

* fixes

* fixes

* start test implementation

* disable running e2e from

* create module test changes

* exclude e2e from test target

* kyma alpha deploy

* fix

* Forcing an empty commit.

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Increase timeout

* fix

* fix

* fix

* fixes

* fixes

* fix

* Reduce timeout

* fixes

* fixes

* fixes

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* enable module

* enable module

* stop running create module command for the rest of the e2e

* stop running create module command for the rest of the e2e

* debug

* validate resources after enablement

* fix linting

* debugging

* debugging

* debugging

* debugging

* fixes

* fixes

* uncomment and add module name

* print kyma.status.modules

* add v1extensions scheme

* increase timeout

* debugging

* debugging

* revert module creation test

* fix linting

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* disable module

* add new template-operator

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix linting

* remove unneeded env variables

* remove unneeded env variables

* debug error

* debug error

* debug error

* fixes

* Oleksandr's comments

* fix test

* remove

* fix test

* fix test

* comment 1

* Oleksandr's PR comments

* fix

* fix

* fix

* fix

* Rephrase the Describe

* Oleksandr's comments

* Xin's comments

* Oleksandr's comments

* flatten

* fix linting

* fixes

* fixes

* fixes

* fix create module

* remove duplicate targets

* Forcing an empty commit.

* Xin's comment

* Xin's comment

* fix status

* fix status

* fix status

* fix status

* comment

* remove unneeded consts

* fix: Error out if create module is executed with an existing version without the overwrite flag (#1797)

* Setup e2e tests action

* Forcing an empty commit.

* Add go file + make target

* add Run E2E tests step

* add e2e test

* refactor existing E2E tests

* remove redundant step in e2e yaml

* trigger the pipeline

* editing go file to trigger pipeline

* fix yaml file

* remove unneeded expect statement

* some fixes

* some fixes

* add suite_test.go

* ginkgo bootstrap

* add e2e_suite_test

* remove unnecessary log

* fixes

* fixes

* start test implementation

* disable running e2e from

* create module test changes

* exclude e2e from test target

* kyma alpha deploy

* fix

* Forcing an empty commit.

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Increase timeout

* fix

* fix

* fix

* fixes

* fixes

* fix

* Reduce timeout

* fixes

* fixes

* fixes

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* debug error

* enable module

* enable module

* stop running create module command for the rest of the e2e

* stop running create module command for the rest of the e2e

* debug

* validate resources after enablement

* fix linting

* debugging

* debugging

* debugging

* debugging

* fixes

* fixes

* uncomment and add module name

* print kyma.status.modules

* add v1extensions scheme

* increase timeout

* debugging

* debugging

* revert module creation test

* fix linting

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* disable module

* add new template-operator

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* fix linting

* remove unneeded env variables

* remove unneeded env variables

* debug error

* debug error

* debug error

* fixes

* Oleksandr's comments

* fix test

* remove

* fix test

* fix test

* comment 1

* Oleksandr's PR comments

* fix

* fix

* fix

* fix

* fix implementation

* Add e2e test

* fix test

* fix

* fix

* debug test

* fix linting

* debuggging

* Rephrase the Describe

* Oleksandr's comments

* debug test

* debug test

* debug test

* fix target

* fix error message

* fix: Add module version annotation to the ModuleTemplate (#1799)

* add test

* Addressing test comment

* PR comments

* enhance message (#1801)

* feat: Add refactor title type (#1803)

* remove custom multierror. use join on one fix occurence (#1802)

* chore: Fix some CLI checkmarx issues (#1807)

* Add some error handling

* More error handling for regex

* Condest reconciler call

* Add default status

* bump golang.org/x/net (#1815)

* fix(checkmarx): Fix unhandled errors (#1813)

* Fix unhandled errors

* APlly review comments

* fix misspelling

* update kyma to 2.19.2

---------

Co-authored-by: Damian Badura <[email protected]>
Co-authored-by: Nesma Badr <[email protected]>
Co-authored-by: Benjamin Lindner <[email protected]>
Co-authored-by: Jeremy Harisch <[email protected]>
  • Loading branch information
5 people authored Oct 26, 2023
1 parent e6880da commit b9a7465
Show file tree
Hide file tree
Showing 34 changed files with 928 additions and 345 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint-conventional-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
deps
chore
deps
docs
feat
fix
refactor
test
requireScope: false
# https://regex101.com/r/YybDgS/1
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/test-e2e-create-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
e2e:
strategy:
matrix:
e2e-test: [ "create_module_kubebuilder_project", "create_module_module_config"]
e2e-test: [ "test-kubebuilder-module-creation", "test-moduleconfig-module-creation",
"test-same-version-module-creation"]
name: "Run E2E tests"
runs-on: ubuntu-latest
env:
Expand All @@ -33,7 +34,7 @@ jobs:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Build Kyma CLI
run: |
run: |
make resolve validate build-linux
chmod +x ./bin/kyma-linux
ls -la ./bin
Expand All @@ -54,7 +55,7 @@ jobs:
run: |
k3d registry create oci.localhost --port 5001
- name: Run create module with kubebuilder-project
if: ${{ matrix.e2e-test == 'create_module_kubebuilder_project' }}
if: ${{ matrix.e2e-test == 'test-kubebuilder-module-creation' }}
run: |
kyma alpha create module \
--name kyma-project.io/module/template-operator \
Expand All @@ -67,7 +68,7 @@ jobs:
--sec-scanners-config ./template-operator/sec-scanners-config.yaml
echo "MODULE_TEMPLATE_PATH=/tmp/kubebuilder-template.yaml" >> "$GITHUB_ENV"
- name: Run create module with module-config
if: ${{ matrix.e2e-test == 'create_module_module_config' }}
if: ${{ matrix.e2e-test == 'test-moduleconfig-module-creation' || matrix.e2e-test == 'test-same-version-module-creation'}}
run: |
cd ./template-operator
make build-manifests
Expand All @@ -81,6 +82,12 @@ jobs:
--output /tmp/module-config-template.yaml
echo "MODULE_TEMPLATE_PATH=/tmp/module-config-template.yaml" >> "$GITHUB_ENV"
- name: Verify module template
if: ${{ matrix.e2e-test == 'test-moduleconfig-module-creation' || matrix.e2e-test == 'test-kubebuilder-module-creation'}}
run: |
echo $MODULE_TEMPLATE_PATH
make -C tests/e2e test-module-creation
- name: Run E2E tests
if: ${{ matrix.e2e-test == 'test-same-version-module-creation'}}
run: |
echo $MODULE_TEMPLATE_PATH
make -C tests/e2e ${{ matrix.e2e-test }}
make -C tests/e2e test-same-version-module-creation
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TestSuite Smoke
name: TestSuite E2E

on:
push:
Expand All @@ -14,20 +14,22 @@ on:
- 'go.sum'
- '**.go'
jobs:
cli-deploy:
name: "kyma deploy"
e2e-tests:
name: "Run E2E tests"
runs-on: ubuntu-latest
env:
LIFECYCLE_MANAGER: ${{ github.repository }}
K3D_VERSION: v5.4.7
steps:
- name: Checkout
- name: Checkout Kyma CLI
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Set up kubectl
uses: azure/setup-kubectl@v3
id: install
- name: Build Kyma CLI
run: |
make resolve validate build-linux
Expand All @@ -48,5 +50,5 @@ jobs:
--name kyma
- name: Update Kubeconfigs
run: k3d kubeconfig merge -a -d
- name: Run kyma deploy
run: kyma --ci alpha deploy
- name: Run E2E tests
run: make -C tests/e2e test-module-enabling-disabling
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ docs:

.PHONY: test
test:
go test -race -coverprofile=cover.out ./...
go test `go list ./... | grep -v /tests/e2e` -race -coverprofile=cover.out
@echo "Total test coverage: $$(go tool cover -func=cover.out | grep total | awk '{print $$3}')"
@rm cover.out

Expand Down
61 changes: 40 additions & 21 deletions cmd/kyma/alpha/create/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"context"
"errors"
"fmt"
"maps"
"os"
"path/filepath"
"strings"

"github.com/kyma-project/lifecycle-manager/api/v1beta2"
"github.com/mandelsoft/vfs/pkg/memoryfs"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"
Expand All @@ -16,7 +18,6 @@ import (
"github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch"
"github.com/spf13/cobra"
"go.uber.org/zap"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"

Expand Down Expand Up @@ -382,29 +383,9 @@ func (cmd *command) Run(ctx context.Context) error {

cmd.NewStep("Generating module template")

labels := map[string]string{}
annotations := map[string]string{}

var resourceName = ""

if modCnf != nil {
resourceName = modCnf.ResourceName

maps.Copy(labels, modCnf.Labels)
maps.Copy(annotations, modCnf.Annotations)

if modCnf.Beta {
labels["operator.kyma-project.io/beta"] = "true"
}
if modCnf.Internal {
labels["operator.kyma-project.io/internal"] = "true"
}
}
isClusterScoped := isCrdClusterScoped(crValidator.GetCrd())
if isClusterScoped {
annotations["operator.kyma-project.io/is-cluster-scoped"] = "true"
} else {
annotations["operator.kyma-project.io/is-cluster-scoped"] = "false"
}

var channel = cmd.opts.Channel
Expand All @@ -417,6 +398,9 @@ func (cmd *command) Run(ctx context.Context) error {
namespace = modCnf.Namespace
}

labels := cmd.getModuleTemplateLabels(modCnf)
annotations := cmd.getModuleTemplateAnnotations(modCnf, crValidator)

t, err := module.Template(componentVersionAccess, resourceName, namespace,
channel, modDef.DefaultCR, labels, annotations, modDef.CustomStateChecks)

Expand All @@ -435,6 +419,41 @@ func (cmd *command) Run(ctx context.Context) error {
return nil
}

func (cmd *command) getModuleTemplateLabels(modCnf *Config) map[string]string {
labels := map[string]string{}
if modCnf != nil {
maps.Copy(labels, modCnf.Labels)

if modCnf.Beta {
labels[v1beta2.BetaLabel] = v1beta2.EnableLabelValue
}
if modCnf.Internal {
labels[v1beta2.InternalLabel] = v1beta2.EnableLabelValue
}
}

return labels
}

func (cmd *command) getModuleTemplateAnnotations(modCnf *Config, crValidator validator) map[string]string {
annotations := map[string]string{}
moduleVersion := cmd.opts.Version
if modCnf != nil {
maps.Copy(annotations, modCnf.Annotations)

moduleVersion = modCnf.Version
}

isClusterScoped := isCrdClusterScoped(crValidator.GetCrd())
if isClusterScoped {
annotations[v1beta2.IsClusterScopedAnnotation] = v1beta2.EnableLabelValue
} else {
annotations[v1beta2.IsClusterScopedAnnotation] = v1beta2.DisableLabelValue
}
annotations["operator.kyma-project.io/module-version"] = moduleVersion
return annotations
}

func (cmd *command) validateDefaultCR(ctx context.Context, modDef *module.Definition, l *zap.SugaredLogger) (validator, error) {
cmd.NewStep("Validating Default CR")

Expand Down
162 changes: 162 additions & 0 deletions cmd/kyma/alpha/create/module/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package module

import (
_ "embed"
"reflect"
"testing"

"github.com/kyma-project/cli/internal/cli"
"github.com/kyma-project/cli/pkg/module"
"github.com/kyma-project/lifecycle-manager/api/v1beta2"
)

//go:embed testdata/clusterScopedCRD.yaml
Expand Down Expand Up @@ -43,3 +48,160 @@ func Test_isCrdClusterScoped(t *testing.T) {
})
}
}

func Test_command_getModuleTemplateLabels(t *testing.T) {
type fields struct {
Command cli.Command
opts *Options
}
type args struct {
modCnf *Config
}
tests := []struct {
name string
fields fields
args args
want map[string]string
}{
{
name: "beta module with moduleConfig labels set",
fields: fields{
opts: &Options{},
},
args: args{
modCnf: &Config{
Beta: true,
Labels: map[string]string{
"label1": "value1",
"label2": "value2",
},
Version: "1.1.1",
},
},
want: map[string]string{
"label1": "value1",
"label2": "value2",
v1beta2.BetaLabel: v1beta2.EnableLabelValue,
},
},
{
name: "internal module",
fields: fields{
opts: &Options{},
},
args: args{
modCnf: &Config{
Internal: true,
Version: "1.1.1",
},
},
want: map[string]string{
v1beta2.InternalLabel: v1beta2.EnableLabelValue,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := &command{
Command: tt.fields.Command,
opts: tt.fields.opts,
}
if got := cmd.getModuleTemplateLabels(tt.args.modCnf); !reflect.DeepEqual(got, tt.want) {
t.Errorf("getModuleTemplateLabels() = %v, want %v", got, tt.want)
}
})
}
}

func Test_command_getModuleTemplateAnnotations(t *testing.T) {
type fields struct {
Command cli.Command
opts *Options
}
type args struct {
modCnf *Config
crValidator validator
}
tests := []struct {
name string
fields fields
args args
want map[string]string
}{
{
name: "module with moduleConfig annotations set",
fields: fields{
opts: &Options{},
},
args: args{
modCnf: &Config{
Internal: true,
Annotations: map[string]string{
"annotation1": "value1",
"annotation2": "value2",
},
Version: "1.1.1",
},
crValidator: &module.SingleManifestFileCRValidator{
Crd: namespacedScopedCrd,
},
},
want: map[string]string{
"annotation1": "value1",
"annotation2": "value2",
"operator.kyma-project.io/module-version": "1.1.1",
v1beta2.IsClusterScopedAnnotation: v1beta2.DisableLabelValue,
},
},
{
name: "cluster scoped module with moduleConfig annotations set",
fields: fields{
opts: &Options{},
},
args: args{
modCnf: &Config{
Annotations: map[string]string{
"annotation1": "value1",
"annotation2": "value2",
},
Version: "1.1.1",
},
crValidator: &module.SingleManifestFileCRValidator{
Crd: clusterScopedCrd,
},
},
want: map[string]string{
"annotation1": "value1",
"annotation2": "value2",
v1beta2.IsClusterScopedAnnotation: v1beta2.EnableLabelValue,
"operator.kyma-project.io/module-version": "1.1.1",
},
},
{
name: "module versions set from version flag",
fields: fields{
opts: &Options{Version: "1.0.0"},
},
args: args{
crValidator: &module.SingleManifestFileCRValidator{
Crd: namespacedScopedCrd,
},
},
want: map[string]string{
"operator.kyma-project.io/module-version": "1.0.0",
v1beta2.IsClusterScopedAnnotation: v1beta2.DisableLabelValue,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := &command{
Command: tt.fields.Command,
opts: tt.fields.opts,
}
if got := cmd.getModuleTemplateAnnotations(tt.args.modCnf, tt.args.crValidator); !reflect.DeepEqual(got, tt.want) {
t.Errorf("getModuleTemplateAnnotations() = %v, want %v", got, tt.want)
}
})
}
}
Loading

0 comments on commit b9a7465

Please sign in to comment.