Skip to content

Commit

Permalink
Support for dashboard url (#152)
Browse files Browse the repository at this point in the history
* support for dashboard url

Signed-off-by: Mandana Vaziri <[email protected]>

* bug fix

Signed-off-by: Mandana Vaziri <[email protected]>
  • Loading branch information
vazirim authored Jun 18, 2020
1 parent 03815a7 commit c883801
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/crds/ibmcloud_v1alpha1_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ spec:
user:
type: string
type: object
dashboardURL:
type: string
externalName:
type: string
generation:
Expand Down
2 changes: 1 addition & 1 deletion hack/crd-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
sed -i.bak "71s/.*//" $SCRIPTDIR/../config/crds/ibmcloud_v1alpha1_service.yaml
sed -i.bak "141s/.*//" $SCRIPTDIR/../config/crds/ibmcloud_v1alpha1_service.yaml
sed -i.bak "143s/.*//" $SCRIPTDIR/../config/crds/ibmcloud_v1alpha1_service.yaml
sed -i.bak "54s/.*//" $SCRIPTDIR/../config/crds/ibmcloud_v1alpha1_binding.yaml


Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/ibmcloud/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type ServiceStatus struct {
Parameters []keyvaluev1.KeyValue `json:"parameters,omitempty"`
// +optional
Tags []string `json:"tags,omitempty"`
// +optional
DashboardURL string `json:"dashboardURL,omitempty"`
}

// +genclient
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/service/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ func (r *ReconcileService) updateStatus(instance *ibmcloudv1alpha1.Service, ibmC
instance.Status.State = state
instance.Status.Message = state
instance.Status.InstanceID = instanceID
instance.Status.DashboardURL = getDashboardURL(instance.Spec.ServiceClass, instanceID)
setStatusFieldsFromSpec(instance, ibmCloudInfo)
err := r.Status().Update(context.Background(), instance)
if err != nil {
Expand All @@ -477,6 +478,13 @@ func (r *ReconcileService) updateStatus(instance *ibmcloudv1alpha1.Service, ibmC
return reconcile.Result{Requeue: true, RequeueAfter: syncPeriod}, nil
}

func getDashboardURL(serviceClass, crn string) string {
url := "https://cloud.ibm.com/services/" + serviceClass + "/"
crn = strings.Replace(crn, ":", "%3A", -1)
crn = strings.Replace(crn, "/", "%2F", -1)
return url + crn
}

func getState(serviceInstanceState string) string {
if serviceInstanceState == "succeeded" || serviceInstanceState == "active" || serviceInstanceState == "provisioned" {
return "Online"
Expand Down

0 comments on commit c883801

Please sign in to comment.