Skip to content

Commit 8fc9908

Browse files
Init passphrase on deploy commands only
1 parent 183c61b commit 8fc9908

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

pkg/project/provider/provider.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ func Passphrase(backend Home, app, stage string) (string, error) {
103103
return "", err
104104
}
105105

106+
if passphrase != "" {
107+
cache[app+stage] = passphrase
108+
}
109+
return passphrase, nil
110+
}
111+
112+
func PassphraseInit(backend Home, app, stage string) (string, error) {
113+
passphrase, err := Passphrase(backend, app, stage)
114+
if err != nil {
115+
return "", err
116+
}
117+
106118
if passphrase == "" {
107119
slog.Info("passphrase not found, setting passphrase", "app", app, "stage", stage)
108120
passphrase = flag.SST_PASSPHRASE
@@ -118,9 +130,10 @@ func Passphrase(backend Home, app, stage string) (string, error) {
118130
if err != nil {
119131
return "", err
120132
}
133+
134+
passphraseCache[backend][app+stage] = passphrase
121135
}
122136

123-
existingPassphrase, ok = cache[app+stage]
124137
return passphrase, nil
125138
}
126139

pkg/project/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ func (p *Project) RunNext(ctx context.Context, input *StackInput) error {
7878
}
7979
defer workdir.Cleanup()
8080

81-
passphrase, err := provider.Passphrase(p.home, p.app.Name, p.app.Stage)
81+
var passphrase string
82+
if input.Command == "deploy" || input.Dev {
83+
passphrase, err = provider.PassphraseInit(p.home, p.app.Name, p.app.Stage)
84+
} else {
85+
passphrase, err = provider.Passphrase(p.home, p.app.Name, p.app.Stage)
86+
}
8287
if err != nil {
8388
return err
8489
}

0 commit comments

Comments
 (0)