diff --git a/castai/resource_node_template.go b/castai/resource_node_template.go index 8f1a3bb26..5bd68a999 100644 --- a/castai/resource_node_template.go +++ b/castai/resource_node_template.go @@ -1062,7 +1062,8 @@ func resourceNodeTemplateCreate(ctx context.Context, d *schema.ResourceData, met ShouldTaint: lo.ToPtr(d.Get(FieldNodeTemplateShouldTaint).(bool)), } - if v, ok := d.GetOk(FieldNodeTemplateIsEnabled); ok { + //nolint:staticcheck // Currently no other way to reliably get the value and determine if it is set + if v, ok := d.GetOkExists(FieldNodeTemplateIsEnabled); ok { req.IsEnabled = lo.ToPtr(v.(bool)) } diff --git a/castai/resource_node_template_test.go b/castai/resource_node_template_test.go index 3eda7c493..4437ebf45 100644 --- a/castai/resource_node_template_test.go +++ b/castai/resource_node_template_test.go @@ -440,6 +440,85 @@ func TestNodeTemplateResourceCreate_defaultNodeTemplate(t *testing.T) { r.False(result.HasError()) } +func TestNodeTemplateResourceCreate_customNodeTemplate(t *testing.T) { + r := require.New(t) + mockctrl := gomock.NewController(t) + mockClient := mock_sdk.NewMockClientInterface(mockctrl) + + ctx := context.Background() + provider := &ProviderConfig{ + api: &sdk.ClientWithResponses{ + ClientInterface: mockClient, + }, + } + + name := "custom-template" + clusterId := "b6bfc074-a267-400f-b8f1-db0850c369b1" + templateResponse := ` + { + "configurationId": "7dc4f922-29c9-4377-889c-0c8c5fb8d497", + "configurationName": "default", + "name": "custom-template", + "isEnabled": false, + "constraints": { + "spot": false, + "onDemand": true, + "minCpu": 10, + "maxCpu": 10000, + "architectures": ["amd64", "arm64"], + "resourceLimits": { + "cpuLimitEnabled": true, + "cpuLimitMaxCores": 20 + } + }, + "version": "3", + "shouldTaint": true, + "customLabels": {}, + "customTaints": [], + "rebalancingConfig": { + "minNodes": 0 + }, + "customInstancesEnabled": true, + "customInstancesWithExtendedMemoryEnabled": true + } + ` + + templateBody := io.NopCloser(bytes.NewReader([]byte(templateResponse))) + listBody := io.NopCloser(bytes.NewReader([]byte(fmt.Sprintf(` + { + "items": [ + { + "template": %s + } + ] + } + `, templateResponse)))) + + mockClient.EXPECT(). + NodeTemplatesAPIListNodeTemplates(gomock.Any(), clusterId, &sdk.NodeTemplatesAPIListNodeTemplatesParams{IncludeDefault: lo.ToPtr(true)}). + Return(&http.Response{StatusCode: 200, Body: listBody, Header: map[string][]string{"Content-Type": {"json"}}}, nil) + mockClient.EXPECT(). + NodeTemplatesAPICreateNodeTemplate(gomock.Any(), clusterId, gomock.Any()). + Return(&http.Response{StatusCode: 200, Body: templateBody, Header: map[string][]string{"Content-Type": {"json"}}}, nil) + + resource := resourceNodeTemplate() + val := cty.ObjectVal(map[string]cty.Value{ + FieldClusterId: cty.StringVal(clusterId), + FieldNodeTemplateName: cty.StringVal(name), + FieldNodeTemplateIsDefault: cty.BoolVal(true), + FieldNodeTemplateIsEnabled: cty.BoolVal(false), + FieldNodeTemplateCustomInstancesEnabled: cty.BoolVal(true), + FieldNodeTemplateCustomInstancesWithExtendedMemoryEnabled: cty.BoolVal(true), + }) + state := terraform.NewInstanceStateShimmedFromValue(val, 0) + state.ID = name + + data := resource.Data(state) + result := resource.CreateContext(ctx, data, provider) + r.Nil(result) + r.False(result.HasError()) +} + func TestNodeTemplateResourceDelete_defaultNodeTemplate(t *testing.T) { r := require.New(t) mockctrl := gomock.NewController(t) diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index 90a427173..f67066680 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -1987,9 +1987,6 @@ type CastaiRbacV1beta1RoleBindingDefinition struct { // RoleId RoleID is the unique identifier of the role. RoleId string `json:"roleId"` - // Scope Scope represents the scope of the role binding. - Scope *CastaiRbacV1beta1Scope `json:"scope,omitempty"` - // Scopes Scopes is a list of multiple scopes of the role binding. Scopes *[]CastaiRbacV1beta1Scope `json:"scopes,omitempty"` @@ -2560,9 +2557,6 @@ type CastaiUsersV1beta1Organization struct { // ParentId ID of the parent organization. This is beta feature not available for all organizations. ParentId *string `json:"parentId"` - // Rbacv2Enabled information whether the organization have rbacv2 enabled. - Rbacv2Enabled *bool `json:"rbacv2Enabled"` - // Type OrganizationType defines possible types of organization. // // - ORGANIZATION_TYPE_DEFAULT: default organization type @@ -2655,9 +2649,6 @@ type CastaiUsersV1beta1UserOrganization struct { // ParentId ID of the parent organization. This is beta feature not available for all organizations. ParentId *string `json:"parentId"` - // Rbacv2Enabled information whether the organization have rbacv2 enabled. - Rbacv2Enabled *bool `json:"rbacv2Enabled"` - // Role Deprecated: for RBACv2 user can be bound to multiple roles. // Use https://docs.cast.ai/reference/rbacserviceapi instead. // user role in the organization. @@ -3495,7 +3486,7 @@ type NodeconfigV1DeleteConfigurationResponse = map[string]interface{} // NodeconfigV1EKSConfig defines model for nodeconfig.v1.EKSConfig. type NodeconfigV1EKSConfig struct { - // DnsClusterIp IP address to use for DNS queries within the cluster. Defaults to 10.100.0.10 or 172.20.0.10 based on the IP address of the primary interface. + // DnsClusterIp Comma-separated IP addresses to use for DNS queries within the cluster. Defaults to 10.100.0.10 or 172.20.0.10 based on the primary interface's IP address. DnsClusterIp *string `json:"dnsClusterIp"` // ImageFamily List of supported image families (OSes) for EKS.