From 296600d31ae3ad300c35d0d9eba457a35bdb8850 Mon Sep 17 00:00:00 2001 From: oshratz Date: Thu, 14 Nov 2024 13:27:59 +0200 Subject: [PATCH 1/5] Turn the signing key to be optional in RBC --- lifecycle/cli.go | 4 ---- lifecycle/cli_test.go | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lifecycle/cli.go b/lifecycle/cli.go index 92a7a5d0e..d45068b4e 100644 --- a/lifecycle/cli.go +++ b/lifecycle/cli.go @@ -127,10 +127,6 @@ func validateCreateReleaseBundleContext(c *cli.Context) error { return cliutils.WrongNumberOfArgumentsHandler(c) } - if err := assertSigningKeyProvided(c); err != nil { - return err - } - return assertValidCreationMethod(c) } diff --git a/lifecycle/cli_test.go b/lifecycle/cli_test.go index 65b911958..a09ac6e91 100644 --- a/lifecycle/cli_test.go +++ b/lifecycle/cli_test.go @@ -21,7 +21,7 @@ func TestValidateCreateReleaseBundleContext(t *testing.T) { {"extraArgs", []string{"one", "two", "three", "four"}, []string{}, true}, {"bothSources", []string{"one", "two", "three"}, []string{cliutils.Builds + "=/path/to/file", cliutils.ReleaseBundles + "=/path/to/file"}, true}, {"noSources", []string{"one", "two", "three"}, []string{}, true}, - {"builds without signing key", []string{"name", "version"}, []string{cliutils.Builds + "=/path/to/file"}, true}, + {"builds without signing key", []string{"name", "version"}, []string{cliutils.Builds + "=/path/to/file"}, false}, {"builds correct", []string{"name", "version"}, []string{ cliutils.Builds + "=/path/to/file", cliutils.SigningKey + "=key"}, false}, {"releaseBundles without signing key", []string{"name", "version", "env"}, []string{cliutils.ReleaseBundles + "=/path/to/file"}, true}, From 7ac19f5f3f1737448683a8c6d89af1a2da6bc769 Mon Sep 17 00:00:00 2001 From: oshratz Date: Thu, 14 Nov 2024 17:36:40 +0200 Subject: [PATCH 2/5] Turn the signing key to be optional in RBC --- lifecycle_test.go | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lifecycle_test.go b/lifecycle_test.go index 455f035d8..c566793e3 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -87,14 +87,18 @@ func compareRbArtifacts(t *testing.T, actual services.ReleaseBundleSpecResponse, } func TestReleaseBundleCreationFromAql(t *testing.T) { - testReleaseBundleCreation(t, tests.UploadDevSpecA, tests.LifecycleAql, tests.GetExpectedLifecycleCreationByAql()) + testReleaseBundleCreation(t, tests.UploadDevSpecA, tests.LifecycleAql, tests.GetExpectedLifecycleCreationByAql(), false) } func TestReleaseBundleCreationFromArtifacts(t *testing.T) { - testReleaseBundleCreation(t, tests.UploadDevSpec, tests.LifecycleArtifacts, tests.GetExpectedLifecycleCreationByArtifacts()) + testReleaseBundleCreation(t, tests.UploadDevSpec, tests.LifecycleArtifacts, tests.GetExpectedLifecycleCreationByArtifacts(), false) } -func testReleaseBundleCreation(t *testing.T, uploadSpec, creationSpec string, expected []string) { +func TestReleaseBundleCreationFromArtifactsWithoutSigningKey(t *testing.T) { + testReleaseBundleCreation(t, tests.UploadDevSpec, tests.LifecycleArtifacts, tests.GetExpectedLifecycleCreationByArtifacts(), true) +} + +func testReleaseBundleCreation(t *testing.T, uploadSpec, creationSpec string, expected []string, withoutKey bool) { cleanCallback := initLifecycleTest(t) defer cleanCallback() lcManager := getLcServiceManager(t) @@ -103,7 +107,7 @@ func testReleaseBundleCreation(t *testing.T, uploadSpec, creationSpec string, ex assert.NoError(t, err) runRt(t, "upload", "--spec="+specFile) - createRbFromSpec(t, creationSpec, tests.LcRbName1, number1, true) + createRbFromSpec(t, creationSpec, tests.LcRbName1, number1, true, withoutKey) defer deleteReleaseBundle(t, lcManager, tests.LcRbName1, number1) assertRbArtifacts(t, lcManager, tests.LcRbName1, number1, expected) @@ -119,17 +123,17 @@ func TestLifecycleFullFlow(t *testing.T) { defer deleteBuilds() // Create release bundle from builds synchronously. - createRbFromSpec(t, tests.LifecycleBuilds12, tests.LcRbName1, number1, true) + createRbFromSpec(t, tests.LifecycleBuilds12, tests.LcRbName1, number1, true, false) defer deleteReleaseBundle(t, lcManager, tests.LcRbName1, number1) // Create release bundle from a build asynchronously and assert status. // This build has dependencies which are included in the release bundle. - createRbFromSpec(t, tests.LifecycleBuilds3, tests.LcRbName2, number2, false) + createRbFromSpec(t, tests.LifecycleBuilds3, tests.LcRbName2, number2, false, false) defer deleteReleaseBundle(t, lcManager, tests.LcRbName2, number2) assertStatusCompleted(t, lcManager, tests.LcRbName2, number2, "") // Create a combined release bundle from the two previous release bundle. - createRbFromSpec(t, tests.LifecycleReleaseBundles, tests.LcRbName3, number3, true) + createRbFromSpec(t, tests.LifecycleReleaseBundles, tests.LcRbName3, number3, true, false) defer deleteReleaseBundle(t, lcManager, tests.LcRbName3, number3) // Promote the last release bundle to prod repo 1. @@ -195,23 +199,27 @@ func uploadBuilds(t *testing.T) func() { func createRbBackwardCompatible(t *testing.T, specName, sourceOption, rbName, rbVersion string, sync bool) { specFile, err := getSpecFile(specName) assert.NoError(t, err) - createRb(t, specFile, sourceOption, rbName, rbVersion, sync) + createRb(t, specFile, sourceOption, rbName, rbVersion, sync, false) } -func createRbFromSpec(t *testing.T, specName, rbName, rbVersion string, sync bool) { +func createRbFromSpec(t *testing.T, specName, rbName, rbVersion string, sync bool, withoutKey bool) { specFile, err := tests.CreateSpec(specName) assert.NoError(t, err) - createRb(t, specFile, "spec", rbName, rbVersion, sync) + createRb(t, specFile, "spec", rbName, rbVersion, sync, withoutKey) } -func createRb(t *testing.T, specFilePath, sourceOption, rbName, rbVersion string, sync bool) { +func createRb(t *testing.T, specFilePath, sourceOption, rbName, rbVersion string, sync bool, withoutKey bool) { argsAndOptions := []string{ "rbc", rbName, rbVersion, getOption(sourceOption, specFilePath), - getOption(cliutils.SigningKey, gpgKeyPairName), } + + if !withoutKey { + argsAndOptions = append(argsAndOptions, getOption(cliutils.SigningKey, gpgKeyPairName)) + } + // Add the --sync option only if requested, to test the default value. if sync { argsAndOptions = append(argsAndOptions, getOption(cliutils.Sync, "true")) From 7ecf2d443273317756830350f67e299ad0e4e556 Mon Sep 17 00:00:00 2001 From: oshratz Date: Sun, 17 Nov 2024 11:38:37 +0200 Subject: [PATCH 3/5] Turn the signing key to be optional in RBC --- lifecycle/cli_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lifecycle/cli_test.go b/lifecycle/cli_test.go index a09ac6e91..8f5aefe8b 100644 --- a/lifecycle/cli_test.go +++ b/lifecycle/cli_test.go @@ -24,7 +24,7 @@ func TestValidateCreateReleaseBundleContext(t *testing.T) { {"builds without signing key", []string{"name", "version"}, []string{cliutils.Builds + "=/path/to/file"}, false}, {"builds correct", []string{"name", "version"}, []string{ cliutils.Builds + "=/path/to/file", cliutils.SigningKey + "=key"}, false}, - {"releaseBundles without signing key", []string{"name", "version", "env"}, []string{cliutils.ReleaseBundles + "=/path/to/file"}, true}, + {"releaseBundles without signing key", []string{"name", "version"}, []string{cliutils.ReleaseBundles + "=/path/to/file"}, false}, {"releaseBundles correct", []string{"name", "version"}, []string{ cliutils.ReleaseBundles + "=/path/to/file", cliutils.SigningKey + "=key"}, false}, {"spec without signing key", []string{"name", "version", "env"}, []string{"spec=/path/to/file"}, true}, From f5041031ba8d454529f1ed18b915d192711fbb2a Mon Sep 17 00:00:00 2001 From: oshratz Date: Sun, 17 Nov 2024 13:57:54 +0200 Subject: [PATCH 4/5] Turn the signing key to be optional in RBP --- lifecycle/cli.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lifecycle/cli.go b/lifecycle/cli.go index 366ba25cf..ce0e32bbb 100644 --- a/lifecycle/cli.go +++ b/lifecycle/cli.go @@ -184,10 +184,6 @@ func promote(c *cli.Context) error { return cliutils.WrongNumberOfArgumentsHandler(c) } - if err := assertSigningKeyProvided(c); err != nil { - return err - } - lcDetails, err := createLifecycleDetailsByFlags(c) if err != nil { return err From 5c10b966da968d29ad8c20b31790fc1d4c095464 Mon Sep 17 00:00:00 2001 From: oshratz Date: Sun, 17 Nov 2024 13:57:54 +0200 Subject: [PATCH 5/5] Turn the signing key to be optional in RBP --- lifecycle/cli.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lifecycle/cli.go b/lifecycle/cli.go index ce0e32bbb..da6c3d7d7 100644 --- a/lifecycle/cli.go +++ b/lifecycle/cli.go @@ -350,13 +350,6 @@ func validateDistributeCommand(c *cli.Context) error { return nil } -func assertSigningKeyProvided(c *cli.Context) error { - if c.String(cliutils.SigningKey) == "" { - return errorutils.CheckErrorf("the --%s option is mandatory", cliutils.SigningKey) - } - return nil -} - func createLifecycleDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, error) { lcDetails, err := cliutils.CreateServerDetailsWithConfigOffer(c, true, commonCliUtils.Platform) if err != nil {