func (r *Repo) Init(consistentSnapshot bool) error { t, err := r.targets() if err != nil { return err } if len(t.Targets) > 0 { return ErrInitNotAllowed } root := data.NewRoot() root.ConsistentSnapshot = consistentSnapshot return r.setMeta("root.json", root) }
func (r *Repo) root() (*data.Root, error) { rootJSON, ok := r.meta["root.json"] if !ok { return data.NewRoot(), nil } s := &data.Signed{} if err := json.Unmarshal(rootJSON, s); err != nil { return nil, err } root := &data.Root{} if err := json.Unmarshal(s.Signed, root); err != nil { return nil, err } return root, nil }