diff --git a/.goreleaser.yml b/.goreleaser.yml index 1a170dbec..c9c7c4840 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -21,13 +21,13 @@ builds: - goos: darwin goarch: 386 archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + - id: foo + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} format_overrides: - goos: windows format: zip diff --git a/cmd/kyma/alpha/create/module/module.go b/cmd/kyma/alpha/create/module/module.go index 2dc5da8e8..18ed5d3ce 100644 --- a/cmd/kyma/alpha/create/module/module.go +++ b/cmd/kyma/alpha/create/module/module.go @@ -207,7 +207,7 @@ func (cmd *command) Run(ctx context.Context) error { cmd.NewStep("Adding layers to archive...") - if err := module.AddResources(archive, modDef, l, osFS); err != nil { + if err := module.AddResources(archive, modDef, l, osFS, cmd.opts.RegistryCredSelector); err != nil { cmd.CurrentStep.Failure() return err } @@ -264,7 +264,7 @@ func (cmd *command) Run(ctx context.Context) error { } cmd.NewStep("Generating module template") - t, err := module.Template(componentVersionAccess, cmd.opts.Channel, cmd.opts.Target, modDef.DefaultCR, cmd.opts.RegistryCredSelector) + t, err := module.Template(componentVersionAccess, cmd.opts.Channel, cmd.opts.Target, modDef.DefaultCR) if err != nil { cmd.CurrentStep.Failure() return err diff --git a/docs/gen-docs/kyma_deploy.md b/docs/gen-docs/kyma_deploy.md index 0b67cabca..9a49eb236 100644 --- a/docs/gen-docs/kyma_deploy.md +++ b/docs/gen-docs/kyma_deploy.md @@ -28,7 +28,7 @@ kyma deploy [flags] - Deploy a specific branch of the Kyma repository on kyma-project.org: "kyma deploy --source=" - Deploy a commit (8 characters or more), for example: "kyma deploy --source=34edf09a" - Deploy a pull request, for example "kyma deploy --source=PR-9486" - - Deploy the local sources: "kyma deploy --source=local" (default "2.13.0") + - Deploy the local sources: "kyma deploy --source=local" (default "2.13.1") -t, --timeout duration Maximum time for the deployment. (default 20m0s) --tls-crt string TLS certificate file for the domain used for installation. --tls-key string TLS key file for the domain used for installation. diff --git a/go.mod b/go.mod index 1967c486d..4ff8d0e60 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-logr/logr v1.2.3 github.com/go-logr/zapr v1.2.3 github.com/imdario/mergo v0.3.13 - github.com/kyma-incubator/reconciler v0.0.0-20230414081633-01086c789985 + github.com/kyma-incubator/reconciler v0.0.0-20230427062256-f255ae8d0053 github.com/kyma-project/hydroform/function v0.0.0-20230307104736-fc661e702543 github.com/kyma-project/hydroform/provision v0.0.0-20230418133637-1ea26b368bb6 github.com/kyma-project/lifecycle-manager v0.0.0-20230228084539-adc0e4a5f93a diff --git a/go.sum b/go.sum index 1b7f52373..5028b1861 100644 --- a/go.sum +++ b/go.sum @@ -1172,8 +1172,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= 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-incubator/reconciler v0.0.0-20230414081633-01086c789985 h1:P7dPx0nuYru8gv3hZmNsPS6tffbMyJGbk9W6Je5tukg= -github.com/kyma-incubator/reconciler v0.0.0-20230414081633-01086c789985/go.mod h1:Xgvl68xt2qKPKrzh73UbeHjmT4VdSNJPKXpozkMPUN0= +github.com/kyma-incubator/reconciler v0.0.0-20230427062256-f255ae8d0053 h1:w5U5uQFmsWXWYS+e/t8g7Ai/BNP9+FF2ToJ3jhWMb4Y= +github.com/kyma-incubator/reconciler v0.0.0-20230427062256-f255ae8d0053/go.mod h1:Xgvl68xt2qKPKrzh73UbeHjmT4VdSNJPKXpozkMPUN0= github.com/kyma-project/hydroform/function v0.0.0-20230307104736-fc661e702543 h1:7xCxCkLYwwcl1zrhu65YQ5LkHzZYiCcM1tYhC/vNQ00= github.com/kyma-project/hydroform/function v0.0.0-20230307104736-fc661e702543/go.mod h1:h6psCfFtd9Lo4AjiV2a9EYnG0yeNCR5TvSPbkZHL4qg= github.com/kyma-project/hydroform/provision v0.0.0-20230418133637-1ea26b368bb6 h1:k8TsRKhbYr+uQ1Glpbwii9kBqMPSFEZdMSov9KJjgiA= diff --git a/hack/release.sh b/hack/release.sh index 843c57ead..df8994643 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -17,16 +17,16 @@ delete_stable_tag() { get_new_release_version() { # get the list of tags in a reverse chronological order TAG_LIST=($(git tag --sort=-creatordate)) - NEW_RELEASE_VERSION=${TAG_LIST[0]} + export GORELEASER_CURRENT_TAG=${TAG_LIST[0]} } -get_current_release_version() { +get_previous_release_version() { # get the list of tags in a reverse chronological order excluding release candidate tags TAG_LIST_WITHOUT_RC=($(git tag --sort=-creatordate | grep -v -e "-rc")) if [[ $NEW_RELEASE_VERSION == *"-rc"* ]]; then - CURRENT_RELEASE_VERSION=${TAG_LIST_WITHOUT_RC[0]} + export GORELEASER_PREVIOUS_TAG=${TAG_LIST_WITHOUT_RC[0]} else - CURRENT_RELEASE_VERSION=${TAG_LIST_WITHOUT_RC[1]} + export GORELEASER_PREVIOUS_TAG=${TAG_LIST_WITHOUT_RC[1]} fi } @@ -34,9 +34,9 @@ main() { git remote add origin git@github.com:kyma-project/cli.git delete_stable_tag get_new_release_version - get_current_release_version + get_previous_release_version # release CLI with release notes generated by goreleaser - curl -sL https://git.io/goreleaser | VERSION=v1.11.4 bash -s -- + curl -sL https://git.io/goreleaser | VERSION=v1.17.2 bash -s -- } main diff --git a/internal/config/config.go b/internal/config/config.go index a61668241..425bd7cc7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -6,5 +6,5 @@ package config const ( - DefaultKyma2Version = "2.13.0" + DefaultKyma2Version = "2.13.1" ) diff --git a/pkg/module/resources.go b/pkg/module/resources.go index 27040302b..bde6ccdc3 100644 --- a/pkg/module/resources.go +++ b/pkg/module/resources.go @@ -1,6 +1,7 @@ package module import ( + "encoding/json" "fmt" "os" "path/filepath" @@ -13,12 +14,17 @@ import ( "github.com/mandelsoft/vfs/pkg/vfs" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" + ocmv1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" "github.com/pkg/errors" "go.uber.org/zap" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" ) +//nolint:gosec +const OCIRegistryCredLabel = "oci-registry-cred" + // ResourceDescriptor contains all information to describe a resource type ResourceDescriptor struct { compdesc.Resource @@ -33,10 +39,29 @@ type ResourceDescriptorList struct { // AddResources adds the resources in the given resource definitions into the archive and its FS. // A resource definition is a string with format: NAME:TYPE@PATH, where NAME and TYPE can be omitted and will default to the last path element name and "helm-chart" respectively func AddResources( - archive *comparch.ComponentArchive, modDef *Definition, log *zap.SugaredLogger, fs vfs.FileSystem, + archive *comparch.ComponentArchive, + modDef *Definition, + log *zap.SugaredLogger, + fs vfs.FileSystem, + registryCredSelector string, ) error { descriptor := archive.GetDescriptor() - resources, err := generateResources(log, modDef.Version, modDef.Layers...) + var matchLabels []byte + if registryCredSelector != "" { + selector, err := metav1.ParseToLabelSelector(registryCredSelector) + if err != nil { + return err + } + matchLabels, err = json.Marshal(selector.MatchLabels) + if err != nil { + return err + } + descriptor.SetLabels([]ocmv1.Label{{ + Name: OCIRegistryCredLabel, + Value: matchLabels, + }}) + } + resources, err := generateResources(log, modDef.Version, matchLabels, modDef.Layers...) if err != nil { return err } @@ -63,7 +88,7 @@ func AddResources( // generateResources generates resources by parsing the given definitions. // Definitions have the following format: NAME:TYPE@PATH // If a definition does not have a name or type, the name of the last path element is used and it is assumed to be a helm-chart type. -func generateResources(log *zap.SugaredLogger, version string, defs ...Layer) ([]ResourceDescriptor, error) { +func generateResources(log *zap.SugaredLogger, version string, credLabel []byte, defs ...Layer) ([]ResourceDescriptor, error) { res := []ResourceDescriptor{} for _, d := range defs { r := ResourceDescriptor{Input: &blob.Input{}} @@ -86,6 +111,13 @@ func generateResources(log *zap.SugaredLogger, version string, defs ...Layer) ([ r.Input.Type = "file" } + if len(credLabel) != 0 { + r.SetLabels([]ocmv1.Label{{ + Name: OCIRegistryCredLabel, + Value: credLabel, + }}) + } + log.Debugf("Generated resource:\n%s", r) res = append(res, r) } diff --git a/pkg/module/template.go b/pkg/module/template.go index 45ff1b0b0..9ed0ed8c2 100644 --- a/pkg/module/template.go +++ b/pkg/module/template.go @@ -2,7 +2,6 @@ package module import ( "bytes" - "encoding/json" "fmt" "strings" "text/template" @@ -10,8 +9,6 @@ import ( "github.com/kyma-project/cli/pkg/module/oci" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" - ocmv1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" ) @@ -33,38 +30,10 @@ spec: descriptor: {{yaml .Descriptor | printf "%s" | indent 4}} ` - - //nolint:gosec - OCIRegistryCredLabel = "oci-registry-cred" ) -func Template( - remote ocm.ComponentVersionAccess, channel, target string, data []byte, registryCredSelector string, -) ([]byte, error) { +func Template(remote ocm.ComponentVersionAccess, channel, target string, data []byte) ([]byte, error) { descriptor := remote.GetDescriptor() - if registryCredSelector != "" { - selector, err := metav1.ParseToLabelSelector(registryCredSelector) - if err != nil { - return nil, err - } - matchLabels, err := json.Marshal(selector.MatchLabels) - if err != nil { - return nil, err - } - descriptor.SetLabels([]ocmv1.Label{{ - Name: OCIRegistryCredLabel, - Value: matchLabels, - }}) - for i := range descriptor.Resources { - resource := &descriptor.Resources[i] - resource.SetLabels( - []ocmv1.Label{{ - Name: OCIRegistryCredLabel, - Value: matchLabels, - }}, - ) - } - } ref, err := oci.ParseRef(descriptor.Name) if err != nil { return nil, err