Skip to content

Commit

Permalink
Handle empty instance_families (#236)
Browse files Browse the repository at this point in the history
* handle empty instance_families in node template

* add check for gpu too

* PR review
  • Loading branch information
linkas45 authored Oct 25, 2023
1 parent d794e3b commit cd2621d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ default: build
init-examples:
@echo "==> Creating symlinks for example/ projects to terraform-provider-castai binary"; \
TF_PROVIDER_FILENAME=terraform-provider-castai; \
GOOS=`go tool dist env | awk -F'=' '/^GOOS/ { print $$2}' | tr -d '"'`; \
GOARCH=`go tool dist env | awk -F'=' '/^GOARCH/ { print $$2}' | tr -d '"'`; \
GOOS=`go tool dist env | awk -F'=' '/^GOOS/ { print $$2}' | tr -d '";'`; \
GOARCH=`go tool dist env | awk -F'=' '/^GOARCH/ { print $$2}' | tr -d '";'`; \
for examples in examples/eks examples/gke examples/aks ; do \
for tfproject in $$examples/* ; do \
TF_PROJECT_PLUGIN_PATH="$${tfproject}/terraform.d/plugins/registry.terraform.io/castai/castai/0.0.0-local/$${GOOS}_$${GOARCH}"; \
Expand Down
10 changes: 8 additions & 2 deletions castai/resource_node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,16 @@ func toTemplateConstraints(obj map[string]any) *sdk.NodetemplatesV1TemplateConst
out.FallbackRestoreRateSeconds = toPtr(int32(v))
}
if v, ok := obj[FieldNodeTemplateGpu].([]any); ok && len(v) > 0 {
out.Gpu = toTemplateConstraintsGpuConstraints(v[0].(map[string]any))
val, ok := v[0].(map[string]any)
if ok {
out.Gpu = toTemplateConstraintsGpuConstraints(val)
}
}
if v, ok := obj[FieldNodeTemplateInstanceFamilies].([]any); ok && len(v) > 0 {
out.InstanceFamilies = toTemplateConstraintsInstanceFamilies(v[0].(map[string]any))
val, ok := v[0].(map[string]any)
if ok {
out.InstanceFamilies = toTemplateConstraintsInstanceFamilies(val)
}
}
if v, ok := obj[FieldNodeTemplateMaxCpu].(int); ok && v != 0 {
out.MaxCpu = toPtr(int32(v))
Expand Down

0 comments on commit cd2621d

Please sign in to comment.