Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Do a few validations
Browse files Browse the repository at this point in the history
  • Loading branch information
abourget committed May 5, 2018
1 parent dde3759 commit 8be26a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func (i *IPFS) Get(ref IPFSRef) ([]byte, error) {
return nil, err
}

fmt.Printf("Fetching %q from primary location (%q)...", ref, i.GatewayAddressURL.String())
fmt.Printf("Fetching %q from %q...", ref, i.GatewayAddressURL.String())
resp, err := i.Client.Do(req1)
if err != nil {
fmt.Printf(" failed (%s), trying fallback (%q)...", err, i.FallbackGatewayAddressURL)
fmt.Printf(" failed (%s), trying %q...", err, i.FallbackGatewayAddressURL)

resp, err = i.Client.Do(req2)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package bios

import (
"encoding/json"
"fmt"
"io/ioutil"
"strings"

yaml2json "github.com/bronze1man/go-yaml2json"
)
Expand All @@ -28,5 +30,14 @@ func ValidateDiscoveryFile(filename string) error {
return err
}

for _, peer := range disco.LaunchData.Peers {
if !strings.HasPrefix(string(peer.DiscoveryLink), "/ipns/") {
return fmt.Errorf("peer link %q invalid, should start with '/ipns/'", peer.DiscoveryLink)
}
if peer.Weight > 1.0 {
return fmt.Errorf("peer %q weight must be between 0.0 and 1.0", peer.DiscoveryLink)
}
}

return nil
}

0 comments on commit 8be26a7

Please sign in to comment.