Skip to content

Commit f66d1e8

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

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

pkg/project/provider/provider.go

Lines changed: 15 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,11 @@ func Passphrase(backend Home, app, stage string) (string, error) {
118130
if err != nil {
119131
return "", err
120132
}
133+
134+
cache := passphraseCache[backend]
135+
cache[app+stage] = passphrase
121136
}
122137

123-
existingPassphrase, ok = cache[app+stage]
124138
return passphrase, nil
125139
}
126140

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)