Skip to content

Commit

Permalink
Merge pull request #292 from kaleido-io/permission-fixes
Browse files Browse the repository at this point in the history
More fixes for directory permissions
  • Loading branch information
nguyer authored Mar 4, 2024
2 parents 99626b3 + 9685bc7 commit a766617
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/blockchain/ethereum/besu/besu_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (p *BesuProvider) FirstTimeSetup() error {
return err
}

if err := p.connector.FirstTimeSetup(p.stack); err != nil {
return err
}

if err := docker.CreateVolume(p.ctx, besuVolumeName); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

type Connector interface {
FirstTimeSetup(stack *types.Stack) error
GetServiceDefinitions(s *types.Stack, dependentServices map[string]string) []*docker.ServiceDefinition
DeployContract(contract *ethtypes.CompiledContract, contractName string, member *types.Organization, extraArgs []string) (*types.ContractDeploymentResult, error)
GenerateConfig(stack *types.Stack, member *types.Organization, blockchainServiceName string) Config
Expand Down
4 changes: 4 additions & 0 deletions internal/blockchain/ethereum/connector/ethconnect/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ func getReply(ctx context.Context, ethconnectURL, id string) (*EthconnectReply,
err = core.RequestWithRetry(ctx, "GET", requestURL, nil, reply)
return reply, err
}

func (e *Ethconnect) FirstTimeSetup(stack *types.Stack) error {
return nil
}
10 changes: 10 additions & 0 deletions internal/blockchain/ethereum/connector/evmconnect/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum"
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/ethtypes"
"github.com/hyperledger/firefly-cli/internal/core"
"github.com/hyperledger/firefly-cli/internal/docker"
"github.com/hyperledger/firefly-cli/pkg/types"
)

Expand Down Expand Up @@ -146,3 +147,12 @@ func (e *Evmconnect) getTransactionStatus(evmconnectURL, id string) (*Evmconnect
err = core.RequestWithRetry(e.ctx, "GET", requestURL, nil, reply)
return reply, err
}

func (e *Evmconnect) FirstTimeSetup(stack *types.Stack) error {
for _, member := range stack.Members {
if err := docker.MkdirInVolume(e.ctx, fmt.Sprintf("%s_evmconnect_data_%s", stack.Name, member.ID), "/leveldb"); err != nil {
return err
}
}
return nil
}
5 changes: 3 additions & 2 deletions internal/blockchain/ethereum/connector/evmconnect/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (e *Evmconnect) GetServiceDefinitions(s *types.Stack, dependentServices map
}
serviceDefinitions := make([]*docker.ServiceDefinition, len(s.Members))
for i, member := range s.Members {
dataVolumeName := fmt.Sprintf("evmconnect_data_%s", member.ID)
serviceDefinitions[i] = &docker.ServiceDefinition{
ServiceName: "evmconnect_" + member.ID,
Service: &docker.Service{
Expand All @@ -40,12 +41,12 @@ func (e *Evmconnect) GetServiceDefinitions(s *types.Stack, dependentServices map
Ports: []string{fmt.Sprintf("%d:%v", member.ExposedConnectorPort, e.Port())},
Volumes: []string{
fmt.Sprintf("%s/config/evmconnect_%s.yaml:/evmconnect/config.yaml", s.RuntimeDir, member.ID),
fmt.Sprintf("evmconnect_data_%s:/evmconnect/data", member.ID),
fmt.Sprintf("%s:/evmconnect/data", dataVolumeName),
},
Logging: docker.StandardLogOptions,
},
VolumeNames: []string{
fmt.Sprintf("evmconnect_data_%s", member.ID),
dataVolumeName,
},
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/blockchain/ethereum/geth/geth_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (p *GethProvider) FirstTimeSetup() error {
blockchainDir := path.Join(p.stack.RuntimeDir, "blockchain")
contractsDir := path.Join(p.stack.RuntimeDir, "contracts")

if err := p.connector.FirstTimeSetup(p.stack); err != nil {
return err
}

if err := os.MkdirAll(contractsDir, 0755); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions internal/blockchain/ethereum/remoterpc/remoterpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (p *RemoteRPCProvider) FirstTimeSetup() error {
return err
}

if err := p.connector.FirstTimeSetup(p.stack); err != nil {
return err
}

for i := range p.stack.Members {
// Copy connector config to each member's volume
connectorConfigPath := filepath.Join(p.stack.StackDir, "runtime", "config", fmt.Sprintf("%s_%v.yaml", p.connector.Name(), i))
Expand Down
3 changes: 3 additions & 0 deletions internal/stacks/stack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ func (s *StackManager) copyDataExchangeConfigToVolumes() error {
if err := docker.MkdirInVolume(s.ctx, volumeName, "peer-certs"); err != nil {
return err
}
if err := docker.MkdirInVolume(s.ctx, volumeName, "blobs"); err != nil {
return err
}
if err := docker.CopyFileToVolume(s.ctx, volumeName, path.Join(memberDXDir, "config.json"), "/config.json"); err != nil {
return err
}
Expand Down

0 comments on commit a766617

Please sign in to comment.