store: add getBlueprintChange update blueprint commit message
Add function to get a single blueprint change given the blueprint name and the commit hash. Update the PushBlueprint function to allow a commit message to be passed to it which will be used when adding a change.
This commit is contained in:
parent
c882bebfb4
commit
1b46a83522
1 changed files with 13 additions and 3 deletions
|
|
@ -368,6 +368,17 @@ func (s *Store) GetBlueprintCommitted(name string, bp *blueprint.Blueprint) bool
|
|||
return true
|
||||
}
|
||||
|
||||
func (s *Store) GetBlueprintChange(name string, commit string) *blueprint.Change {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
change, ok := s.BlueprintsChanges[name][commit]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &change
|
||||
}
|
||||
|
||||
func (s *Store) GetBlueprintChanges(name string) []blueprint.Change {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
|
@ -381,7 +392,7 @@ func (s *Store) GetBlueprintChanges(name string) []blueprint.Change {
|
|||
return changes
|
||||
}
|
||||
|
||||
func (s *Store) PushBlueprint(bp blueprint.Blueprint) {
|
||||
func (s *Store) PushBlueprint(bp blueprint.Blueprint, commitMsg string) {
|
||||
s.change(func() error {
|
||||
hash := sha1.New()
|
||||
// Hash timestamp to create unique hash
|
||||
|
|
@ -390,11 +401,10 @@ func (s *Store) PushBlueprint(bp blueprint.Blueprint) {
|
|||
commitBytes := hash.Sum(nil)
|
||||
// Get hash as a hex string
|
||||
commit := hex.EncodeToString(commitBytes)
|
||||
message := "Recipe " + bp.Name + ", version " + bp.Version + " saved."
|
||||
timestamp := time.Now().Format("2006-01-02T15:04:05Z")
|
||||
change := blueprint.Change{
|
||||
Commit: commit,
|
||||
Message: message,
|
||||
Message: commitMsg,
|
||||
Timestamp: timestamp,
|
||||
Blueprint: bp,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue