File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
pkg/deployment/depresource Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 18
18
package depresource
19
19
20
20
import (
21
+ "fmt"
22
+
21
23
"github.com/elastic/cloud-sdk-go/pkg/api"
22
24
"github.com/elastic/cloud-sdk-go/pkg/client/platform_configuration_templates"
23
25
"github.com/elastic/cloud-sdk-go/pkg/models"
@@ -56,6 +58,11 @@ func NewKibana(params NewStateless) (*models.KibanaPayload, error) {
56
58
return nil , api .UnwrapError (err )
57
59
}
58
60
61
+ if res .Payload .ClusterTemplate .Kibana == nil {
62
+ return nil , fmt .Errorf ("deployment: the %s template is not configured for Kibana. Please use another template if you wish to start Kibana instances" ,
63
+ params .TemplateID )
64
+ }
65
+
59
66
var clusterTopology = res .Payload .ClusterTemplate .Kibana .Plan .ClusterTopology
60
67
var topology = models.KibanaClusterTopologyElement {Size : new (models.TopologySize )}
61
68
if len (clusterTopology ) > 0 {
Original file line number Diff line number Diff line change @@ -54,6 +54,15 @@ var kibanaTemplateResponse = models.DeploymentTemplateInfo{
54
54
},
55
55
}
56
56
57
+ var invalidTemplateResponse = models.DeploymentTemplateInfo {
58
+ ID : "invalid" ,
59
+ ClusterTemplate : & models.DeploymentTemplateDefinitionRequest {
60
+ Plan : & models.ElasticsearchClusterPlan {
61
+ ClusterTopology : defaultESTopologies ,
62
+ },
63
+ },
64
+ }
65
+
57
66
func TestNewKibana (t * testing.T ) {
58
67
var internalError = models.BasicFailedReply {
59
68
Errors : []* models.BasicFailedReplyElement {
@@ -139,6 +148,18 @@ func TestNewKibana(t *testing.T) {
139
148
}},
140
149
err : errors .New (string (internalErrorBytes )),
141
150
},
151
+ {
152
+ name : "obtains the deployment template but it's an invalid template for kibana" ,
153
+ args : args {params : NewStateless {
154
+ DeploymentID : util .ValidClusterID ,
155
+ API : api .NewMock (
156
+ mock .New200Response (mock .NewStructBody (getResponse )),
157
+ mock .New200Response (mock .NewStructBody (invalidTemplateResponse )),
158
+ ),
159
+ Region : "ece-region" ,
160
+ }},
161
+ err : errors .New ("deployment: the an ID template is not configured for Kibana. Please use another template if you wish to start Kibana instances" ),
162
+ },
142
163
{
143
164
name : "succeeds with no argument override" ,
144
165
args : args {params : NewStateless {
You can’t perform that action at this time.
0 commit comments