浏览代码

修改脚本

yjp 1 年之前
父节点
当前提交
6d3a04837c

+ 4 - 0
go.mod

@@ -14,6 +14,7 @@ require (
 
 require (
 	git.sxidc.com/service-supports/fserr v0.3.5 // indirect
+	git.sxidc.com/service-supports/websocket v1.3.1 // indirect
 	github.com/Masterminds/goutils v1.1.1 // indirect
 	github.com/Masterminds/semver/v3 v3.2.0 // indirect
 	github.com/Masterminds/sprig/v3 v3.2.3 // indirect
@@ -34,6 +35,7 @@ require (
 	github.com/gogo/protobuf v1.3.0 // indirect
 	github.com/golang/protobuf v1.5.4 // indirect
 	github.com/google/uuid v1.6.0 // indirect
+	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/huandu/xstrings v1.3.3 // indirect
 	github.com/iancoleman/strcase v0.3.0 // indirect
 	github.com/imdario/mergo v0.3.11 // indirect
@@ -51,7 +53,9 @@ require (
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/mwitkow/go-proto-validators v0.3.2 // indirect
+	github.com/olahol/melody v1.2.1 // indirect
 	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/puzpuzpuz/xsync v1.5.2 // indirect
 	github.com/satori/go.uuid v1.2.0 // indirect

+ 10 - 2
go.sum

@@ -1,5 +1,5 @@
-git.sxidc.com/go-framework/baize v0.4.1 h1:bU6e+IXlpwxkMf1YS0MTMrNetwRX9mfpeBTbKP2bfXY=
-git.sxidc.com/go-framework/baize v0.4.1/go.mod h1:Izm9F1neCVNcERNaMHXV5bDVYCS07WpMIGwwk43e5t0=
+git.sxidc.com/go-framework/baize v0.6.0 h1:zoSjgNZAvQa2+CUqE7xVcDrpqJU2ALq8K3RSm7BM3ic=
+git.sxidc.com/go-framework/baize v0.6.0/go.mod h1:l4L9/s9V+HplttyhTjfaqAGxqv44fglq4wSxacpUQpk=
 git.sxidc.com/go-tools/utils v1.5.15 h1:7xs/EM8XZyKycrSSHcPZ6wvyYs+v8uWQ7ZmPP/fHyFI=
 git.sxidc.com/go-tools/utils v1.5.15/go.mod h1:fkobAXFpOMTvkZ82TQXWcpsayePcyk/MS5TN6GTlRDg=
 git.sxidc.com/service-supports/fserr v0.3.5 h1:1SDC60r3FIDd2iRq/oHRLK4OMa1gf67h9B7kierKTUE=
@@ -8,6 +8,8 @@ git.sxidc.com/service-supports/fslog v0.5.9 h1:q2XIK2o/fk/qmByy4x5kKLC+k7kolT5Lr
 git.sxidc.com/service-supports/fslog v0.5.9/go.mod h1:/m03ATmmOle75qtEgvEw8a1+Dcg6iHp08M1bGFXJTBU=
 git.sxidc.com/service-supports/scm-sdk v0.1.0 h1:198qs/XxffOrHioKEWXyPfsQLoO3E8Ifj4idOWJxIe0=
 git.sxidc.com/service-supports/scm-sdk v0.1.0/go.mod h1:F0DLFok92zElZZRxJujSk6KmRoVGN8bkrbXFdq19uwI=
+git.sxidc.com/service-supports/websocket v1.3.1 h1:1mRfUwvpg0QA2JVKVMK8YJ/B33HFpDhY9srqroIuNGc=
+git.sxidc.com/service-supports/websocket v1.3.1/go.mod h1:YqEZXkN8ZFzUp01tDlekgIJJ0Yz+67d6eTXyA0ZIkgM=
 github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
 github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
 github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
@@ -58,6 +60,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
 github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
+github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
+github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
 github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
 github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
@@ -103,8 +107,12 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
 github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 github.com/mwitkow/go-proto-validators v0.3.2 h1:qRlmpTzm2pstMKKzTdvwPCF5QfBNURSlAgN/R+qbKos=
 github.com/mwitkow/go-proto-validators v0.3.2/go.mod h1:ej0Qp0qMgHN/KtDyUt+Q1/tA7a5VarXUOUxD+oeD30w=
+github.com/olahol/melody v1.2.1 h1:xdwRkzHxf+B0w4TKbGpUSSkV516ZucQZJIWLztOWICQ=
+github.com/olahol/melody v1.2.1/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
 github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
 github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/puzpuzpuz/xsync v1.5.2 h1:yRAP4wqSOZG+/4pxJ08fPTwrfL0IzE/LKQ/cw509qGY=

+ 0 - 10
server/deployment/data_service/apply_data_containers.sh

@@ -1,10 +0,0 @@
-#!/bin/bash
-cd "$(dirname "$0")" || exit 1
-
-datactl apply -f base.yaml
-
-for file in ./data_containers/*; do
-	if [ -f "$file" ]; then
-		datactl apply -f "$file"
-	fi
-done

+ 0 - 20
server/deployment/data_service/base.yaml

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

+ 4 - 2
server/deployment/data_service/apply_data_containers.ps1 → server/deployment/data_service/create_data_containers.ps1

@@ -1,9 +1,11 @@
 Set-Location  $(Split-Path $MyInvocation.MyCommand.Path -Parent)
 
-datactl.exe apply -f base.yaml
+Param (
+    [string]$DatabaseName
+)
 
 foreach ($file in $(Get-ChildItem -Path ".\data_containers")) {
     if ($file.GetType() -eq [System.IO.FileInfo]) {
-        datactl.exe apply -f $file.FullName
+        datactl.exe offline database create_dc $DatabaseName -f $file.FullName
     }
 }

+ 13 - 0
server/deployment/data_service/create_data_containers.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+cd "$(dirname "$0")" || exit 1
+
+if [ "$#" -ne 1 ]; then
+    echo "Usage: $0 database_name"
+    exit 1
+fi
+
+for file in ./data_containers/*; do
+	if [ -f "$file" ]; then
+		datactl offline database create_dc "$1" -f "$file"
+	fi
+done

+ 4 - 2
server/deployment/data_service/delete_data_containers.ps1

@@ -1,9 +1,11 @@
 Set-Location  $(Split-Path $MyInvocation.MyCommand.Path -Parent)
 
-datactl.exe delete -f base.yaml
+Param (
+    [string]$DatabaseName
+)
 
 foreach ($file in $(Get-ChildItem -Path ".\data_containers")) {
     if ($file.GetType() -eq [System.IO.FileInfo]) {
-        datactl.exe apply -f $file.FullName
+        datactl.exe offline database delete_dc $DatabaseName -f $file.FullName
     }
 }

+ 5 - 2
server/deployment/data_service/delete_data_containers.sh

@@ -1,10 +1,13 @@
 #!/bin/bash
 cd "$(dirname "$0")" || exit 1
 
-datactl delete -f base.yaml
+if [ "$#" -ne 1 ]; then
+    echo "Usage: $0 database_name"
+    exit 1
+fi
 
 for file in ./data_containers/*; do
 	if [ -f "$file" ]; then
-		datactl apply -f "$file"
+		datactl offline database delete_dc "$1" -f "$file"
 	fi
 done