...

Source file src/github.com/theupdateframework/go-tuf/cmd/tuf/root_keys.go

Documentation: github.com/theupdateframework/go-tuf/cmd/tuf

     1  package main
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"os"
     7  
     8  	"github.com/flynn/go-docopt"
     9  	"github.com/theupdateframework/go-tuf"
    10  )
    11  
    12  func init() {
    13  	register("root-keys", cmdRootKeys, `
    14  usage: tuf root-keys
    15  
    16  Outputs a JSON serialized array of root keys to STDOUT.
    17  
    18  The resulting JSON should be distributed to clients for performing initial updates.
    19  `)
    20  }
    21  
    22  func cmdRootKeys(args *docopt.Args, repo *tuf.Repo) error {
    23  	keys, err := repo.RootKeys()
    24  	if err != nil {
    25  		return err
    26  	}
    27  	data, err := json.Marshal(keys)
    28  	if err == nil {
    29  		fmt.Fprintf(os.Stderr, "The resulting JSON should be distributed to clients for performing initial updates:\n\n")
    30  		fmt.Fprintln(os.Stdout, string(data))
    31  	}
    32  	return err
    33  }
    34  

View as plain text