Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

SBO design direction with multiple services support #286

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7a96082
Improving .editorconfig file.
otaviof Dec 16, 2019
38c9014
BackingServiceSelectors.
otaviof Dec 16, 2019
3eb18cb
Refactoring SBR validation.
otaviof Dec 16, 2019
3fcc2a7
Embed GroupVersionKind in BackingServiceSelector and other cleanups
isutton Dec 18, 2019
dedc3e3
Merge remote-tracking branch 'origin/master' into isutton/APPSVC-305
isutton Dec 18, 2019
953d7d0
Refactor Reconciler and friends to simplify the code
isutton Dec 19, 2019
f5b5664
Add TypeMeta information in SBR mock
isutton Dec 19, 2019
495ddfc
Mark yaml encoding to inline GroupVersionKind
isutton Dec 19, 2019
5802800
Split Reconciiler into Reconciler and BindingManager
isutton Dec 30, 2019
c106db9
Add found bool return value
isutton Dec 30, 2019
54edba9
Client is required
isutton Dec 30, 2019
5384087
Move types and constant like vars to the top
isutton Dec 30, 2019
cd49930
Validate options in BuildBindingManager
isutton Dec 30, 2019
e838a17
Rename local variable
isutton Dec 30, 2019
c04eaa9
Reword field documentation
isutton Dec 31, 2019
8ae4ff9
Organize imports
isutton Dec 31, 2019
e642982
Adjust APIs to handle multiple related CRs
isutton Dec 31, 2019
7923e8a
Group CRD and CR into RelatedResources
isutton Dec 31, 2019
ca56e23
Reorder method definitions
isutton Jan 1, 2020
cbe927e
Rename BindingManager to ServiceBinder
isutton Jan 1, 2020
a280ee9
Return CR after adding it to known objects
isutton Jan 1, 2020
7b11f10
Return unstructured Deployment
isutton Jan 1, 2020
cc3cb7a
Fix an issue where selector could be empty, leading to a nil element …
isutton Jan 2, 2020
35a37e5
Change return type to expose actions collected by FakeDynamicClient
isutton Jan 2, 2020
0344b4b
Convert v1.ConfigMap to Unstructured before adding it to test fixtures
isutton Jan 2, 2020
296c544
Implement ServiceBinder bind tests
isutton Jan 2, 2020
bd1d3ed
Add support for multiple backing services
isutton Jan 3, 2020
dcc69cd
Fixes go mod invalid pseudo-version error
Jan 14, 2020
e75305c
Extracts RelatedResources type to its own file
Jan 14, 2020
bc35d12
Extract methods to their own files
Jan 14, 2020
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
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ indent_size = 4

max_line_length = 101

[*.yml,*.yaml,*.toml]
[*.yml]
indent_size = 2

[*.yaml]
indent_size = 2

[*.toml]
indent_size = 2

[*.md]
Expand Down
232 changes: 232 additions & 0 deletions deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: servicebindingrequests.apps.openshift.io
spec:
group: apps.openshift.io
names:
kind: ServiceBindingRequest
listKind: ServiceBindingRequestList
plural: servicebindingrequests
shortNames:
- sbr
- sbrs
singular: servicebindingrequest
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ServiceBindingRequest is the Schema for the servicebindings API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ServiceBindingRequestSpec defines the desired state of ServiceBindingRequest
properties:
applicationSelector:
description: ApplicationSelector is used to identify the application
connecting to the backing service operator.
properties:
group:
type: string
matchLabels:
additionalProperties:
type: string
type: object
resource:
type: string
resourceRef:
type: string
version:
type: string
required:
- matchLabels
- resource
- resourceRef
- version
type: object
backingServiceSelector:
description: BackingServiceSelector is used to identify the backing
service operator.
properties:
group:
type: string
kind:
type: string
resourceRef:
type: string
version:
type: string
required:
- group
- kind
- resourceRef
- version
type: object
backingServiceSelectors:
description: BackingServiceSelectors is an slice of BackingServiceSelector
items:
description: BackingServiceSelector defines the selector based on
resource name, version, and resource kind
properties:
group:
type: string
kind:
type: string
resourceRef:
type: string
version:
type: string
required:
- group
- kind
- resourceRef
- version
type: object
type: array
customEnvVar:
description: Custom env variables
items:
description: EnvVar represents an environment variable present in
a Container.
properties:
name:
description: Name of the environment variable. Must be a C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded using
the previous defined environment variables in the container
and any service environment variables. If a variable cannot
be resolved, the reference in the input string will be unchanged.
The $(VAR_NAME) syntax can be escaped with a double $$, ie:
$$(VAR_NAME). Escaped references will never be expanded, regardless
of whether the variable exists or not. Defaults to "".'
type: string
valueFrom:
description: Source for the environment variable's value. Cannot
be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or its key
must be defined
type: boolean
required:
- key
type: object
fieldRef:
description: 'Selects a field of the pod: supports metadata.name,
metadata.namespace, metadata.labels, metadata.annotations,
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP.'
properties:
apiVersion:
description: Version of the schema the FieldPath is written
in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in the specified
API version.
type: string
required:
- fieldPath
type: object
resourceFieldRef:
description: 'Selects a resource of the container: only resources
limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage,
requests.cpu, requests.memory and requests.ephemeral-storage)
are currently supported.'
properties:
containerName:
description: 'Container name: required for volumes, optional
for env vars'
type: string
divisor:
description: Specifies the output format of the exposed
resources, defaults to "1"
type: string
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
secretKeyRef:
description: Selects a key of a secret in the pod's namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
type: object
required:
- name
type: object
type: array
detectBindingResources:
description: DetectBindingResources is flag used to bind all non-bindable
variables from different subresources owned by backing operator CR.
type: boolean
envVarPrefix:
description: EnvVarPrefix is the prefix for environment variables
type: string
mountPathPrefix:
description: MountPathPrefix is the prefix for volume mount
type: string
required:
- applicationSelector
- backingServiceSelector
- backingServiceSelectors
type: object
status:
description: ServiceBindingRequestStatus defines the observed state of ServiceBindingRequest
properties:
applicationObjects:
description: ApplicationObjects contains all the application objects
filtered by label
items:
type: string
type: array
bindingStatus:
description: BindingStatus is the status of the service binding request.
type: string
secret:
description: Secret is the name of the intermediate secret
type: string
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ github.com/operator-framework/operator-registry v1.0.1/go.mod h1:1xEdZjjUg2hPEd5
github.com/operator-framework/operator-registry v1.0.4/go.mod h1:hve6YwcjM2nGVlscLtNsp9sIIBkNZo6jlJgzWw7vP9s=
github.com/operator-framework/operator-registry v1.1.1/go.mod h1:7D4WEwL+EKti5npUh4/u64DQhawCBRugp8Ql20duUb4=
github.com/operator-framework/operator-sdk v0.8.2-0.20190522220659-031d71ef8154/go.mod h1:iVyukRkam5JZa8AnjYf+/G3rk7JI1+M6GsU0sq0B9NA=
github.com/operator-framework/operator-sdk v0.12.0 h1:9eAD1L8e6pPCpFCAacBUVf2eloDkRuVm29GTCOktLqQ=
github.com/operator-framework/operator-sdk v0.12.0 h1:aD4qPbSAbZgRj1jFdFLq/dBI4P4aKX8d4rJowyQtTYM=
github.com/operator-framework/operator-sdk v0.12.0/go.mod h1:mW8isQxiXlLCVf2E+xqflkQAVLOTbiqjndKdkKIrR0M=
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
Expand All @@ -28,6 +29,9 @@ type ServiceBindingRequestSpec struct {
// BackingServiceSelector is used to identify the backing service operator.
BackingServiceSelector BackingServiceSelector `json:"backingServiceSelector"`

// BackingServiceSelectors is used to identify multiple backing services.
BackingServiceSelectors []BackingServiceSelector `json:"backingServiceSelectors"`

// ApplicationSelector is used to identify the application connecting to the
// backing service operator.
ApplicationSelector ApplicationSelector `json:"applicationSelector"`
Expand All @@ -52,10 +56,8 @@ type ServiceBindingRequestStatus struct {
// BackingServiceSelector defines the selector based on resource name, version, and resource kind
// +k8s:openapi-gen=true
type BackingServiceSelector struct {
Group string `json:"group"`
Version string `json:"version"`
Kind string `json:"kind"`
ResourceRef string `json:"resourceRef"`
schema.GroupVersionKind `json:",inline" yaml:",inline"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this change in a separate PR merge it first?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure if Igor is ok with it

ResourceRef string `json:"resourceRef"`
}

// ApplicationSelector defines the selector based on labels and GVR
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion pkg/apis/apps/v1alpha1/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ func schema_pkg_apis_apps_v1alpha1_ServiceBindingRequestSpec(ref common.Referenc
Ref: ref("github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1.BackingServiceSelector"),
},
},
"backingServiceSelectors": {
SchemaProps: spec.SchemaProps{
Description: "BackingServiceSelectors is an slice of BackingServiceSelector",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1.BackingServiceSelector"),
},
},
},
},
},
"applicationSelector": {
SchemaProps: spec.SchemaProps{
Description: "ApplicationSelector is used to identify the application connecting to the backing service operator.",
Expand All @@ -207,7 +220,7 @@ func schema_pkg_apis_apps_v1alpha1_ServiceBindingRequestSpec(ref common.Referenc
},
},
},
Required: []string{"backingServiceSelector", "applicationSelector"},
Required: []string{"backingServiceSelector", "backingServiceSelectors", "applicationSelector"},
},
},
Dependencies: []string{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package servicebindingrequest

import (
"github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"

"github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
)

var (
Expand Down
Loading