Skip to content

Commit

Permalink
Release 2.15.1 (#1691)
Browse files Browse the repository at this point in the history
* Handle optional serverless dependencies in cli (#1679)

* Handle optional serverless dependencies in cli

* Apply suggestions from code review

Co-authored-by: Filip Strózik <[email protected]>

* Bump hydroform

* fix linter

* fix linter again

---------

Co-authored-by: Filip Strózik <[email protected]>

* Bump reconciler lib for Istio 1.18 client update (#1682)

* bump reconciler (#1687)

* use newest reconciler (#1688)

* Release 2.15.1

---------

Co-authored-by: Krzysztof Kwiatosz <[email protected]>
Co-authored-by: Filip Strózik <[email protected]>
Co-authored-by: Vladimir Videlov <[email protected]>
Co-authored-by: Damian Badura <[email protected]>
  • Loading branch information
5 people authored Jun 27, 2023
1 parent 68c310d commit 336a28f
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 92 deletions.
90 changes: 54 additions & 36 deletions cmd/kyma/apply/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/kyma-project/cli/internal/cli"
"github.com/kyma-project/cli/internal/kube"
Expand All @@ -19,8 +18,11 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
)

type command struct {
Expand Down Expand Up @@ -103,32 +105,45 @@ func (c *command) Run() error {
return err
}

subscriptions, err := resources.NewSubscriptions(configuration)
if err != nil {
step.Failure()
return err
}
operators := []operator.Operator{}

kymaAddress, err := c.kymaHostAddress()
if err != nil {
step.LogErrorf("%s\n%s", err, "Check if your cluster is available and has Kyma installed.")
if len(configuration.Subscriptions) != 0 {

subscriptionGVR := operator.SubscriptionGVR(configuration.SchemaVersion)
err := isDependencyInstalled(client, subscriptionGVR)
if err != nil {
step.Failure()
return err
}

subscriptions, err := resources.NewSubscriptions(configuration)
if err != nil {
step.Failure()
return err
}
operators = append(operators, operator.NewSubscriptionOperator(client.Resource(subscriptionGVR).Namespace(configuration.Namespace),
configuration.Name, configuration.Namespace, subscriptions...))
}

apiRules, err := resources.NewAPIRule(configuration, kymaAddress)
if err != nil {
step.Failure()
return err
if len(configuration.APIRules) != 0 {

err := isDependencyInstalled(client, operator_types.GVRApiRule)
if err != nil {
step.Failure()
return err
}
apiRules, err := resources.NewAPIRule(configuration)
if err != nil {
step.Failure()
return err
}
operators = append(operators, operator.NewAPIRuleOperator(client.Resource(operator_types.GVRApiRule).Namespace(configuration.Namespace),
configuration.Name, apiRules...))
}

subscriptionGVR := operator.SubscriptionGVR(configuration.SchemaVersion)
mgr.AddParent(
operator.NewGenericOperator(client.Resource(operator_types.GVRFunction).Namespace(configuration.Namespace), function),
[]operator.Operator{
operator.NewSubscriptionOperator(client.Resource(subscriptionGVR).Namespace(configuration.Namespace),
configuration.Name, configuration.Namespace, subscriptions...),
operator.NewAPIRuleOperator(client.Resource(operator_types.GVRApiRule).Namespace(configuration.Namespace),
configuration.Name, apiRules...),
},
operators,
)

options := manager.Options{
Expand All @@ -150,21 +165,6 @@ func (c *command) Run() error {
return mgr.Do(ctx, options)
}

func (c *command) kymaHostAddress() (string, error) {
var url string
vs, err := c.K8s.Istio().NetworkingV1alpha3().Gateways("kyma-system").Get(context.Background(), "kyma-gateway", v1.GetOptions{})
switch {
case err != nil:
err = errors.Wrapf(err, "Unable to read the Kyma host URL due to error")
case vs != nil && len(vs.Spec.GetServers()) > 0 && len(vs.Spec.Servers[0].Hosts) > 0:
url = strings.TrimPrefix(vs.Spec.Servers[0].Hosts[0], "*.")
default:
err = errors.New("kyma host URL could not be obtained")
}

return url, err
}

const (
operatingFormat = "%s - %s operating... %s"
createdFormat = "%s - %s created %s"
Expand All @@ -187,6 +187,24 @@ func chooseOnError(onErr value) manager.OnError {
return manager.PurgeOnError
}

func isDependencyInstalled(client dynamic.Interface, dependencyCRD schema.GroupVersionResource) error {
crdGVR := schema.GroupVersionResource{
Group: "apiextensions.k8s.io",
Version: "v1",
Resource: "customresourcedefinitions",
}

_, err := client.Resource(crdGVR).Get(context.Background(), fmt.Sprintf("%s.%s", dependencyCRD.Resource, dependencyCRD.Group), metav1.GetOptions{})

if err != nil {
if k8sErrors.IsNotFound(err) {
return errors.Errorf("failed to apply %s. %s module is missing", dependencyCRD.Resource, dependencyCRD.Group)
}
return err
}
return nil
}

func (l *logger) chooseFormat(status client.StatusType) string {
switch status {
case client.StatusTypeCreated:
Expand Down
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kyma deploy [flags]
- Deploy a specific branch of the Kyma repository on kyma-project.org: "kyma deploy --source=<my-branch-name>"
- 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.15.0")
- Deploy the local sources: "kyma deploy --source=local" (default "2.15.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.
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ require (
github.com/docker/docker v20.10.24+incompatible
github.com/docker/go-connections v0.4.0
github.com/fatih/color v1.14.1
github.com/go-git/go-git/v5 v5.5.2
github.com/go-git/go-git/v5 v5.7.0
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.3
github.com/imdario/mergo v0.3.13
github.com/kyma-incubator/reconciler v0.0.0-20230427062256-f255ae8d0053
github.com/kyma-project/hydroform/function v0.0.0-20230511065356-7c87adf20e49
github.com/imdario/mergo v0.3.15
github.com/kyma-incubator/reconciler v0.0.0-20230622145557-b23e244ca299
github.com/kyma-project/hydroform/function v0.0.0-20230607080739-8cda607c4599
github.com/kyma-project/hydroform/provision v0.0.0-20230418133637-1ea26b368bb6
github.com/kyma-project/lifecycle-manager v0.0.0-20230515084114-0cd8e8e80748
github.com/mandelsoft/vfs v0.0.0-20220805210647-bf14a11bfe31
Expand Down Expand Up @@ -71,8 +71,8 @@ require (
github.com/Masterminds/squirrel v1.5.3 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/hcsshim v0.9.7 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aws/aws-sdk-go-v2 v1.17.1 // indirect
Expand Down Expand Up @@ -129,8 +129,8 @@ require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-cmd/cmd v1.4.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.4.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand Down Expand Up @@ -217,7 +217,7 @@ require (
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/pjbgf/sha1cd v0.2.3 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
Expand All @@ -229,7 +229,7 @@ require (
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/skeema/knownhosts v1.1.0 // indirect
github.com/skeema/knownhosts v1.1.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -254,14 +254,14 @@ require (
go.starlark.net v0.0.0-20230128213706-3f75dec8e403 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand Down
Loading

0 comments on commit 336a28f

Please sign in to comment.