-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC0028] Support for Cloud Native Buildpacks lifecycle (#2871)
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com> Co-authored-by: Nicolas Bender <nicolas.bender@sap.com> Co-authored-by: Pavel Busko <pavel.busko@sap.com> Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com> Co-authored-by: Al Berez <al.berez@broadcom.com> Co-authored-by: João Pereira <joaopapereira@gmail.com>
- Loading branch information
1 parent
301073b
commit 0cc96f4
Showing
37 changed files
with
857 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package v7pushaction | ||
|
||
import ( | ||
"code.cloudfoundry.org/cli/command/translatableerror" | ||
"code.cloudfoundry.org/cli/util/manifestparser" | ||
) | ||
|
||
func HandleCNBCredentialsOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { | ||
if overrides.CNBCredentials != nil { | ||
if manifest.ContainsMultipleApps() { | ||
return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} | ||
} | ||
|
||
app := manifest.GetFirstApp() | ||
if app.RemainingManifestFields == nil { | ||
app.RemainingManifestFields = map[string]interface{}{} | ||
} | ||
|
||
app.RemainingManifestFields["cnb-credentials"] = overrides.CNBCredentials | ||
} | ||
|
||
return manifest, nil | ||
} |
66 changes: 66 additions & 0 deletions
66
actor/v7pushaction/handle_cnb_credentials_override_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package v7pushaction_test | ||
|
||
import ( | ||
. "code.cloudfoundry.org/cli/actor/v7pushaction" | ||
"code.cloudfoundry.org/cli/util/manifestparser" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("HandleCNBCredentialsOverride", func() { | ||
var ( | ||
originalManifest manifestparser.Manifest | ||
transformedManifest manifestparser.Manifest | ||
overrides FlagOverrides | ||
executeErr error | ||
) | ||
|
||
BeforeEach(func() { | ||
originalManifest = manifestparser.Manifest{ | ||
Applications: []manifestparser.Application{{}}, | ||
} | ||
overrides = FlagOverrides{} | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
transformedManifest, executeErr = HandleCNBCredentialsOverride(originalManifest, overrides) | ||
}) | ||
|
||
When("the cnb credentials are present", func() { | ||
BeforeEach(func() { | ||
overrides.CNBCredentials = map[string]interface{}{ | ||
"foo": "bar", | ||
} | ||
}) | ||
|
||
It("add it to the raw manifest", func() { | ||
Expect(executeErr).NotTo(HaveOccurred()) | ||
Expect(transformedManifest).To(Equal(manifestparser.Manifest{ | ||
Applications: []manifestparser.Application{{ | ||
RemainingManifestFields: map[string]interface{}{ | ||
"cnb-credentials": map[string]interface{}{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
}}, | ||
})) | ||
}) | ||
|
||
}) | ||
|
||
When("the credentials are not present", func() { | ||
BeforeEach(func() { | ||
overrides.CNBCredentials = nil | ||
}) | ||
|
||
It("does not add it to the raw manifest", func() { | ||
Expect(executeErr).NotTo(HaveOccurred()) | ||
Expect(transformedManifest).To(Equal(manifestparser.Manifest{ | ||
Applications: []manifestparser.Application{{}}, | ||
})) | ||
|
||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package v7pushaction | ||
|
||
import ( | ||
"code.cloudfoundry.org/cli/command/translatableerror" | ||
"code.cloudfoundry.org/cli/util/manifestparser" | ||
) | ||
|
||
func HandleLifecycleOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { | ||
if overrides.Lifecycle != "" { | ||
if manifest.ContainsMultipleApps() { | ||
return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} | ||
} | ||
|
||
app := manifest.GetFirstApp() | ||
app.Lifecycle = overrides.Lifecycle | ||
} | ||
|
||
return manifest, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.