Documentation
¶
Overview ¶
Package validation checks whether a target migration model is consistent and can be provisioned, without creating or modifying any CSP/Tumblebug resource. The same checks back both the standalone validation API and the pre-flight gate that migration execution runs immediately before creating resources.
Index ¶
- Constants
- type NetworkRequirement
- type SecurityGroupRequirement
- type Severity
- type SshKeyRequirement
- type ValidationIssue
- func CheckNetworkAvailability(nsId string, netRequirement NetworkRequirement, ...) (needsCreate bool, issue *ValidationIssue)
- func CheckSecurityGroupAvailability(nsId string, sgRequirement SecurityGroupRequirement, ...) (needsCreate bool, issue *ValidationIssue)
- func CheckSshKeyAvailability(nsId string, sshKeyRequirement SshKeyRequirement, ...) (needsCreate bool, issue *ValidationIssue)
- type ValidationResult
Constants ¶
const ( CodeRequiredFieldMissing = "REQUIRED_FIELD_MISSING" CodeReferentialIntegrity = "REFERENTIAL_INTEGRITY" CodeResourceAlreadyExists = "RESOURCE_ALREADY_EXISTS" CodeResourceNotAvailable = "RESOURCE_NOT_AVAILABLE" CodeSpecImageIncompatible = "SPEC_IMAGE_INCOMPATIBLE" CodeInvalidConnectionName = "INVALID_CONNECTION_NAME" CodeSpecOrImageLookupFailed = "SPEC_OR_IMAGE_LOOKUP_FAILED" CodeConnectionMismatch = "CONNECTION_MISMATCH" )
Issue codes, stable identifiers a UI can switch on without parsing Message.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetworkRequirement ¶
NetworkRequirement represents the virtual network and subnets required by NodeGroups.
func DeriveNetworkRequirements ¶
func DeriveNetworkRequirements(nodeGroups []cloudmodel.CreateNodeGroupReq) []NetworkRequirement
DeriveNetworkRequirements groups and extracts virtual network requirements from NodeGroups.
type SecurityGroupRequirement ¶
SecurityGroupRequirement represents the security group required by NodeGroups.
func DeriveSecurityGroupRequirements ¶
func DeriveSecurityGroupRequirements(nodeGroups []cloudmodel.CreateNodeGroupReq) []SecurityGroupRequirement
DeriveSecurityGroupRequirements extracts unique security group requirements from NodeGroups.
type SshKeyRequirement ¶
SshKeyRequirement represents the SSH key required by NodeGroups.
func DeriveSshKeyRequirements ¶
func DeriveSshKeyRequirements(nodeGroups []cloudmodel.CreateNodeGroupReq) []SshKeyRequirement
DeriveSshKeyRequirements extracts unique SSH key requirements from NodeGroups.
type ValidationIssue ¶
type ValidationIssue struct {
Code string `json:"code"` // stable machine-readable identifier, one of the Code* constants
Severity Severity `json:"severity"` // error | warning
Path string `json:"path"` // location of the offending field, e.g. "targetInfra.nodeGroups[0].imageId"
Message string `json:"message"` // human-readable detail
}
ValidationIssue is a single problem found while validating a target model.
func CheckNetworkAvailability ¶
func CheckNetworkAvailability(nsId string, netRequirement NetworkRequirement, vNetCreationReq cloudmodel.VNetReq) (needsCreate bool, issue *ValidationIssue)
CheckNetworkAvailability reports whether the required vNet and subnets already exist, or - if not - whether vNetCreationReq carries enough data to create them. It performs reads only; no resource is created or modified.
func CheckSecurityGroupAvailability ¶
func CheckSecurityGroupAvailability(nsId string, sgRequirement SecurityGroupRequirement, sgCreationReqList []cloudmodel.SecurityGroupReq) (needsCreate bool, issue *ValidationIssue)
CheckSecurityGroupAvailability reports whether the required security group already exists, or - if not - whether sgCreationReqList carries enough data (a matching entry with ConnectionName and VNetId resolvable) to create it. It performs reads only; no resource is created or modified.
func CheckSshKeyAvailability ¶
func CheckSshKeyAvailability(nsId string, sshKeyRequirement SshKeyRequirement, sshKeyCreationReq cloudmodel.SshKeyReq) (needsCreate bool, issue *ValidationIssue)
CheckSshKeyAvailability reports whether the required SSH key already exists, or - if not - whether sshKeyCreationReq carries enough data to create it. It performs reads only; no resource is created or modified.
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
Issues []ValidationIssue `json:"issues"`
}
ValidationResult is the outcome of validating a target model.
func ValidateTargetInfra ¶
func ValidateTargetInfra(nsId string, targetInfraModel *cloudmodel.RecommendedInfra, useExisting bool) ValidationResult
ValidateTargetInfra checks whether targetInfraModel is internally consistent and can be migrated into namespace nsId, given how resources are provisioned under useExisting:
- useExisting=false: CreateInfra creates fresh VNet/SshKey/SecurityGroups, so none of them may already exist.
- useExisting=true: CreateInfraWithExisting reuses a resource by ID if found, otherwise falls back to creating it from the accompanying Target*Req data, so a missing resource is only an error when that fallback data is absent.
In both modes the check performs Tumblebug reads only - no resource is created, modified, or deleted. Because state can change between this call and an actual migration, a "valid" result is a best-effort snapshot, not a guarantee; the migration path re-runs this same validation immediately before provisioning.
All applicable checks run to completion and their issues are accumulated, rather than stopping at the first failure, so a caller (e.g. a Portal UI) can surface every problem found in a single call.
func (ValidationResult) Err ¶
func (r ValidationResult) Err() error
Err joins every SeverityError issue's message into a single error, or returns nil when the result is Valid. It mirrors context.Context.Err() / bufio.Scanner.Err(): nil means "nothing went wrong."