Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57d252cee4 | |||
| 78030230c5 | |||
| adfb087037 | |||
| 5570f82eb4 | |||
| bffe7bde12 |
@@ -708,7 +708,8 @@ sgard/
|
|||||||
sgardpb/ # Generated protobuf + gRPC Go code
|
sgardpb/ # Generated protobuf + gRPC Go code
|
||||||
proto/sgard/v1/ # Proto source definitions
|
proto/sgard/v1/ # Proto source definitions
|
||||||
|
|
||||||
flake.nix # Nix flake (builds sgard + sgardd)
|
VERSION # Semver string, read by flake.nix; synced from latest git tag via `make version`
|
||||||
|
flake.nix # Nix flake (builds sgard + sgardd, version from VERSION file)
|
||||||
.goreleaser.yaml # GoReleaser (builds both binaries)
|
.goreleaser.yaml # GoReleaser (builds both binaries)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -1,4 +1,6 @@
|
|||||||
.PHONY: proto build test lint clean
|
VERSION := $(shell git describe --tags --abbrev=0 | sed 's/^v//')
|
||||||
|
|
||||||
|
.PHONY: proto build test lint clean version
|
||||||
|
|
||||||
proto:
|
proto:
|
||||||
protoc \
|
protoc \
|
||||||
@@ -7,8 +9,11 @@ proto:
|
|||||||
-I proto \
|
-I proto \
|
||||||
proto/sgard/v1/sgard.proto
|
proto/sgard/v1/sgard.proto
|
||||||
|
|
||||||
|
version:
|
||||||
|
@echo $(VERSION) > VERSION
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build ./...
|
go build -ldflags "-X main.version=$(VERSION)" ./...
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|||||||
@@ -111,3 +111,5 @@ 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 | — | `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 | — | 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-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. |
|
||||||
|
| 2026-03-26 | — | Version derived from git tags via `VERSION` file. flake.nix reads `VERSION`; Makefile `version` target syncs from latest tag, `build` injects via ldflags. |
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/kisom/sgard/garden"
|
"github.com/kisom/sgard/garden"
|
||||||
|
"github.com/kisom/sgard/manifest"
|
||||||
"github.com/kisom/sgard/server"
|
"github.com/kisom/sgard/server"
|
||||||
"github.com/kisom/sgard/sgardpb"
|
"github.com/kisom/sgard/sgardpb"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
@@ -273,6 +274,22 @@ func (c *Client) doPull(ctx context.Context, g *garden.Garden) (int, error) {
|
|||||||
return blobCount, nil
|
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.
|
// Prune requests the server to remove orphaned blobs. Returns the count removed.
|
||||||
// Automatically re-authenticates if needed.
|
// Automatically re-authenticates if needed.
|
||||||
func (c *Client) Prune(ctx context.Context) (int, error) {
|
func (c *Client) Prune(ctx context.Context) (int, error) {
|
||||||
|
|||||||
@@ -1,22 +1,57 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/kisom/sgard/garden"
|
"github.com/kisom/sgard/garden"
|
||||||
|
"github.com/kisom/sgard/manifest"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var listRemoteFlag bool
|
||||||
|
|
||||||
var listCmd = &cobra.Command{
|
var listCmd = &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List all tracked files",
|
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 {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if listRemoteFlag {
|
||||||
|
return listRemote()
|
||||||
|
}
|
||||||
|
return listLocal()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func listLocal() error {
|
||||||
g, err := garden.Open(repoFlag)
|
g, err := garden.Open(repoFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
entries := g.List()
|
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 {
|
for _, e := range entries {
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case "file":
|
case "file":
|
||||||
@@ -31,11 +66,9 @@ var listCmd = &cobra.Command{
|
|||||||
fmt.Printf("%-6s %s\n", "dir", e.Path)
|
fmt.Printf("%-6s %s\n", "dir", e.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
listCmd.Flags().BoolVarP(&listRemoteFlag, "use-remote", "r", false, "list files on the remote server")
|
||||||
rootCmd.AddCommand(listCmd)
|
rootCmd.AddCommand(listCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
15
flake.nix
15
flake.nix
@@ -11,17 +11,20 @@
|
|||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
in
|
in
|
||||||
|
let
|
||||||
|
version = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile ./VERSION);
|
||||||
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
sgard = pkgs.buildGoModule {
|
sgard = pkgs.buildGoModule rec {
|
||||||
pname = "sgard";
|
pname = "sgard";
|
||||||
version = "2.1.0";
|
inherit version;
|
||||||
src = pkgs.lib.cleanSource ./.;
|
src = pkgs.lib.cleanSource ./.;
|
||||||
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
||||||
|
|
||||||
vendorHash = "sha256-Z/Ja4j7YesNYefQQcWWRG2v8WuIL+UNqPGwYD5AipZY=";
|
vendorHash = "sha256-Z/Ja4j7YesNYefQQcWWRG2v8WuIL+UNqPGwYD5AipZY=";
|
||||||
|
|
||||||
ldflags = [ "-s" "-w" ];
|
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Shimmering Clarity Gardener: dotfile management";
|
description = "Shimmering Clarity Gardener: dotfile management";
|
||||||
@@ -29,9 +32,9 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
sgard-fido2 = pkgs.buildGoModule {
|
sgard-fido2 = pkgs.buildGoModule rec {
|
||||||
pname = "sgard-fido2";
|
pname = "sgard-fido2";
|
||||||
version = "2.1.0";
|
inherit version;
|
||||||
src = pkgs.lib.cleanSource ./.;
|
src = pkgs.lib.cleanSource ./.;
|
||||||
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
subPackages = [ "cmd/sgard" "cmd/sgardd" ];
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@
|
|||||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||||
tags = [ "fido2" ];
|
tags = [ "fido2" ];
|
||||||
|
|
||||||
ldflags = [ "-s" "-w" ];
|
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Shimmering Clarity Gardener: dotfile management (with FIDO2 hardware support)";
|
description = "Shimmering Clarity Gardener: dotfile management (with FIDO2 hardware support)";
|
||||||
|
|||||||
Reference in New Issue
Block a user