Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Cherry-pick minor fixes from main #2098

Merged
merged 31 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f255322
chore(dependabot): bump k8s.io/api from 0.29.1 to 0.29.2 (#1955)
dependabot[bot] Feb 19, 2024
3595f28
chore(dependabot): bump github.com/opencontainers/image-spec (#1954)
dependabot[bot] Feb 19, 2024
37bd3e0
chore(deps): bump the go_modules group across 1 directories with 1 up…
dependabot[bot] Feb 19, 2024
2985452
chore(dependabot): bump k8s.io/cli-runtime from 0.29.1 to 0.29.2 (#1953)
dependabot[bot] Feb 19, 2024
94d76df
chore(dependabot): bump sigs.k8s.io/controller-runtime (#1952)
dependabot[bot] Feb 19, 2024
ca3bbd4
chore(dependabot): bump github.com/mandelsoft/vfs from 0.4.0 to 0.4.1…
dependabot[bot] Feb 20, 2024
a2c5d96
chore(dependabot): bump k8s.io/apiextensions-apiserver (#1957)
dependabot[bot] Feb 20, 2024
9febec2
chore(dependabot): bump go.uber.org/zap from 1.26.0 to 1.27.0 (#1961)
dependabot[bot] Feb 22, 2024
a7ec3c7
chore(dependabot): bump helm.sh/helm/v3 from 3.14.1 to 3.14.2 (#1965)
dependabot[bot] Feb 23, 2024
5e7708f
chore(dependabot): bump github.com/mandelsoft/vfs from 0.4.1 to 0.4.3…
dependabot[bot] Feb 26, 2024
b909931
chore: Bump `ocm` dependency to `v0.7.0` (#1971)
c-pius Feb 29, 2024
d866891
Update CODEOWNERS (#1974)
janmedrek Mar 1, 2024
360c6bd
chore: Add Python 3.12 environment (#1976)
halamix2 Mar 6, 2024
9960ced
chore: Deprecate Python39 environment (#1983)
halamix2 Mar 6, 2024
8a83d9b
chore: Remove Nodejs16 environment (#1985)
halamix2 Mar 7, 2024
8e2e31a
chore: Add Nodejs20 environment (#1982)
halamix2 Mar 14, 2024
1d55a25
Bump hydroform (#1998)
MichalKalke Mar 15, 2024
b75fdd5
Bump Hydroform functions (#2000)
kwiatekus Mar 15, 2024
7a27762
chore: Deprecate Nodejs18 environment (#2005)
halamix2 Mar 19, 2024
0a543e1
fix: Security config ignored (#2003)
Tomasz-Smelcerz-SAP Mar 19, 2024
2ebfebd
chore: Make Nodejs20 default runtime (#2006)
halamix2 Mar 20, 2024
bdf1b0e
chore(dependabot): bump github.com/stretchr/testify from 1.8.4 to 1.9…
dependabot[bot] Apr 11, 2024
f1fc24d
chore(dependabot): bump github.com/onsi/ginkgo/v2 from 2.15.0 to 2.17…
dependabot[bot] Apr 11, 2024
3eabb7d
chore(dependabot): bump helm.sh/helm/v3 from 3.14.2 to 3.14.4 (#2038)
dependabot[bot] May 2, 2024
3ed8c8a
chore(dependabot): bump github.com/containerd/containerd (#2060)
dependabot[bot] May 2, 2024
c293cce
chore(deps): bump the go_modules group across 1 directory with 5 upda…
dependabot[bot] May 2, 2024
2873657
chore(dependabot): bump istio.io/client-go from 1.20.2 to 1.21.2 (#2077)
dependabot[bot] May 14, 2024
0f2c343
chore(dependabot): bump github.com/onsi/gomega from 1.31.1 to 1.33.1 …
dependabot[bot] May 14, 2024
de10035
chore(dependabot): bump sigs.k8s.io/kustomize/kyaml (#2081)
dependabot[bot] May 14, 2024
680e770
chore(dependabot): bump github.com/onsi/ginkgo/v2 from 2.17.1 to 2.17…
dependabot[bot] May 14, 2024
476e55b
chore(dependabot): bump github.com/go-git/go-git/v5 (#2088)
dependabot[bot] May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# These are the default owners for the whole content of the repository. The default owners are automatically added as reviewers when you open a pull request, unless different owners are specified in the file.
* @kyma-project/jellyfish
* @kyma-project/otters

# All .md files
*.md @kyma-project/technical-writers

# serverless related commands
cmd/kyma/init @kyma-project/otters
cmd/kyma/sync @kyma-project/otters
cmd/kyma/apply @kyma-project/otters
cmd/kyma/apply @kyma-project/otters
37 changes: 29 additions & 8 deletions cmd/kyma/alpha/create/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import (
"github.com/kyma-project/cli/pkg/module"
)

const (
kcpSystemNamespace = "kcp-system"
securityConfigFlagName = "sec-scanners-config"
)

type command struct {
cli.Command
opts *Options
Expand Down Expand Up @@ -113,7 +118,7 @@ Build a Kubebuilder module my-domain/modC in version 3.2.1 and push it to a loca
kyma alpha create module --name my-domain/modC --version 3.2.1 --path /path/to/module --registry http://localhost:5001/unsigned --insecure

`,
RunE: func(cobraCmd *cobra.Command, args []string) error { return c.Run() },
RunE: func(cobraCmd *cobra.Command, args []string) error { return c.Run(cobraCmd) },
Aliases: []string{"mod"},
}

Expand Down Expand Up @@ -181,7 +186,7 @@ Build a Kubebuilder module my-domain/modC in version 3.2.1 and push it to a loca
cmd.Flags().BoolVar(&o.Insecure, "insecure", false, "Uses an insecure connection to access the registry.")

cmd.Flags().StringVar(
&o.SecurityScanConfig, "sec-scanners-config", "sec-scanners-config.yaml", "Path to the file holding "+
&o.SecurityScanConfig, securityConfigFlagName, "sec-scanners-config.yaml", "Path to the file holding "+
"the security scan configuration.",
)

Expand Down Expand Up @@ -225,9 +230,7 @@ func configureLegacyFlags(cmd *cobra.Command, o *Options) *cobra.Command {
return cmd
}

const kcpSystemNamespace = "kcp-system"

func (cmd *command) Run() error {
func (cmd *command) Run(cobraCmd *cobra.Command) error {
osFS := osfs.New()

if cmd.opts.CI {
Expand Down Expand Up @@ -319,10 +322,23 @@ func (cmd *command) Run() error {
}

// Security Scan
if cmd.opts.SecurityScanConfig != "" && gitPath != "" { // security scan is only supported for target git repositories
var securityScanConfigFile = ""

// if the flag is explicitly set, use it
if cmd.isSecurityConfigFlagDefined(cobraCmd) {
securityScanConfigFile = cmd.opts.SecurityScanConfig
} else if modCnf != nil && modCnf.Security != "" {
fPath, err := resolveFilePath(modCnf.Security, cmd.opts.Path)
//Supress the error to keep the existing contract: The non-existing file is ignored and the security scan is skipped
if err == nil {
securityScanConfigFile = fPath
}
}

if securityScanConfigFile != "" && gitPath != "" { // security scan is only supported for target git repositories
cmd.NewStep("Configuring security scanning...")
if files.IsFileExists(cmd.opts.SecurityScanConfig) {
err = module.AddSecurityScanningMetadata(componentDescriptor, cmd.opts.SecurityScanConfig)
if files.IsFileExists(securityScanConfigFile) {
err = module.AddSecurityScanningMetadata(componentDescriptor, securityScanConfigFile)
if err != nil {
cmd.CurrentStep.Failure()
return err
Expand Down Expand Up @@ -592,6 +608,11 @@ func (cmd *command) avoidUserInteraction() bool {
return cmd.NonInteractive || cmd.CI
}

// isSecurityConfigFlagDefined returns true if the "sec-scanners-config" flag is set explicitly on the command line
func (cmd *command) isSecurityConfigFlagDefined(cobraCmd *cobra.Command) bool {
return cobraCmd.Flags().Lookup(securityConfigFlagName).Changed
}

// resolvePath resolves given path if it's absolute or uses the provided prefix to make it absolute.
// Returns an error if the path does not exist or is a directory.
func resolveFilePath(given, absolutePrefix string) (string, error) {
Expand Down
12 changes: 7 additions & 5 deletions cmd/kyma/init/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import (
)

const (
defaultRuntime = "nodejs18"
defaultRuntime = "nodejs20"
defaultReference = "main"
defaultBaseDir = "/"
)

var (
deprecatedRuntimes = map[string]struct{}{
"nodejs16": {},
"nodejs18": {},
"python39": {},
}
)

Expand Down Expand Up @@ -55,9 +56,10 @@ Use the flags to specify the initial configuration for your Function or to choos
cmd.Flags().StringVarP(
&o.Runtime, "runtime", "r", defaultRuntime,
`Flag used to define the environment for running your Function. Use one of these options:
- nodejs16 (deprecated)
- nodejs18
- python39`,
- nodejs18 (deprecated)
- nodejs20
- python39 (deprecated)
- python312`,
)
cmd.Flags().StringVar(&o.SchemaVersion, "schema-version", string(workspace.SchemaVersionDefault), `Version of the config API.`)

Expand Down
6 changes: 3 additions & 3 deletions cmd/kyma/init/function/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestFunctionFlags(t *testing.T) {
require.Equal(t, "", o.Name, "Default value for the --name flag not as expected.")
require.Equal(t, "", o.Namespace, "Default value for the --namespace flag not as expected.")
require.Equal(t, "", o.Dir, "Default value for the --dir flag not as expected.")
require.Equal(t, "nodejs18", o.Runtime, "Default value for the --runtime flag not as expected.")
require.Equal(t, "nodejs20", o.Runtime, "Default value for the --runtime flag not as expected.")
require.Equal(t, "", o.RuntimeImageOverride, "The parsed value for the --runtime-image-override flag not as expected.")
require.Equal(t, "", o.URL, "The parsed value for the --url flag not as expected.")
require.Equal(t, "", o.RepositoryName, "The parsed value for the --repository-name flag not as expected.")
Expand All @@ -31,7 +31,7 @@ func TestFunctionFlags(t *testing.T) {
"--name", "test-name",
"--namespace", "test-namespace",
"--runtime-image-override", "runtime-image-override",
"--runtime", "python39",
"--runtime", "python312",
"--url", "test-url",
"--repository-name", "test-repository-name",
"--reference", "test-reference",
Expand All @@ -42,7 +42,7 @@ func TestFunctionFlags(t *testing.T) {
require.Equal(t, "/fakepath", o.Dir, "The parsed value for the --dir flag not as expected.")
require.Equal(t, "test-name", o.Name, "The parsed value for the --name flag not as expected.")
require.Equal(t, "test-namespace", o.Namespace, "The parsed value for the --namespace flag not as expected.")
require.Equal(t, "python39", o.Runtime, "The parsed value for the --runtime flag not as expected.")
require.Equal(t, "python312", o.Runtime, "The parsed value for the --runtime flag not as expected.")
require.Equal(t, "runtime-image-override", o.RuntimeImageOverride, "The parsed value for the --runtime-image-override flag not as expected.")
require.Equal(t, "test-url", o.URL, "The parsed value for the --url flag not as expected.")
require.Equal(t, "test-repository-name", o.RepositoryName, "The parsed value for the --repository-name flag not as expected.")
Expand Down
7 changes: 4 additions & 3 deletions cmd/kyma/run/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ func (c *command) workspaceConfig(path string) (workspace.Cfg, error) {
}

supportedRuntimes := map[string]struct{}{
"nodejs16": {},
"nodejs18": {},
"python39": {},
"nodejs18": {},
"nodejs20": {},
"python39": {},
"python312": {},
}
if _, ok := supportedRuntimes[cfg.Runtime]; !ok {
return workspace.Cfg{}, fmt.Errorf("unsupported runtime: %s", cfg.Runtime)
Expand Down
7 changes: 4 additions & 3 deletions docs/gen-docs/kyma_init_function.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ kyma init function [flags]
--reference string Commit hash or branch name (default "main")
--repository-name string The name of the Git repository to be created
-r, --runtime string Flag used to define the environment for running your Function. Use one of these options:
- nodejs16 (deprecated)
- nodejs18
- python39 (default "nodejs18")
- nodejs18 (deprecated)
- nodejs20
- python39 (deprecated)
- python312 (default "nodejs20")
--runtime-image-override string Set custom runtime image base.
--schema-version string Version of the config API. (default "v0")
--url string Git repository URL
Expand Down
Loading
Loading