github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/pkg/metamanager/client/podstatus.go (about)

     1  package client
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/kubeedge/beehive/pkg/core/model"
     7  
     8  	edgeapi "github.com/kubeedge/kubeedge/common/types"
     9  	"github.com/kubeedge/kubeedge/edge/pkg/common/message"
    10  	commodule "github.com/kubeedge/kubeedge/edge/pkg/common/modules"
    11  )
    12  
    13  //PodStatusGetter is interface to get pod status
    14  type PodStatusGetter interface {
    15  	PodStatus(namespace string) PodStatusInterface
    16  }
    17  
    18  //PodStatusInterface is interface of pod status
    19  type PodStatusInterface interface {
    20  	Create(*edgeapi.PodStatusRequest) (*edgeapi.PodStatusRequest, error)
    21  	Update(rsName string, ps edgeapi.PodStatusRequest) error
    22  	Delete(name string) error
    23  	Get(name string) (*edgeapi.PodStatusRequest, error)
    24  }
    25  
    26  type podStatus struct {
    27  	namespace string
    28  	send      SendInterface
    29  }
    30  
    31  func newPodStatus(namespace string, s SendInterface) *podStatus {
    32  	return &podStatus{
    33  		send:      s,
    34  		namespace: namespace,
    35  	}
    36  }
    37  
    38  func (c *podStatus) Create(ps *edgeapi.PodStatusRequest) (*edgeapi.PodStatusRequest, error) {
    39  	return nil, nil
    40  }
    41  
    42  func (c *podStatus) Update(rsName string, ps edgeapi.PodStatusRequest) error {
    43  	podStatusMsg := message.BuildMsg(commodule.MetaGroup, "", commodule.EdgedModuleName, c.namespace+"/"+model.ResourceTypePodStatus+"/"+rsName, model.UpdateOperation, ps)
    44  	_, err := c.send.SendSync(podStatusMsg)
    45  	if err != nil {
    46  		return fmt.Errorf("update podstatus failed, err: %v", err)
    47  	}
    48  
    49  	return nil
    50  }
    51  
    52  func (c *podStatus) Delete(name string) error {
    53  	return nil
    54  }
    55  
    56  func (c *podStatus) Get(name string) (*edgeapi.PodStatusRequest, error) {
    57  	return nil, nil
    58  }