Skip to content

Commit

Permalink
Revert "Preserve backwards compatibility, for now" (#61)
Browse files Browse the repository at this point in the history
This reverts commit cf501e7.

Signed-off-by: Scott Andrews <andrewssc@vmware.com>
  • Loading branch information
scothis authored Sep 22, 2020
1 parent 52a093b commit 922ab98
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const (
ServiceBindingProjectionConditionApplicationAvailable = "ApplicationAvailable"

ServiceBindingRootEnv = "SERVICE_BINDING_ROOT"
// Deprecated: favor ServiceBindingRootEnv, this value will be removed in a
// future release
DeprecatedServiceBindingsRootEnv = "SERVICE_BINDINGS_ROOT"
)

var sbpCondSet = apis.NewLivingConditionSet(
Expand Down Expand Up @@ -111,29 +108,21 @@ func (b *ServiceBindingProjection) Do(ctx context.Context, ps *duckv1.WithPod) {

func (b *ServiceBindingProjection) doContainer(ctx context.Context, ps *duckv1.WithPod, c *corev1.Container, bindingVolume, secretName string) {
mountPath := ""
env := []corev1.EnvVar{}
// lookup predefined mount path
for _, e := range c.Env {
if e.Name == ServiceBindingRootEnv || e.Name == DeprecatedServiceBindingsRootEnv {
if e.Name == ServiceBindingRootEnv {
mountPath = e.Value
} else {
env = append(env, e)
break
}
}
if mountPath == "" {
// default mount path
mountPath = "/bindings"
}
c.Env = append(env,
corev1.EnvVar{
c.Env = append(c.Env, corev1.EnvVar{
Name: ServiceBindingRootEnv,
Value: mountPath,
},
corev1.EnvVar{
Name: DeprecatedServiceBindingsRootEnv,
Value: mountPath,
},
)
})
}

containerVolumes := sets.NewString()
for _, vm := range c.VolumeMounts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand All @@ -803,10 +799,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -884,10 +876,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand All @@ -907,10 +895,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -991,10 +975,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -1067,10 +1047,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{Name: "preserve"},
Expand Down Expand Up @@ -1145,86 +1121,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/custom/path",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/custom/path",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "binding-5c5a15a8b0b3e154d77746945e563ba40100681b",
MountPath: "/custom/path/my-binding-name",
ReadOnly: true,
},
},
},
},
Volumes: []corev1.Volume{
{
Name: "binding-5c5a15a8b0b3e154d77746945e563ba40100681b",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: "my-secret",
},
},
},
},
},
},
},
},
},
{
name: "inject volume at custom path, deprecated var",
binding: &ServiceBindingProjection{
ObjectMeta: metav1.ObjectMeta{
Name: "my-binding",
},
Spec: ServiceBindingProjectionSpec{
Name: "my-binding-name",
Binding: corev1.LocalObjectReference{
Name: "my-secret",
},
},
},
seed: &duckv1.WithPod{
Spec: duckv1.WithPodSpec{
Template: duckv1.PodSpecable{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Env: []corev1.EnvVar{
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/custom/path",
},
},
},
},
},
},
},
},
expected: &duckv1.WithPod{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"internal.service.binding/projection-16384e6a11df69776193b6a877b": "binding-5c5a15a8b0b3e154d77746945e563ba40100681b",
},
},
Spec: duckv1.WithPodSpec{
Template: duckv1.PodSpecable{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Env: []corev1.EnvVar{
{
Name: "SERVICE_BINDING_ROOT",
Value: "/custom/path",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/custom/path",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -1305,10 +1201,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
{
Name: "MY_VAR",
ValueFrom: &corev1.EnvVarSource{
Expand Down Expand Up @@ -1446,10 +1338,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down Expand Up @@ -1490,10 +1378,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand All @@ -1511,10 +1395,6 @@ func TestServiceBindingProjection_Do(t *testing.T) {
Name: "SERVICE_BINDING_ROOT",
Value: "/bindings",
},
{
Name: "SERVICE_BINDINGS_ROOT",
Value: "/bindings",
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/spring-petclinic/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
containers:
- name: application
# built with paketo builder from https://github.com/spring-projects/spring-petclinic
image: scothis/petclinic:service-bindings
image: scothis/petclinic:service-bindings-20200922
env:
# tell the application to use mysql instead of the default embedded database
- name: SPRING_PROFILES_ACTIVE
Expand Down

0 comments on commit 922ab98

Please sign in to comment.