-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* List Servicebindings from SBO only * Support both implementations * Integration tests (TBC) * Human readable output * Support --name flag * Reference doc * fix * self review * Check for InjectionReady condition before to get bindings * Fix comments * Remove unnecessary error returned value * Display info when status is unknown * Sections in doc * Review
- Loading branch information
Showing
19 changed files
with
1,387 additions
and
36 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
docs/website/versioned_docs/version-3.0.0/command-reference/describe-binding.md
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,107 @@ | ||
--- | ||
title: odo describe binding | ||
--- | ||
|
||
## Description | ||
|
||
`odo describe binding` command is useful for getting information about service bindings. | ||
|
||
This command supports the service bindings added with the command `odo add binding` and bindings added manually to the Devfile, using a `ServiceBinding` resource from one of these apiVersion: | ||
- `binding.operators.coreos.com/v1alpha1` | ||
- `servicebinding.io/v1alpha3` | ||
|
||
## Running the Command | ||
|
||
There are 2 ways to describe a service binding: | ||
- [Describe with access to Devfile](#describe-with-access-to-devfile) | ||
- [Describe without access to Devfile](#describe-without-access-to-devfile) | ||
|
||
### Describe with access to Devfile | ||
|
||
This command returns information extracted from the Devfile and, if possible, from the cluster. | ||
|
||
The command lists the Kubernetes resources declared in the Devfile as a Kubernetes component, | ||
with the kind `ServiceBinding` and one of these apiVersion: | ||
- `binding.operators.coreos.com/v1alpha1` | ||
- `servicebinding.io/v1alpha3` | ||
|
||
For each of these resources, the following information is displayed: | ||
- the resource name, | ||
- the list of the services to which the component is bound using this service binding, | ||
- if the variables are bound as files or as environment variables, | ||
- if the binding information is auto-detected. | ||
|
||
When the service binding are not deployed yet to the cluster: | ||
|
||
```shell | ||
$ odo describe binding | ||
ServiceBinding used by the current component: | ||
|
||
Service Binding Name: my-nodejs-app-cluster-sample | ||
Services: | ||
• cluster-sample (Cluster.postgresql.k8s.enterprisedb.io) | ||
Bind as files: false | ||
Detect binding resources: true | ||
Available binding information: unknown | ||
|
||
Service Binding Name: my-nodejs-app-redis-standalone | ||
Services: | ||
• redis-standalone (Redis.redis.redis.opstreelabs.in) | ||
Bind as files: false | ||
Detect binding resources: true | ||
Available binding information: unknown | ||
|
||
Binding information for one or more ServiceBinding is not available because they don't exist on the cluster yet. | ||
Start "odo dev" first to see binding information. | ||
``` | ||
When the resources have been deployed to the cluster, the command also extracts information from the status of the resources to display information about the variables that can be used from the component. | ||
```shell | ||
$ odo describe binding | ||
ServiceBinding used by the current component: | ||
Service Binding Name: my-nodejs-app-cluster-sample-2 | ||
Services: | ||
• cluster-sample-2 (Cluster.postgresql.k8s.enterprisedb.io) | ||
Bind as files: false | ||
Detect binding resources: true | ||
Available binding information: | ||
• CLUSTER_PASSWORD | ||
• CLUSTER_PROVIDER | ||
• CLUSTER_TLS.CRT | ||
• CLUSTER_TLS.KEY | ||
• CLUSTER_USERNAME | ||
• CLUSTER_CA.KEY | ||
• CLUSTER_CLUSTERIP | ||
• CLUSTER_HOST | ||
• CLUSTER_PGPASS | ||
• CLUSTER_TYPE | ||
• CLUSTER_CA.CRT | ||
• CLUSTER_DATABASE | ||
Service Binding Name: my-nodejs-app-redis-standalone | ||
Services: | ||
• redis-standalone (Redis.redis.redis.opstreelabs.in) | ||
Bind as files: false | ||
Detect binding resources: true | ||
Available binding information: | ||
• REDIS_CLUSTERIP | ||
• REDIS_HOST | ||
• REDIS_PASSWORD | ||
• REDIS_TYPE | ||
``` | ||
### Describe without access to Devfile | ||
```shell | ||
odo describe binding --name <component_name> | ||
``` | ||
The command extracts information from the cluster. | ||
The command searches for a resource in the current namespace with the given name, the kind `ServiceBinding` and one of these apiVersion: | ||
- `binding.operators.coreos.com/v1alpha1` | ||
- `servicebinding.io/v1alpha3` | ||
If a resource is found, it displays information about the service binding and the variables that can be used from the component. |
2 changes: 1 addition & 1 deletion
2
...rsion-3.0.0/command-reference/describe.md → ...0/command-reference/describe-component.md
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,63 @@ | ||
package api | ||
|
||
import ( | ||
bindingApi "github.com/redhat-developer/service-binding-operator/apis/binding/v1alpha1" | ||
specApi "github.com/redhat-developer/service-binding-operator/apis/spec/v1alpha3" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// ServiceBinding describes a service binding, from group binding.operators.coreos.com/v1alpha1 or servicebinding.io/v1alpha3 | ||
type ServiceBinding struct { | ||
Name string `json:"name"` | ||
Spec ServiceBindingSpec `json:"spec"` | ||
Status *ServiceBindingStatus `json:"status,omitempty"` | ||
} | ||
|
||
type ServiceBindingSpec struct { | ||
Services []specApi.ServiceBindingServiceReference `json:"services"` | ||
DetectBindingResources bool `json:"detectBindingResources"` | ||
BindAsFiles bool `json:"bindAsFiles"` | ||
} | ||
|
||
type ServiceBindingStatus struct { | ||
BindingFiles []string `json:"bindingsFiles,omitempty"` | ||
BindingEnvVars []string `json:"bindingEnvVars,omitempty"` | ||
} | ||
|
||
// ServiceBindingFromBinding returns a common api.ServiceBinding structure | ||
// from a ServiceBinding.binding.operators.coreos.com/v1alpha1 | ||
func ServiceBindingFromBinding(binding bindingApi.ServiceBinding) ServiceBinding { | ||
|
||
var dstSvcs []specApi.ServiceBindingServiceReference | ||
for _, srcSvc := range binding.Spec.Services { | ||
dstSvc := specApi.ServiceBindingServiceReference{ | ||
Name: srcSvc.Name, | ||
} | ||
dstSvc.APIVersion, dstSvc.Kind = schema.GroupVersion{ | ||
Group: srcSvc.Group, | ||
Version: srcSvc.Version, | ||
}.WithKind(srcSvc.Kind).ToAPIVersionAndKind() | ||
dstSvcs = append(dstSvcs, dstSvc) | ||
} | ||
return ServiceBinding{ | ||
Name: binding.Name, | ||
Spec: ServiceBindingSpec{ | ||
Services: dstSvcs, | ||
DetectBindingResources: binding.Spec.DetectBindingResources, | ||
BindAsFiles: binding.Spec.BindAsFiles, | ||
}, | ||
} | ||
} | ||
|
||
// ServiceBindingFromSpec returns a common api.ServiceBinding structure | ||
// from a ServiceBinding.servicebinding.io/v1alpha3 | ||
func ServiceBindingFromSpec(spec specApi.ServiceBinding) ServiceBinding { | ||
return ServiceBinding{ | ||
Name: spec.Name, | ||
Spec: ServiceBindingSpec{ | ||
Services: []specApi.ServiceBindingServiceReference{spec.Spec.Service}, | ||
DetectBindingResources: false, | ||
BindAsFiles: true, | ||
}, | ||
} | ||
} |
Oops, something went wrong.