You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2021/03/23 03:28:38 UTC

[GitHub] [submarine] kevin85421 opened a new pull request #541: SUBMARINE-770. Create Submarine CRD & Test API generated by code-generator

kevin85421 opened a new pull request #541:
URL: https://github.com/apache/submarine/pull/541


   ### What is this PR for?
   This task aims to test API generated by code-generator. (SUBMARINE-768)
   To achieve this, we should follow the following steps
   
   Step1: Register Custom Resource Defintion (CRD) "Submarine"
   Step2: Create a Custom Resource for CRD Submarine
   Step3: Test API generated by code-generator.
   
   ### What type of PR is it?
   [Feature]
   
   ### Todos
   * Implement controller pattern
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/SUBMARINE-770
   
   ### How should this be tested?
   ```
   # Step0: Move to submarine-cloud-v2/
   
   # Step1: Register Custom Resource Definition
   kubectl apply -f artifacts/examples/crd.yaml
   
   # Step2: Create a Custom Resource
   kubectl apply -f artifacts/examples/example-submarine.yaml
   
   # Step3: Run unit test
   go test
   ```
   
   ### Screenshots (if appropriate)
   
   https://user-images.githubusercontent.com/20109646/112088423-c0d87d00-8bca-11eb-962a-19d7f13e3a49.mov
   
   
   
   ### Questions:
   * Does the licenses files need update? No
   * Is there breaking changes for older versions? No
   * Does this needs documentation? Yes
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] xunliu commented on a change in pull request #541: SUBMARINE-770. Create Submarine CRD & Test API generated by code-generator

Posted by GitBox <gi...@apache.org>.
xunliu commented on a change in pull request #541:
URL: https://github.com/apache/submarine/pull/541#discussion_r600286686



##########
File path: submarine-cloud-v2/main_test.go
##########
@@ -0,0 +1,68 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *    http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+package main
+
+import (
+    "context"
+	"submarine-cloud-v2/pkg/generated/clientset/versioned/typed/submarine/v1alpha1"
+	"fmt"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/client-go/tools/clientcmd"
+	"k8s.io/client-go/kubernetes"
+    "testing"
+    "reflect"
+)
+
+
+var (
+    namespace = "default"
+)
+
+func TestSubmarineClient(t *testing.T) {
+    ctx := context.Background()
+	config, e := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
+	if e != nil {
+		panic(e.Error())
+	}
+	client, e := v1alpha1.NewForConfig(config)
+    if e != nil {
+		panic(e.Error())
+	}
+    
+	submarineList, e := client.Submarines(namespace).List(ctx, metav1.ListOptions{})
+    if e != nil {
+		panic(e.Error())
+	}
+    fmt.Println(reflect.TypeOf(submarineList), e)    
+    // fmt.Println(submarineList, e)

Review comment:
       Code indentation needs to be formatted.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] asfgit closed pull request #541: SUBMARINE-770. Create Submarine CRD & Test API generated by code-generator

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #541:
URL: https://github.com/apache/submarine/pull/541


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] kevin85421 commented on a change in pull request #541: SUBMARINE-770. Create Submarine CRD & Test API generated by code-generator

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on a change in pull request #541:
URL: https://github.com/apache/submarine/pull/541#discussion_r600295033



##########
File path: submarine-cloud-v2/main_test.go
##########
@@ -0,0 +1,68 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *    http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+package main
+
+import (
+    "context"
+	"submarine-cloud-v2/pkg/generated/clientset/versioned/typed/submarine/v1alpha1"
+	"fmt"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/client-go/tools/clientcmd"
+	"k8s.io/client-go/kubernetes"
+    "testing"
+    "reflect"
+)
+
+
+var (
+    namespace = "default"
+)
+
+func TestSubmarineClient(t *testing.T) {
+    ctx := context.Background()
+	config, e := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
+	if e != nil {
+		panic(e.Error())
+	}
+	client, e := v1alpha1.NewForConfig(config)
+    if e != nil {
+		panic(e.Error())
+	}
+    
+	submarineList, e := client.Submarines(namespace).List(ctx, metav1.ListOptions{})
+    if e != nil {
+		panic(e.Error())
+	}
+    fmt.Println(reflect.TypeOf(submarineList), e)    
+    // fmt.Println(submarineList, e)

Review comment:
       Thank you for your recommendation! I have fixed it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org