Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
1f9210a3
Commit
1f9210a3
authored
Sep 23, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fileutil function
parent
bf12b436
Pipeline
#8037
failed with stages
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
+19
-6
init.go
cmd/sidecar/init.go
+2
-2
config.go
hub/client/config.go
+2
-2
config.go
internal/repo/config.go
+3
-2
tool.go
tool/tool.go
+12
-0
No files found.
cmd/sidecar/init.go
View file @
1f9210a3
...
...
@@ -6,10 +6,10 @@ import (
"os"
"path/filepath"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/urfave/cli"
"github.com/link33/sidecar/internal/repo"
"github.com/link33/sidecar/tool"
)
var
initCMD
=
cli
.
Command
{
...
...
@@ -21,7 +21,7 @@ var initCMD = cli.Command{
return
err
}
if
fileuti
l
.
Exist
(
filepath
.
Join
(
repoRoot
,
repo
.
ConfigName
))
{
if
too
l
.
Exist
(
filepath
.
Join
(
repoRoot
,
repo
.
ConfigName
))
{
fmt
.
Println
(
"sidecar configuration file already exists"
)
fmt
.
Println
(
"reinitializing would overwrite your configuration, Y/N?"
)
input
:=
bufio
.
NewScanner
(
os
.
Stdin
)
...
...
hub/client/config.go
View file @
1f9210a3
...
...
@@ -5,9 +5,9 @@ import (
"time"
"github.com/meshplus/bitxhub-kit/crypto"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/link33/sidecar/pkg/log"
"github.com/link33/sidecar/tool"
)
const
(
...
...
@@ -95,7 +95,7 @@ func checkConfig(config *config) error {
// if EnableTLS is set, then tls certs must be provided
for
_
,
nodeInfo
:=
range
config
.
nodesInfo
{
if
nodeInfo
.
EnableTLS
{
if
!
fileuti
l
.
Exist
(
nodeInfo
.
CertPath
)
{
if
!
too
l
.
Exist
(
nodeInfo
.
CertPath
)
{
return
fmt
.
Errorf
(
"ca cert file %s is not found while tls is enabled"
,
nodeInfo
.
CertPath
)
}
}
...
...
internal/repo/config.go
View file @
1f9210a3
...
...
@@ -5,8 +5,9 @@ import (
"path/filepath"
"strings"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/spf13/viper"
"github.com/link33/sidecar/tool"
)
const
(
...
...
@@ -135,7 +136,7 @@ func DefaultConfig() *Config {
func
UnmarshalConfig
(
repoRoot
string
)
(
*
Config
,
error
)
{
configPath
:=
filepath
.
Join
(
repoRoot
,
ConfigName
)
if
!
fileuti
l
.
Exist
(
configPath
)
{
if
!
too
l
.
Exist
(
configPath
)
{
return
nil
,
fmt
.
Errorf
(
"file %s doesn't exist, please initialize sidecar firstly"
,
configPath
)
}
...
...
tool/tool.go
View file @
1f9210a3
package
tool
import
"os"
func
Asset
(
err
error
)
{
if
err
!=
nil
{
panic
(
err
)
}
}
// Exist check if the file with the given path exits.
func
Exist
(
path
string
)
bool
{
fi
,
err
:=
os
.
Lstat
(
path
)
if
fi
!=
nil
||
(
err
!=
nil
&&
!
os
.
IsNotExist
(
err
))
{
return
true
}
return
false
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment