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 // DeleteOption allows setting optional attributes when
// performing a UninstallRelease tiller rpc. // performing a UninstallRelease tiller rpc.
type DeleteOption func(*options) type DeleteOption func(*options)

@ -122,6 +122,7 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
Manifest: manifestDoc.String(), Manifest: manifestDoc.String(),
Hooks: hooks, Hooks: hooks,
Version: int32(revision), Version: int32(revision),
Annotations: req.Annotations,
} }
if len(notesTxt) > 0 { if len(notesTxt) > 0 {
rel.Info.Status.Notes = notesTxt rel.Info.Status.Notes = notesTxt

@ -106,6 +106,7 @@ func (s *ReleaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
Version: crls.Version + 1, Version: crls.Version + 1,
Manifest: prls.Manifest, Manifest: prls.Manifest,
Hooks: prls.Hooks, Hooks: prls.Hooks,
Annotations: prls.Annotations,
} }
return crls, target, nil 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) s.Log("copying values from %s (v%d) to new release.", current.Name, current.Version)
req.Values = current.Config 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 return nil
} }

@ -122,6 +122,7 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
Version: revision, Version: revision,
Manifest: manifestDoc.String(), Manifest: manifestDoc.String(),
Hooks: hooks, Hooks: hooks,
Annotations: req.Annotations,
} }
if len(notesTxt) > 0 { if len(notesTxt) > 0 {

Loading…
Cancel
Save