-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for providing credentials for Cloud Native Buildpacks
Co-authored-by: Pavel Busko <pavel.busko@sap.com> Co-authored-by: Nicolas Bender <nicolas.bender@sap.com>
- Loading branch information
Showing
17 changed files
with
528 additions
and
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 | ||
} |
65 changes: 65 additions & 0 deletions
65
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,65 @@ | ||
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
Oops, something went wrong.