github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/jxfactory/connector/connector.go (about)

     1  package connector
     2  
     3  import "path/filepath"
     4  
     5  // RemoteConnector specifies the namespace in the remote cluster
     6  type RemoteConnector struct {
     7  	GKE *GKEConnector `json:"gcp,omitempty" protobuf:"bytes,1,opt,name=gcp"`
     8  }
     9  
    10  // Key returns the key used for caching connectors
    11  func (c *RemoteConnector) Path() string {
    12  	if c.GKE != nil {
    13  		return c.GKE.Path()
    14  	}
    15  	return "unknown"
    16  }
    17  
    18  // GKEConnector the connection details for using Google Cloud
    19  type GKEConnector struct {
    20  	Project string `json:"project,omitempty" protobuf:"bytes,1,opt,name=project"`
    21  	Cluster string `json:"cluster,omitempty" protobuf:"bytes,2,opt,name=cluster"`
    22  	Region  string `json:"region,omitempty" protobuf:"bytes,3,opt,name=region"`
    23  	Zone    string `json:"zone,omitempty" protobuf:"bytes,4,opt,name=zone"`
    24  }
    25  
    26  func (c *GKEConnector) Path() string {
    27  	if c.Region != "" {
    28  		return filepath.Join("gcp", c.Project, c.Cluster, "region", c.Region)
    29  	} else {
    30  		return filepath.Join("gcp", c.Project, c.Cluster, "zone", c.Zone)
    31  	}
    32  }