Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename tokenrequest CR #1965

Merged
merged 7 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apis

import (
"github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/connectorservice/v1alpha1"
"github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/applicationconnector/v1alpha1"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package applicationconnector contains applicationconnector API versions
package applicationconnector
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Package v1alpha1 contains API Schema definitions for the applicationconnector v1alpha1 API group
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/applicationconnector
// +k8s:defaulter-gen=TypeMeta
// +groupName=applicationconnector.kyma-project.io
package v1alpha1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// NOTE: Boilerplate only. Ignore this file.

// Package v1alpha1 contains API Schema definitions for the connectorservice v1alpha1 API group
// Package v1alpha1 contains API Schema definitions for the applicationconnector v1alpha1 API group
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/connectorservice
// +k8s:conversion-gen=github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/applicationconnector
// +k8s:defaulter-gen=TypeMeta
// +groupName=connectorservice.kyma-project.io
// +groupName=applicationconnector.kyma-project.io
package v1alpha1

import (
Expand All @@ -15,7 +15,7 @@ import (

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "connectorservice.kyma-project.io", Version: "v1alpha1"}
SchemeGroupVersion = schema.GroupVersion{Group: "applicationconnector.kyma-project.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

connectorservicev1alpha1 "github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/connectorservice/v1alpha1"
applicationconnectorv1alpha1 "github.com/kyma-project/kyma/components/connection-token-handler/pkg/apis/applicationconnector/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -43,7 +43,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
return err
}

err = c.Watch(&source.Kind{Type: &connectorservicev1alpha1.TokenRequest{}}, &handler.EnqueueRequestForObject{})
err = c.Watch(&source.Kind{Type: &applicationconnectorv1alpha1.TokenRequest{}}, &handler.EnqueueRequestForObject{})
if err != nil {
return err
}
Expand All @@ -66,7 +66,7 @@ type ReconcileTokenRequest struct {
func (r *ReconcileTokenRequest) Reconcile(request reconcile.Request) (reconcile.Result, error) {
log.Printf("Processing TokenRequest %s", request.NamespacedName)

instance := &connectorservicev1alpha1.TokenRequest{}
instance := &applicationconnectorv1alpha1.TokenRequest{}
err := r.Get(context.TODO(), request.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
Expand All @@ -89,11 +89,11 @@ func (r *ReconcileTokenRequest) Reconcile(request reconcile.Request) (reconcile.
if err != nil {
log.Printf("Fetching token for TokenRequest %s failed", request.NamespacedName)

instance.Status.State = connectorservicev1alpha1.TokenRequestStateERR
instance.Status.State = applicationconnectorv1alpha1.TokenRequestStateERR
} else {
log.Printf("Token for TokenRequest %s fetched", request.NamespacedName)

instance.Status.State = connectorservicev1alpha1.TokenRequestStateOK
instance.Status.State = applicationconnectorv1alpha1.TokenRequestStateOK
instance.Status.Token = tokenDto.Token
instance.Status.URL = tokenDto.URL
instance.Status.ExpireAfter = metav1.NewTime(metav1.Now().Add(time.Second * time.Duration(r.options.TokenTTL)))
Expand All @@ -113,14 +113,14 @@ func (r *ReconcileTokenRequest) Reconcile(request reconcile.Request) (reconcile.
return reconcile.Result{}, nil
}

func (r *ReconcileTokenRequest) updateTokenRequest(tokenRequest *connectorservicev1alpha1.TokenRequest) error {
func (r *ReconcileTokenRequest) updateTokenRequest(tokenRequest *applicationconnectorv1alpha1.TokenRequest) error {
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
return r.Update(context.Background(), tokenRequest)

})
}

func (r *ReconcileTokenRequest) deleteTokenRequest(tokenRequest *connectorservicev1alpha1.TokenRequest) error {
func (r *ReconcileTokenRequest) deleteTokenRequest(tokenRequest *applicationconnectorv1alpha1.TokenRequest) error {
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
return r.Delete(context.TODO(), tokenRequest)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To get the configuration URL which allows you to fetch the required configuratio
- Create a TokenRequest CR. The CR name must match the name of the RE for which you want to get the configuration details. Run:
```
cat <<EOF | kubectl apply -f -
apiVersion: connectorservice.kyma-project.io/v1alpha1
apiVersion: applicationconnector.kyma-project.io/v1alpha1
kind: TokenRequest
metadata:
name: {RE_NAME}
Expand All @@ -27,13 +27,13 @@ To get the configuration URL which allows you to fetch the required configuratio

- Fetch the TokenRequest CR you created to get the configuration details from the **status** section. Run:
```
kubectl get tokenrequest.connectorservice.kyma-project.io {RE_NAME} -o yaml
kubectl get tokenrequest.applicationconnector.kyma-project.io {RE_NAME} -o yaml
```
>**NOTE:** If the response doesn't contain the **status** section, wait for a few moments and fetch the CR again.

A successful call returns the following response:
```
apiVersion: connectorservice.kyma-project.io/v1alpha1
apiVersion: applicationconnector.kyma-project.io/v1alpha1
kind: TokenRequest
metadata:
name: {RE_NAME}
Expand Down
6 changes: 3 additions & 3 deletions docs/application-connector/docs/060-cr-tokenrequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ title: TokenRequest
type: Custom Resource
---

The `tokenrequests.connectorservice.kyma-project.io` CustomResourceDefinition (CRD) is a detailed description of the kind of data and the format used to request token for RemoteEnvironment configuration URL from the Connector Service. To get the up-to-date CRD and show the output in the `yaml` format, run this command:
The `tokenrequests.applicationconnector.kyma-project.io` CustomResourceDefinition (CRD) is a detailed description of the kind of data and the format used to request token for RemoteEnvironment configuration URL from the Connector Service. To get the up-to-date CRD and show the output in the `yaml` format, run this command:

```
kubectl get crd tokenrequests.connectorservice.kyma-project.io -o yaml
kubectl get crd tokenrequests.applicationconnector.kyma-project.io -o yaml
```

## Sample custom resource

This is a sample custom resource (CR) which allows to get the configuration required to connect an external solution with a `test` Kyma Remote Environment.

```
apiVersion: connectorservice.kyma-project.io/v1alpha1
apiVersion: applicationconnector.kyma-project.io/v1alpha1
kind: TokenRequest
metadata:
name: test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: tokenrequests.connectorservice.kyma-project.io
name: tokenrequests.applicationconnector.kyma-project.io
spec:
group: connectorservice.kyma-project.io
group: applicationconnector.kyma-project.io
version: v1alpha1
names:
kind: TokenRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
release: {{ .Chart.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups: ["connectorservice.kyma-project.io"]
- apiGroups: ["applicationconnector.kyma-project.io"]
resources: ["tokenrequests"]
verbs: ["get", "list", "update", "delete", "watch"]
---
Expand Down
2 changes: 1 addition & 1 deletion resources/application-connector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ global:
version: PR-2005
connection_token_handler:
dir: pr/
version: PR-2005
version: PR-1965
sjanota marked this conversation as resolved.
Show resolved Hide resolved
event_service:
dir: develop/
version: 6e0a7fe2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ metadata:
annotations:
"helm.sh/hook-weight": "0"
rules:
- apiGroups: ["", "apps", "authentication.kyma-project.io", "connectorservice.kyma-project.io", "extensions", "gateway.kyma-project.io", "kubeless.io", "rbac.authorization.k8s.io", "applicationconnector.kyma-project.io", "servicecatalog.k8s.io", "servicecatalog.kyma.cx", "settings.k8s.io", "kyma.cx", "authentication.istio.io", "config.istio.io", "eventing.kyma-project.io", "ui.kyma.cx", "ui.kyma-project.io", "metrics.k8s.io", "networking.istio.io", "batch", "extensions", "autoscaling"]
- apiGroups: ["", "apps", "authentication.kyma-project.io", "extensions", "gateway.kyma-project.io", "kubeless.io", "rbac.authorization.k8s.io", "applicationconnector.kyma-project.io", "servicecatalog.k8s.io", "servicecatalog.kyma.cx", "settings.k8s.io", "kyma.cx", "authentication.istio.io", "config.istio.io", "eventing.kyma-project.io", "ui.kyma.cx", "ui.kyma-project.io", "metrics.k8s.io", "networking.istio.io", "batch", "extensions", "autoscaling"]
sjanota marked this conversation as resolved.
Show resolved Hide resolved
resources: ["*"]
verbs: ["*"]
- apiGroups: ["apiextensions.k8s.io"]
Expand Down