Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5570f82eb4 | |||
| bffe7bde12 | |||
| 3e0aabef4a |
@@ -111,3 +111,4 @@ Phase 6: Manifest Signing (to be planned).
|
||||
| 2026-03-25 | — | `sgard info` command: shows detailed file information (status, hash, timestamps, mode, encryption, targeting). 5 tests. |
|
||||
| 2026-03-25 | — | Deploy sgardd to rift: Dockerfile, docker-compose, mc-proxy L4 route on :9443, Metacrypt TLS cert, DNS. |
|
||||
| 2026-03-25 | — | `sgard remote set/show`: persistent remote config in `<repo>/remote.yaml` (addr, tls, tls_ca). |
|
||||
| 2026-03-26 | — | `sgard list` remote support: uses `resolveRemoteConfig()` to list server manifest via `PullManifest` RPC. Client `List()` method added. |
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/kisom/sgard/garden"
|
||||
"github.com/kisom/sgard/manifest"
|
||||
"github.com/kisom/sgard/server"
|
||||
"github.com/kisom/sgard/sgardpb"
|
||||
"golang.org/x/crypto/ssh"
|
||||
@@ -273,6 +274,22 @@ func (c *Client) doPull(ctx context.Context, g *garden.Garden) (int, error) {
|
||||
return blobCount, nil
|
||||
}
|
||||
|
||||
// List fetches the server's manifest and returns its entries without
|
||||
// downloading any blobs. Automatically re-authenticates if needed.
|
||||
func (c *Client) List(ctx context.Context) ([]manifest.Entry, error) {
|
||||
var entries []manifest.Entry
|
||||
err := c.retryOnAuth(ctx, func() error {
|
||||
resp, err := c.rpc.PullManifest(ctx, &sgardpb.PullManifestRequest{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("list remote: %w", err)
|
||||
}
|
||||
m := server.ProtoToManifest(resp.GetManifest())
|
||||
entries = m.Files
|
||||
return nil
|
||||
})
|
||||
return entries, err
|
||||
}
|
||||
|
||||
// Prune requests the server to remove orphaned blobs. Returns the count removed.
|
||||
// Automatically re-authenticates if needed.
|
||||
func (c *Client) Prune(ctx context.Context) (int, error) {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/kisom/sgard/garden"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -60,11 +59,16 @@ var addCmd = &cobra.Command{
|
||||
|
||||
func promptPassphrase() (string, error) {
|
||||
fmt.Fprint(os.Stderr, "Passphrase: ")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
if scanner.Scan() {
|
||||
return strings.TrimSpace(scanner.Text()), nil
|
||||
fd := int(os.Stdin.Fd())
|
||||
passphrase, err := term.ReadPassword(fd)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("reading passphrase: %w", err)
|
||||
}
|
||||
return "", fmt.Errorf("no passphrase provided")
|
||||
if len(passphrase) == 0 {
|
||||
return "", fmt.Errorf("no passphrase provided")
|
||||
}
|
||||
return string(passphrase), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -1,41 +1,74 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/kisom/sgard/garden"
|
||||
"github.com/kisom/sgard/manifest"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var listRemoteFlag bool
|
||||
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List all tracked files",
|
||||
Long: "List all tracked files locally, or on the remote server with -r.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
g, err := garden.Open(repoFlag)
|
||||
if err != nil {
|
||||
return err
|
||||
if listRemoteFlag {
|
||||
return listRemote()
|
||||
}
|
||||
|
||||
entries := g.List()
|
||||
for _, e := range entries {
|
||||
switch e.Type {
|
||||
case "file":
|
||||
hash := e.Hash
|
||||
if len(hash) > 8 {
|
||||
hash = hash[:8]
|
||||
}
|
||||
fmt.Printf("%-6s %s\t%s\n", "file", e.Path, hash)
|
||||
case "link":
|
||||
fmt.Printf("%-6s %s\t-> %s\n", "link", e.Path, e.Target)
|
||||
case "directory":
|
||||
fmt.Printf("%-6s %s\n", "dir", e.Path)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return listLocal()
|
||||
},
|
||||
}
|
||||
|
||||
func listLocal() error {
|
||||
g, err := garden.Open(repoFlag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printEntries(g.List())
|
||||
return nil
|
||||
}
|
||||
|
||||
func listRemote() error {
|
||||
ctx := context.Background()
|
||||
|
||||
c, cleanup, err := dialRemote(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
entries, err := c.List(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printEntries(entries)
|
||||
return nil
|
||||
}
|
||||
|
||||
func printEntries(entries []manifest.Entry) {
|
||||
for _, e := range entries {
|
||||
switch e.Type {
|
||||
case "file":
|
||||
hash := e.Hash
|
||||
if len(hash) > 8 {
|
||||
hash = hash[:8]
|
||||
}
|
||||
fmt.Printf("%-6s %s\t%s\n", "file", e.Path, hash)
|
||||
case "link":
|
||||
fmt.Printf("%-6s %s\t-> %s\n", "link", e.Path, e.Target)
|
||||
case "directory":
|
||||
fmt.Printf("%-6s %s\n", "dir", e.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
listCmd.Flags().BoolVarP(&listRemoteFlag, "use-remote", "r", false, "list files on the remote server")
|
||||
rootCmd.AddCommand(listCmd)
|
||||
}
|
||||
|
||||
12
flake.nix
12
flake.nix
@@ -13,15 +13,15 @@
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
sgard = pkgs.buildGoModule {
|
||||
sgard = pkgs.buildGoModule rec {
|
||||
pname = "sgard";
|
||||
version = "2.1.0";
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
||||
|
||||
vendorHash = "sha256-LSz15iFsP4N3Cif1PFHEKg3udeqH/9WQQbZ50sxtWTk=";
|
||||
vendorHash = "sha256-Z/Ja4j7YesNYefQQcWWRG2v8WuIL+UNqPGwYD5AipZY=";
|
||||
|
||||
ldflags = [ "-s" "-w" ];
|
||||
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
|
||||
|
||||
meta = {
|
||||
description = "Shimmering Clarity Gardener: dotfile management";
|
||||
@@ -29,19 +29,19 @@
|
||||
};
|
||||
};
|
||||
|
||||
sgard-fido2 = pkgs.buildGoModule {
|
||||
sgard-fido2 = pkgs.buildGoModule rec {
|
||||
pname = "sgard-fido2";
|
||||
version = "2.1.0";
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
||||
|
||||
vendorHash = "sha256-LSz15iFsP4N3Cif1PFHEKg3udeqH/9WQQbZ50sxtWTk=";
|
||||
vendorHash = "sha256-Z/Ja4j7YesNYefQQcWWRG2v8WuIL+UNqPGwYD5AipZY=";
|
||||
|
||||
buildInputs = [ pkgs.libfido2 ];
|
||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||
tags = [ "fido2" ];
|
||||
|
||||
ldflags = [ "-s" "-w" ];
|
||||
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
|
||||
|
||||
meta = {
|
||||
description = "Shimmering Clarity Gardener: dotfile management (with FIDO2 hardware support)";
|
||||
|
||||
Reference in New Issue
Block a user