github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/kubernetes/status/resource/status.go (about)

     1  /*
     2  Copyright 2019 The Skaffold Authors
     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 resource
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/GoogleContainerTools/skaffold/proto/v1"
    23  )
    24  
    25  type Status struct {
    26  	ae       *proto.ActionableErr
    27  	changed  bool
    28  	reported bool
    29  }
    30  
    31  func (rs Status) Error() error {
    32  	if rs.ae.ErrCode == proto.StatusCode_STATUSCHECK_SUCCESS {
    33  		return nil
    34  	}
    35  	return fmt.Errorf(rs.ae.Message)
    36  }
    37  
    38  func (rs Status) ActionableError() *proto.ActionableErr {
    39  	return rs.ae
    40  }
    41  
    42  func (rs Status) String() string {
    43  	return rs.ae.Message
    44  }
    45  
    46  func (rs Status) Equal(other Status) bool {
    47  	return rs.ae.Message == other.ae.Message && rs.ae.ErrCode == other.ae.ErrCode
    48  }
    49  
    50  func newStatus(ae *proto.ActionableErr) Status {
    51  	return Status{
    52  		ae:      ae,
    53  		changed: true,
    54  	}
    55  }