Browse Source

修改逻辑

yjp 1 year ago
parent
commit
f739124d7d
2 changed files with 21 additions and 16 deletions
  1. 1 16
      demo/demo.go
  2. 20 0
      demo/resources.yaml

+ 1 - 16
demo/demo.go

@@ -17,17 +17,6 @@ const (
 )
 
 var (
-	dataSourceSpec = sdk.DataSourceDatabaseSpec{
-		Type:               sdk.DataSourceDatabaseTypePostgres,
-		UserName:           "test",
-		Password:           "123456",
-		Address:            "localhost",
-		Port:               "30432",
-		Database:           "test",
-		MaxConnections:     40,
-		MaxIdleConnections: 10,
-	}
-
 	dataContainerSpec = sdk.DataContainerDatabaseSpec{
 		TableName: "test.classes",
 		Columns: []sdk.DataContainerDatabaseColumnSpec{
@@ -70,11 +59,7 @@ func main() {
 	className2 := strutils.SimpleUUID()
 	studentNum2 := rand.Int31n(100)
 
-	err := sdk.InitInstance(token, baseUrl, namespace, &sdk.DataSourceOption{
-		Name: dataSource,
-		Type: sdk.DataSourceTypeDatabase,
-		Spec: dataSourceSpec.ToMap(),
-	})
+	err := sdk.InitInstance(token, baseUrl, namespace, dataSource)
 	if err != nil {
 		panic(err)
 	}

+ 20 - 0
demo/resources.yaml

@@ -0,0 +1,20 @@
+kind: Namespace
+spec:
+  name: ns-sdk-demo
+
+---
+
+kind: DataSource
+spec:
+  type: database
+  namespace: ns-sdk-demo
+  name: ds-sdk-demo
+  spec:
+    type: postgres
+    user_name: test
+    password: "123456"
+    address: localhost
+    port: "30432"
+    database: test
+    max_connections: 40
+    max_idle_connections: 10