MCPcopy Create free account
hub / github.com/bytebase/bytebase / getVersion

Method getVersion

backend/plugin/db/elasticsearch/sync.go:70–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70func (d *Driver) getVersion() (string, error) {
71 if d.isOpenSearch && d.opensearchAPI != nil {
72 ctx := context.Background()
73 info, err := d.opensearchAPI.Info(ctx, &opensearchapi.InfoReq{})
74 if err != nil {
75 return "", err
76 }
77 return info.Version.Number, nil
78 }
79 resp, err := d.basicAuthClient.Do("GET", []byte("/"), nil)
80 if err != nil {
81 return "", err
82 }
83 defer resp.Body.Close()
84
85 bytes, err := io.ReadAll(resp.Body)
86 if err != nil {
87 return "", errors.Wrap(err, "failed to read response body")
88 }
89
90 // Check HTTP status code
91 if resp.StatusCode != http.StatusOK {
92 // Include response body for debugging
93 return "", errors.Errorf("unexpected status code %d: %s", resp.StatusCode, string(bytes))
94 }
95
96 var result VersionResult
97 err = json.Unmarshal(bytes, &result)
98 if err != nil {
99 // Include response body to help debug parsing issues
100 bodyPreview, truncated := common.TruncateString(string(bytes), 500)
101 if truncated {
102 bodyPreview += "..."
103 }
104 return "", errors.Wrapf(err, "failed to parse version response: %s", bodyPreview)
105 }
106
107 return result.Version.Number, nil
108}
109
110type IndicesResult struct {
111 IndexSize string `json:"store.size"`

Callers 1

SyncInstanceMethod · 0.95

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 6

TruncateStringFunction · 0.92
InfoMethod · 0.80
DoMethod · 0.80
ErrorfMethod · 0.80
UnmarshalMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected