feat: share env files in --demo
Providers whose containers are files give their contents through provider.Contents, which sharing reads instead of the disk. The demo repos build their env files from their keys, and the second demo account has a key to share with (kv-shared-prod / env-share), so S → f and opening the link work in --demo; the demo repos aren't on disk, so opening asks where to save. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
7 files changed
+86
-9
No files matched your search
@@ -40,9 +40,9 @@ type sealedMsg struct {
|
||||
}
|
||||
|
||||
// canShareFiles reports whether src's env files can be shared: it's a
|
||||
// repo whose files are on disk.
|
||||
// repo whose files can be read.
|
||||
func (m Model) canShareFiles(src provider.Source) bool {
|
||||
_, ok := m.providerFor(src).(provider.Files)
|
||||
_, ok := m.providerFor(src).(provider.Contents)
|
||||
return src.Kind == provider.KindRepo && ok
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (m Model) canShareFiles(src provider.Source) bool {
|
||||
// plain ones.
|
||||
func (m *Model) shareFiles(src provider.Source, cs []provider.Container) tea.Cmd {
|
||||
p := m.providerFor(src)
|
||||
files, ok := p.(provider.Files)
|
||||
files, ok := p.(provider.Contents)
|
||||
if !ok {
|
||||
m.flash = warning("these files can't be shared")
|
||||
return nil
|
||||
@@ -78,16 +78,12 @@ func (m *Model) shareFiles(src provider.Source, cs []provider.Container) tea.Cmd
|
||||
}
|
||||
}
|
||||
for _, c := range cs {
|
||||
f, err := files.File(c, nil)
|
||||
if err == nil {
|
||||
var b []byte
|
||||
b, err = os.ReadFile(f.Path)
|
||||
msg.files = append(msg.files, share.File{Path: c.Name, Data: b})
|
||||
}
|
||||
b, err := files.Contents(ctx, c)
|
||||
if err != nil {
|
||||
msg.err = err
|
||||
return msg
|
||||
}
|
||||
msg.files = append(msg.files, share.File{Path: c.Name, Data: b})
|
||||
}
|
||||
key, ok, err := share.DefaultKey(src.ID, general)
|
||||
if ok {
|
||||
|
||||
Reference in new issue
Block a user