Exemplo n.º 1
0
// updateTUFClient updates the given client, initializing and re-running the
// update if ErrNoRootKeys is returned.
func (u *Updater) updateTUFClient(client *tuf.Client) error {
	_, err := client.Update()
	if err == nil || tuf.IsLatestSnapshot(err) {
		return nil
	}
	if err == tuf.ErrNoRootKeys {
		if err := client.Init(u.rootKeys, len(u.rootKeys)); err != nil {
			return err
		}
		return u.updateTUFClient(client)
	}
	return err
}
Exemplo n.º 2
0
func cmdInit(args *docopt.Args, client *tuf.Client) error {
	file := args.String["<root-keys-file>"]
	var in io.Reader
	if file == "" || file == "-" {
		in = os.Stdin
	} else {
		var err error
		in, err = os.Open(file)
		if err != nil {
			return err
		}
	}
	var rootKeys []*data.Key
	if err := json.NewDecoder(in).Decode(&rootKeys); err != nil {
		return err
	}
	return client.Init(rootKeys, len(rootKeys))
}