func tufAdd(cmd *cobra.Command, args []string) { if len(args) < 3 { cmd.Usage() fatalf("must specify a GUN, target, and path to target data") } gun := args[0] targetName := args[1] targetPath := args[2] parseConfig() // no online operations are performed by add so the transport argument // should be nil nRepo, err := notaryclient.NewNotaryRepository(trustDir, gun, getRemoteTrustServer(), nil, retriever) if err != nil { fatalf(err.Error()) } target, err := notaryclient.NewTarget(targetName, targetPath) if err != nil { fatalf(err.Error()) } err = nRepo.AddTarget(target) if err != nil { fatalf(err.Error()) } fmt.Printf("Addition of %s to %s staged for next publish.\n", targetName, gun) }
func (t *tufCommander) tufAdd(cmd *cobra.Command, args []string) error { if len(args) < 3 { cmd.Usage() return fmt.Errorf("Must specify a GUN, target, and path to target data") } config, err := t.configGetter() if err != nil { return err } gun := args[0] targetName := args[1] targetPath := args[2] // no online operations are performed by add so the transport argument // should be nil nRepo, err := notaryclient.NewNotaryRepository( config.GetString("trust_dir"), gun, getRemoteTrustServer(config), nil, t.retriever) if err != nil { return err } target, err := notaryclient.NewTarget(targetName, targetPath) if err != nil { return err } // If roles is empty, we default to adding to targets if err = nRepo.AddTarget(target, t.roles...); err != nil { return err } cmd.Printf( "Addition of target \"%s\" to repository \"%s\" staged for next publish.\n", targetName, gun) return nil }
func tufAdd(cmd *cobra.Command, args []string) { if len(args) < 3 { cmd.Usage() fatalf("must specify a GUN, target, and path to target data") } gun := args[0] targetName := args[1] targetPath := args[2] repo, err := notaryclient.NewNotaryRepository(viper.GetString("baseTrustDir"), gun, hardcodedBaseURL, getInsecureTransport()) if err != nil { fatalf(err.Error()) } target, err := notaryclient.NewTarget(targetName, targetPath) if err != nil { fatalf(err.Error()) } err = repo.AddTarget(target) if err != nil { fatalf(err.Error()) } fmt.Println("Successfully added targets") }