-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! api: linodemachine: add create validation
- Loading branch information
1 parent
084aceb
commit fcf9e51
Showing
2 changed files
with
43 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/linode/linodego" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
func validateRegion(ctx context.Context, client linodego.Client, id string, path *field.Path) (*linodego.Region, *field.Error) { | ||
region, err := client.GetRegion(ctx, id) | ||
if err != nil { | ||
return nil, field.NotFound(path, id) | ||
} | ||
|
||
return region, nil | ||
} | ||
|
||
func validateLinodeType(ctx context.Context, client linodego.Client, id string, path *field.Path) (*linodego.LinodeType, *field.Error) { | ||
plan, err := client.GetType(ctx, id) | ||
if err != nil { | ||
return nil, field.NotFound(path, id) | ||
} | ||
|
||
return plan, nil | ||
} |