Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions pkg/backend/diy/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ import (
)

type lockContent struct {
Pid int `json:"pid"`
Username string `json:"username"`
Hostname string `json:"hostname"`
Timestamp time.Time `json:"timestamp"`
Pid int `json:"pid"`
Username string `json:"username"`
Hostname string `json:"hostname"`
Timestamp time.Time `json:"timestamp"`
Metadata map[string]string `json:"metadata,omitempty"`
}

func newLockContent() (*lockContent, error) {
Expand All @@ -51,12 +52,19 @@ func newLockContent() (*lockContent, error) {
if err != nil {
return nil, err
}
return &lockContent{
lc := &lockContent{
Pid: os.Getpid(),
Username: u.Username,
Hostname: hostname,
Timestamp: time.Now(),
}, nil
}
if raw := os.Getenv("PULUMI_LOCK_METADATA"); raw != "" {
var m map[string]string
if json.Unmarshal([]byte(raw), &m) == nil {
lc.Metadata = m
}
}
return lc, nil
}

// checkForLock looks for any existing locks for this stack, and returns a helpful diagnostic if there is one.
Expand Down Expand Up @@ -104,6 +112,11 @@ func (b *diyBackend) checkForLock(ctx context.Context, stackRef backend.StackRef
l.Pid,
l.Timestamp.Format(time.RFC3339),
))
if len(l.Metadata) > 0 {
for k, v := range l.Metadata {
errorString.WriteString(fmt.Sprintf(" %v=%v", k, v))
}
}
}

return errors.New(errorString.String())
Expand Down