github.com/zoumo/helm@v2.5.0+incompatible/pkg/tiller/release_status.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package tiller 18 19 import ( 20 "errors" 21 "fmt" 22 23 ctx "golang.org/x/net/context" 24 25 "k8s.io/helm/pkg/proto/hapi/release" 26 "k8s.io/helm/pkg/proto/hapi/services" 27 ) 28 29 // GetReleaseStatus gets the status information for a named release. 30 func (s *ReleaseServer) GetReleaseStatus(c ctx.Context, req *services.GetReleaseStatusRequest) (*services.GetReleaseStatusResponse, error) { 31 if !ValidName.MatchString(req.Name) { 32 return nil, errMissingRelease 33 } 34 35 var rel *release.Release 36 37 if req.Version <= 0 { 38 var err error 39 rel, err = s.env.Releases.Last(req.Name) 40 if err != nil { 41 return nil, fmt.Errorf("getting deployed release %q: %s", req.Name, err) 42 } 43 } else { 44 var err error 45 if rel, err = s.env.Releases.Get(req.Name, req.Version); err != nil { 46 return nil, fmt.Errorf("getting release '%s' (v%d): %s", req.Name, req.Version, err) 47 } 48 } 49 50 if rel.Info == nil { 51 return nil, errors.New("release info is missing") 52 } 53 if rel.Chart == nil { 54 return nil, errors.New("release chart is missing") 55 } 56 57 sc := rel.Info.Status.Code 58 statusResp := &services.GetReleaseStatusResponse{ 59 Name: rel.Name, 60 Namespace: rel.Namespace, 61 Info: rel.Info, 62 } 63 64 // Ok, we got the status of the release as we had jotted down, now we need to match the 65 // manifest we stashed away with reality from the cluster. 66 resp, err := s.ReleaseModule.Status(rel, req, s.env) 67 if sc == release.Status_DELETED || sc == release.Status_FAILED { 68 // Skip errors if this is already deleted or failed. 69 return statusResp, nil 70 } else if err != nil { 71 s.Log("warning: Get for %s failed: %v", rel.Name, err) 72 return nil, err 73 } 74 rel.Info.Status.Resources = resp 75 return statusResp, nil 76 }