-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement config setup for each component in bare-metal mode (#153
) * add merge operation for bare-metal config Signed-off-by: sh2 <shawnhxh@outlook.com> * add custom configuration file support for each component in bare-metal mode Signed-off-by: sh2 <shawnhxh@outlook.com> --------- Signed-off-by: sh2 <shawnhxh@outlook.com>
- Loading branch information
Showing
15 changed files
with
235 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# More options for storage: https://docs.greptime.com/user-guide/operations/configuration#storage-options | ||
|
||
[storage] | ||
type = "S3" | ||
bucket = "test_greptimedb" | ||
root = "/greptimedb" | ||
access_key_id = "<access key id>" | ||
secret_access_key = "<secret access key>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cluster: | ||
name: mycluster # name of the cluster | ||
artifact: | ||
version: latest | ||
frontend: | ||
replicas: 1 | ||
datanode: | ||
replicas: 3 | ||
rpcAddr: 0.0.0.0:14100 | ||
mysqlAddr: 0.0.0.0:14200 | ||
httpAddr: 0.0.0.0:14300 | ||
config: 'examples/bare-metal/cluster-with-s3-storage.datanode.toml' | ||
meta: | ||
replicas: 1 | ||
storeAddr: 127.0.0.1:2379 | ||
serverAddr: 0.0.0.0:3002 | ||
httpAddr: 0.0.0.0:14001 | ||
|
||
etcd: | ||
artifact: | ||
version: v3.5.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed 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 file | ||
|
||
import ( | ||
"bytes" | ||
|
||
"golang.org/x/exp/maps" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
// MergeYAML merges two yaml files from src to dst, the src yaml will override dst yaml if the same key exists. | ||
func MergeYAML(dst, src []byte) ([]byte, error) { | ||
map1 := map[string]interface{}{} | ||
map2 := map[string]interface{}{} | ||
|
||
if err := yaml.Unmarshal(src, &map1); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := yaml.Unmarshal(dst, &map2); err != nil { | ||
return nil, err | ||
} | ||
|
||
maps.Copy(map2, map1) | ||
|
||
buf := bytes.NewBuffer([]byte{}) | ||
encoder := yaml.NewEncoder(buf) | ||
encoder.SetIndent(2) | ||
|
||
if err := encoder.Encode(map2); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := encoder.Close(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return buf.Bytes(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed 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 file | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestMergeYAML(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
yaml1 string | ||
yaml2 string | ||
want string | ||
}{ | ||
{ | ||
name: "test", | ||
yaml1: ` | ||
a: a | ||
b: | ||
c: | ||
d: d | ||
e: | ||
f: | ||
- g | ||
k: | ||
l: l | ||
`, | ||
yaml2: ` | ||
a: a1 | ||
b: | ||
c: | ||
d: d1 | ||
e: | ||
f: | ||
- h | ||
i: | ||
j: j | ||
`, | ||
want: `a: a1 | ||
b: | ||
c: | ||
d: d1 | ||
e: | ||
f: | ||
- h | ||
i: | ||
j: j | ||
k: | ||
l: l | ||
`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := MergeYAML([]byte(tt.yaml1), []byte(tt.yaml2)) | ||
if err != nil { | ||
t.Errorf("MergeYAML() err = %v", err) | ||
} | ||
|
||
actual := string(got) | ||
if !reflect.DeepEqual(actual, tt.want) { | ||
t.Errorf("MergeYAML() got = %v, want %v", actual, tt.want) | ||
} | ||
}) | ||
} | ||
} |