fix generation bug (#2043)

This commit is contained in:
zryfish
2020-05-01 13:12:54 +08:00
committed by GitHub
parent 933207d247
commit 98f44fac99
3 changed files with 68 additions and 13 deletions

View File

@@ -23,6 +23,8 @@ const (
defaultAgentImage = "kubesphere/tower:v1.0"
)
var ErrClusterConnectionIsNotProxy = fmt.Errorf("cluster is not using proxy connection")
type handler struct {
serviceLister v1.ServiceLister
clusterLister clusterlister.ClusterLister
@@ -62,6 +64,11 @@ func (h *handler) GenerateAgentDeployment(request *restful.Request, response *re
}
}
if cluster.Spec.Connection.Type != v1alpha1.ConnectionTypeProxy {
api.HandleNotFound(response, request, fmt.Errorf("cluster %s is not using proxy connection", cluster.Name))
return
}
// use service ingress address
if len(h.proxyAddress) == 0 {
err = h.populateProxyAddress()
@@ -126,6 +133,10 @@ func (h *handler) populateProxyAddress() error {
func (h *handler) generateDefaultDeployment(cluster *v1alpha1.Cluster, w io.Writer) error {
if cluster.Spec.Connection.Type == v1alpha1.ConnectionTypeDirect {
return ErrClusterConnectionIsNotProxy
}
agent := appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",