Re: [PR] Support relative paths in configuration [skywalking-banyandb]
hanahmily merged PR #996: URL: https://github.com/apache/skywalking-banyandb/pull/996 -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Support relative paths in configuration [skywalking-banyandb]
codecov-commenter commented on PR #996: URL: https://github.com/apache/skywalking-banyandb/pull/996#issuecomment-4027944422 ## [Codecov](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 30.03%. Comparing base ([`3530dd9`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/3530dd9b5cefaa4fef60eec91ecbfbdfcaf243c5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5ab4040`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/5ab4040ecd5d0c895351be05004be66848b7463b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). :warning: Report is 147 commits behind head on main. > :exclamation: There is a different number of reports uploaded between BASE (3530dd9) and HEAD (5ab4040). Click for more details. > > HEAD has 1 upload less than BASE > >| Flag | BASE (3530dd9) | HEAD (5ab4040) | >|--|--|--| >||1|0| > Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #996 +/- ## === - Coverage 45.97% 30.03% -15.95% === Files 328 123 -205 Lines 5550512850-42655 === - Hits25520 3859-21661 + Misses 27909 8619-19290 + Partials 2076 372 -1704 ``` | [Flag](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [pkg](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `30.03% <100.00%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more. [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :rocket: New features to boost your workflow: - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Support relative paths in configuration [skywalking-banyandb]
hanahmily commented on PR #996: URL: https://github.com/apache/skywalking-banyandb/pull/996#issuecomment-4027741895 @aliyasirnac CI check failed. You can use the "make lint" task to check the linting errors locally. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Support relative paths in configuration [skywalking-banyandb]
Copilot commented on code in PR #996:
URL:
https://github.com/apache/skywalking-banyandb/pull/996#discussion_r2906380431
##
pkg/path/path_test.go:
##
@@ -0,0 +1,82 @@
+// Licensed to 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. Apache Software Foundation (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 path
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestGet(t *testing.T) {
+ wd, err := os.Getwd()
+ if err != nil {
+ t.Fatalf("failed to get working directory: %v", err)
+ }
+
+ tests := []struct {
+ namestring
+ input string
+ wantstring
+ wantErr bool
+ }{
+ {
+ name:"empty string",
+ input: "",
+ want:"",
+ wantErr: false,
+ },
+ {
+ name:"absolute path",
+ input: "/tmp/test",
+ want:filepath.Clean("/tmp/test"),
+ wantErr: false,
+ },
Review Comment:
This test hard-codes a Unix-style absolute path (`/tmp/test`), which can
behave differently or fail on Windows (volume-less rooted paths, path
semantics). Consider generating an OS-appropriate absolute path (e.g., based on
`t.TempDir()` and `filepath.Join`) so the test is cross-platform.
##
pkg/path/path.go:
##
@@ -0,0 +1,34 @@
+// Licensed to 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. Apache Software Foundation (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 path provides utilities to resolve relative paths to absolute paths.
+package path
+
+import (
+ "path/filepath"
+)
+
+// Get resolves the given path to an absolute path.
+// If the path is empty, it returns an empty string.
+// If the path is already absolute, it returns the path as is.
+// Otherwise, it returns the absolute path relative to the current working
directory.
+func Get(p string) (string, error) {
+ if p == "" {
+ return "", nil
+ }
+ return filepath.Abs(p)
+}
Review Comment:
`filepath.Abs` will `Clean` the path (even when already absolute), so the
comment 'returns the path as is' is not strictly accurate. Update the doc to
reflect that it returns a cleaned absolute path (or implement the exact
behavior described).
##
banyand/trace/svc_standalone.go:
##
@@ -136,6 +137,15 @@ func (s *standalone) PreRun(ctx context.Context) error {
s.l = logger.GetLogger(s.Name())
s.l.Info().Msg("memory protector is initialized in PreRun")
s.lfs = fs.NewLocalFileSystemWithLoggerAndLimit(s.l, s.pm.GetLimit())
+ var err error
+ if s.root, err = banyandbpath.Get(s.root); err != nil {
+ return err
+ }
+ if s.dataPath != "" {
+ if s.dataPath, err = banyandbpath.Get(s.dataPath); err != nil {
+ return err
+ }
Review Comment:
`banyandbpath.Get` already treats an empty string as a no-op (`\"\" → \"\"`
with nil error), so the `if s.dataPath != \"\"` guard is redundant. You can
simplify and standardize these call sites to always call `Get` for optional
paths, which reduces boilerplate across services.
```suggestion
if s.dataPath, err = banyandbpath.Get(s.dataPath); err != nil {
return err
```
##
banyand/metadata/client.go:
##
@@ -263,6 +264,40 @@ func (s *cl
[PR] Support relative paths in configuration [skywalking-banyandb]
aliyasirnac opened a new pull request, #996: URL: https://github.com/apache/skywalking-banyandb/pull/996 ### Support relative paths in configuration This PR adds support for relative paths across all core BanyanDB components (Measure, Stream, Trace, Metadata, Gossip) using a new `banyandbpath.Get` centralized helper. Configuration paths like root data directories, TLS certs, and keys can now be defined relatively, improving environment portability. - [ ] If this is non-trivial feature, paste the links/URLs to the design doc. - [ ] Update the documentation to include this new feature. - [x] Tests(including UT, IT, E2E) are added to verify the new feature. - [ ] If it's UI related, attach the screenshots below. - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Fixes apache/skywalking#13698. - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md). -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
