tiller: store annotations during release install/upgrade

Upgrade logic is simple:
- if no annotations are provided, then use the old annotations in the new
  release version;
- if annotations are provided, then replace the old annotations with them.
pull/2631/head
Igor Bazhitov 8 years ago
parent 9734bf3a12
commit 18a2a907f6

@ -393,6 +393,20 @@ func StatusReleaseVersion(version int32) StatusOption {
}
}
// InstallAnnotations attaches annotations to the release
func InstallAnnotations(annotations map[string]string) InstallOption {
return func(opts *options) {
opts.instReq.Annotations = annotations
}
}
// UpgradeAnnotations attaches annotations to the release
func UpgradeAnnotations(annotations map[string]string) UpdateOption {
return func(opts *options) {
opts.updateReq.Annotations = annotations
}
}
// DeleteOption allows setting optional attributes when
// performing a UninstallRelease tiller rpc.
type DeleteOption func(*options)

@ -119,9 +119,10 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
Status: &release.Status{Code: release.Status_UNKNOWN},
Description: "Initial install underway", // Will be overwritten.
},
Manifest: manifestDoc.String(),
Hooks: hooks,
Version: int32(revision),
Manifest: manifestDoc.String(),
Hooks: hooks,
Version: int32(revision),
Annotations: req.Annotations,
}
if len(notesTxt) > 0 {
rel.Info.Status.Notes = notesTxt

@ -103,9 +103,10 @@ func (s *ReleaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
// message here, and only override it later if we experience failure.
Description: fmt.Sprintf("Rollback to %d", rbv),
},
Version: crls.Version + 1,
Manifest: prls.Manifest,
Hooks: prls.Hooks,
Version: crls.Version + 1,
Manifest: prls.Manifest,
Hooks: prls.Hooks,
Annotations: prls.Annotations,
}
return crls, target, nil

@ -147,6 +147,12 @@ func (s *ReleaseServer) reuseValues(req *services.UpdateReleaseRequest, current
s.Log("copying values from %s (v%d) to new release.", current.Name, current.Version)
req.Values = current.Config
}
if len(req.Annotations) == 0 {
s.Log("copying annotations from %s (v%d) to new release.", current.Name, current.Version)
req.Annotations = current.Annotations
}
return nil
}

@ -119,9 +119,10 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
Status: &release.Status{Code: release.Status_UNKNOWN},
Description: "Preparing upgrade", // This should be overwritten later.
},
Version: revision,
Manifest: manifestDoc.String(),
Hooks: hooks,
Version: revision,
Manifest: manifestDoc.String(),
Hooks: hooks,
Annotations: req.Annotations,
}
if len(notesTxt) > 0 {

Loading…
Cancel
Save