diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ade6ff9..1f473e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,58 +2,58 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: test: name: Test and Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' - - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Install dependencies - run: make deps - - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - version: v2.6.0 - - - name: Run checks (vet, fmt-check, test) - run: make vet fmt-check test - - # Note: Validation tests with real cloud providers run in separate workflows - # See .github/workflows/validation-*.yml for provider-specific validation tests - - - name: Run security scan - run: make security - continue-on-error: true - - - name: Run tests with coverage - run: make test-coverage - - - name: Upload coverage reports - uses: actions/upload-artifact@v4 - with: - name: coverage-report - path: coverage/ + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: "go.mod" + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: make deps + + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: v2.7.1 + + - name: Run checks (vet, fmt-check, test) + run: make vet fmt-check test + + # Note: Validation tests with real cloud providers run in separate workflows + # See .github/workflows/validation-*.yml for provider-specific validation tests + + - name: Run security scan + run: make security + continue-on-error: true + + - name: Run tests with coverage + run: make test-coverage + + - name: Upload coverage reports + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ build: name: Cross-platform Build @@ -63,31 +63,31 @@ jobs: matrix: target: [linux, darwin, windows] steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' - - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Install dependencies - run: make deps - - - name: Build for ${{ matrix.target }} - run: make build-${{ matrix.target }} - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-${{ matrix.target }} - path: build/ + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: "go.mod" + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: make deps + + - name: Build for ${{ matrix.target }} + run: make build-${{ matrix.target }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.target }} + path: build/ diff --git a/README.md b/README.md index 3cef4d5..d13dece 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ An early-stage, vendor-agnostic Go SDK for managing **clusterable, GPU-accelerat ## Project Goals - Define a clean, minimal interface for cloud compute primitives: + - `Instance` - `Storage` - `FirewallRule` @@ -41,7 +42,7 @@ See [SECURITY.md](docs/SECURITY.md) for complete security specifications and imp - **Operating System**: Currently supports Ubuntu 22 only - **Architecture**: Designed for GPU-accelerated compute workloads -- **Access Method**: Requires SSH server and SSH key-based authentication +- **Access Method**: Requires SSH server and SSH key-based authentication. Supports `TunneledSSH`. Indicates whether connections must be routed through a client-side tunnel proxy. This is required for instances that do not have public IP addresses. - **System Requirements**: Requires systemd to be running and accessible --- @@ -65,4 +66,3 @@ See [SECURITY.md](docs/SECURITY.md) for complete security specifications and imp ## Get Involved This is a foundation — we're opening it early to **learn with the community** and shape a clean, composable `v2`. If you're building GPU compute infrastructure or tooling, we'd love your input. - diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 64393f2..401e2e4 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -65,8 +65,8 @@ This document outlines the security requirements and best practices for implemen 1. **Default State**: All inbound traffic must be blocked by default (exemption may be made to 22, though the sdk prefers to explicitly set this) 2. **Explicit Allow**: Inbound access must be explicitly granted through `FirewallRule` resources 3. **Outbound Freedom**: Outbound traffic should be unrestricted by default -5. **Security Groups**: Use cloud provider security groups or equivalent (AWS Security Groups, GCP Firewall Rules, Azure NSGs) for network isolation -6. **Default Deny**: Configure security groups with default deny rules for all inbound traffic +4. **Security Groups**: Use cloud provider security groups or equivalent (AWS Security Groups, GCP Firewall Rules, Azure NSGs) for network isolation +5. **Default Deny**: Configure security groups with default deny rules for all inbound traffic ### Cluster Security @@ -137,4 +137,4 @@ For security issues, vulnerabilities, or questions: --- -**Note**: This document is a living document and will be updated as security requirements evolve. All cloud integrations must comply with these requirements to ensure the security and integrity of the Brev Compute SDK ecosystem. +**Note**: This document is a living document and will be updated as security requirements evolve. All cloud integrations must comply with these requirements to ensure the security and integrity of the Brev Compute SDK ecosystem. diff --git a/docs/how-to-add-a-provider.md b/docs/how-to-add-a-provider.md index b63d65b..0204aaf 100644 --- a/docs/how-to-add-a-provider.md +++ b/docs/how-to-add-a-provider.md @@ -3,18 +3,21 @@ This guide explains how to add a new cloud provider to the Brev Cloud SDK (v1). The Lambda Labs provider is the best working, well-tested example—use it as your canonical reference. Goals: + - Implement a provider-specific CloudCredential (factory) and CloudClient (implementation) that satisfy pkg/v1 interfaces. - Accurately declare Capabilities based on the provider’s API surface. - Implement at least instance lifecycle and instance types, adhering to security requirements. - Add validation tests and (optionally) a GitHub Actions workflow to run them with real credentials. Helpful background: + - Architecture overview: ../docs/ARCHITECTURE.md - Security requirements: ../docs/SECURITY.md - Validation testing framework: ../docs/VALIDATION_TESTING.md - v1 design notes: ../pkg/v1/V1_DESIGN_NOTES.md Provider examples: + - Lambda Labs (canonical): ../internal/lambdalabs/v1/README.md - Nebius (in progress): ../internal/nebius/v1/README.md - Fluidstack (in progress): ../internal/fluidstack/v1/README.md @@ -32,6 +35,7 @@ CloudClient is a composed interface of provider capabilities. You don’t need t - Instance types and validation helpers: ../pkg/v1/instancetype.go Patterns to follow: + - Embed v1.NotImplCloudClient in your client so unsupported methods gracefully return ErrNotImplemented (see ../pkg/v1/notimplemented.go). - Accurately return capability flags that match your provider’s real API. - Prefer stable, provider-native identifiers; otherwise use MakeGenericInstanceTypeID/MakeGenericInstanceTypeIDFromInstance. @@ -39,6 +43,7 @@ Patterns to follow: --- --- + ## Compute Brokers & Marketplaces (Aggregators) This SDK supports providers that aggregate compute from multiple upstream sources (multi-cloud brokers, marketplaces, or exchanges). When implementing an aggregator, use these to differentiate where the compute comes from while keeping the interface consistent: @@ -49,9 +54,11 @@ This SDK supports providers that aggregate compute from multiple upstream source - InstanceType attributes (recommended): Use instance type attributes to delineate behavior differences across upstream sources (e.g., performance, network, storage, locality). There is also a `provider` attribute on the instance type you can use to indicate the originating vendor/source. Notes: + - Capabilities represent what your broker can support. Differences between upstream vendors should be reflected in instance type attributes rather than reducing declared capabilities to the lowest common denominator. - Keep your `Location`/`SubLocation` stable even if upstream identifiers change; translate upstream → broker-stable naming. - Conform to the default-deny inbound model; document any upstream limitations under `internal/{provider}/SECURITY.md`. + ## Directory Layout Create a new provider folder: @@ -68,6 +75,7 @@ Create a new provider folder: - validation_test.go (validation suite entry point) Use Lambda Labs as the pattern: + - ../internal/lambdalabs/v1/client.go - ../internal/lambdalabs/v1/instance.go - ../internal/lambdalabs/v1/capabilities.go @@ -220,6 +228,7 @@ func (c *{Provider}Client) MergeInstanceTypeForUpdate(_ v1.InstanceType, newIt v ``` See the canonical mapping and conversion logic in Lambda Labs: + - Create/terminate/list/reboot: ../internal/lambdalabs/v1/instance.go - Capabilities: ../internal/lambdalabs/v1/capabilities.go - Client/credential + NotImpl: ../internal/lambdalabs/v1/client.go @@ -242,25 +251,34 @@ Implement instance types in internal/{provider}/v1/instancetype.go: The SDK uses a three-level capability system to accurately represent what operations are supported: ### 1. Provider-Level Capabilities + These are high-level features that your cloud provider's API supports, declared in your `GetCapabilities()` method. Capability flags live in ../pkg/v1/capabilities.go. Only include capabilities your API actually supports. For example, Lambda Labs supports: + - Create/terminate/reboot instance (`CapabilityCreateInstance`, `CapabilityTerminateInstance`, `CapabilityRebootInstance`) - Does not (currently) support stop/start, resize volume, machine image, tags -### 2. Instance Type Capabilities +### 2. Instance Type Capabilities + These are hardware-specific features that vary by instance configuration, expressed as boolean fields on the `InstanceType` struct: + - `Stoppable`: Whether instances of this type can be stopped/started - `Rebootable`: Whether instances of this type can be rebooted - `CanModifyFirewallRules`: Whether firewall rules can be modified for this instance type - `Preemptible`: Whether this instance type supports spot/preemptible pricing +- `TunneledSSH`: Whether connections must be routed through a client-side tunnel proxy. This is required for instances that do not have public IP addresses. ### 3. Instance Capabilities + These are capability boolean fields replicated on individual `Instance` objects, similar to Instance Type capabilities but applied to the running instance rather than the type template. While these fields could theoretically be derived from the associated `InstanceType`, they are duplicated on the instance for performance and convenience reasons. Examples include: + - `Stoppable`: Whether this specific instance can be stopped/started - `Rebootable`: Whether this specific instance can be rebooted +- `TunneledSSH`: Whether connections must be routed through a client-side tunnel proxy. This is required for instances that do not have public IP addresses. These fields must be kept accurate and in sync with the corresponding InstanceType capabilities, even though they appear redundant. They can also reflect runtime state-dependent variations - for example, a running instance might support certain operations that a stopped instance cannot, based on the current `LifecycleStatus`. Reference: + - Lambda capabilities: ../internal/lambdalabs/v1/capabilities.go --- @@ -268,12 +286,14 @@ Reference: ## Security Requirements All providers must conform to ../docs/SECURITY.md: + - Default deny all inbound, allow all outbound - SSH server must be available with key-based auth - Firewall rules should be explicitly configured via FirewallRule when supported - If your provider’s firewall model is global/project-scoped rather than per-instance, document limitations in internal/{provider}/SECURITY.md and reflect that by omitting CapabilityModifyFirewall if applicable. Provider-specific security doc examples: + - Lambda Labs: ../internal/lambdalabs/SECURITY.md - Nebius: ../internal/nebius/SECURITY.md - Fluidstack: ../internal/fluidstack/v1/SECURITY.md @@ -288,7 +308,8 @@ Use the shared validation suite to test your provider with real credentials. - Shared package: ../internal/validation/suite.go Steps: -1) Create internal/{provider}/v1/validation_test.go: + +1. Create internal/{provider}/v1/validation_test.go: ```go package v1 @@ -317,12 +338,14 @@ func TestValidationFunctions(t *testing.T) { } ``` -2) Local runs: -- make test # skips validation (short) +2. Local runs: + +- make test # skips validation (short) - make test-validation # runs validation (long) -- make test-all # runs everything +- make test-all # runs everything + +3. CI workflow (recommended): -3) CI workflow (recommended): - Add .github/workflows/validation-{provider}.yml (copy Lambda Labs workflow if available or follow VALIDATION_TESTING.md). - Store secrets in GitHub Actions (e.g., YOUR_PROVIDER_API_KEY). diff --git a/internal/errors/errors.go b/internal/clouderrors/errors.go similarity index 99% rename from internal/errors/errors.go rename to internal/clouderrors/errors.go index 7769de1..1921e2c 100644 --- a/internal/errors/errors.go +++ b/internal/clouderrors/errors.go @@ -1,4 +1,4 @@ -package errors +package clouderrors import ( stderrors "errors" diff --git a/v1/V1_DESIGN_NOTES.md b/v1/V1_DESIGN_NOTES.md index 339b8c4..ed36b97 100644 --- a/v1/V1_DESIGN_NOTES.md +++ b/v1/V1_DESIGN_NOTES.md @@ -51,3 +51,6 @@ The terminology around instance-attached storage is one of the more confusing pa - Instance management is treated as individual resources rather than as part of a larger distributed system. - Missing concepts like cluster membership, inter-instance communication, shared state, or cluster lifecycle management. - For support to be added we may need to more fomally implement networks/vpcs or instance groups. + +### SSH Connectivity Patterns +- `TunneledSSH`: Indicates whether connections must be routed through a client-side tunnel proxy. This is required for instances that do not have public IP addresses. This is currently implemented as a field on both `InstanceType` and `Instance`. diff --git a/v1/bytes.go b/v1/bytes.go index 06c3204..0757b64 100644 --- a/v1/bytes.go +++ b/v1/bytes.go @@ -6,15 +6,15 @@ import ( "math" "math/big" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" ) var ( zero = Bytes{} - ErrBytesInvalidUnit = errors.New("invalid unit") - ErrBytesNotAnInt64 = errors.New("byte count is not an int64") - ErrBytesNotAnInt32 = errors.New("byte count is not an int32") + ErrBytesInvalidUnit = clouderrors.New("invalid unit") + ErrBytesNotAnInt64 = clouderrors.New("byte count is not an int64") + ErrBytesNotAnInt32 = clouderrors.New("byte count is not an int32") ) // NewBytes creates a new Bytes with the given value and unit. @@ -86,10 +86,10 @@ func (b Bytes) ByteCountInUnitInt64(unit BytesUnit) (int64, error) { byteCountInt64, accuracy := byteCount.Int64() if byteCountInt64 == math.MaxInt64 && accuracy == big.Below { - return 0, errors.WrapAndTrace(errors.Join(ErrBytesNotAnInt64, fmt.Errorf("byte count %v is greater than %d", byteCount, math.MaxInt64))) + return 0, clouderrors.WrapAndTrace(clouderrors.Join(ErrBytesNotAnInt64, fmt.Errorf("byte count %v is greater than %d", byteCount, math.MaxInt64))) } if byteCountInt64 == math.MinInt64 && accuracy == big.Above { - return 0, errors.WrapAndTrace(errors.Join(ErrBytesNotAnInt64, fmt.Errorf("byte count %v is less than %d", byteCount, math.MinInt64))) + return 0, clouderrors.WrapAndTrace(clouderrors.Join(ErrBytesNotAnInt64, fmt.Errorf("byte count %v is less than %d", byteCount, math.MinInt64))) } return byteCountInt64, nil } @@ -99,12 +99,12 @@ func (b Bytes) ByteCountInUnitInt64(unit BytesUnit) (int64, error) { func (b Bytes) ByteCountInUnitInt32(unit BytesUnit) (int32, error) { byteCountInt64, err := b.ByteCountInUnitInt64(unit) if err != nil { - return 0, errors.WrapAndTrace(err) + return 0, clouderrors.WrapAndTrace(err) } if byteCountInt64 > math.MaxInt32 { - return 0, errors.WrapAndTrace(errors.Join(ErrBytesNotAnInt32, fmt.Errorf("byte count %v is greater than %d", byteCountInt64, math.MaxInt32))) + return 0, clouderrors.WrapAndTrace(clouderrors.Join(ErrBytesNotAnInt32, fmt.Errorf("byte count %v is greater than %d", byteCountInt64, math.MaxInt32))) } - return int32(byteCountInt64), nil //nolint:gosec // checked above + return int32(byteCountInt64), nil } // String returns the string representation of the Bytes @@ -124,7 +124,7 @@ func (b Bytes) MarshalJSON() ([]byte, error) { func (b *Bytes) UnmarshalJSON(data []byte) error { var bytesJSON bytesJSON if err := json.Unmarshal(data, &bytesJSON); err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } if bytesJSON.Value == 0 && bytesJSON.Unit == "" { @@ -134,7 +134,7 @@ func (b *Bytes) UnmarshalJSON(data []byte) error { unit, err := stringToBytesUnit(bytesJSON.Unit) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } newBytes := NewBytes(BytesValue(bytesJSON.Value), unit) @@ -214,5 +214,5 @@ func stringToBytesUnit(unit string) (BytesUnit, error) { case Pebibyte.name: return Pebibyte, nil } - return BytesUnit{}, errors.WrapAndTrace(errors.Join(ErrBytesInvalidUnit, fmt.Errorf("invalid unit: %s", unit))) + return BytesUnit{}, clouderrors.WrapAndTrace(clouderrors.Join(ErrBytesInvalidUnit, fmt.Errorf("invalid unit: %s", unit))) } diff --git a/v1/instance.go b/v1/instance.go index d56a5e0..137e683 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -225,6 +225,7 @@ type Instance struct { NotPrivileged bool InstanceTypeID InstanceTypeID AdditionalDisks []Disk + TunneledSSH bool // As of 08/26/2024 only used for Launchpad cloud. // Because there is port forwarding from a GPU node to Bastion node, @@ -292,6 +293,7 @@ type CreateInstanceAttrs struct { // is the Akash provider. AdditionalEnvVars map[string]string AdditionalDisks []Disk + TunneledSSH bool } type UpdateInstanceTagsArgs struct { diff --git a/v1/instancetype.go b/v1/instancetype.go index 3c09440..8e0edb6 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -79,6 +79,7 @@ type InstanceType struct { VariablePrice bool Preemptible bool IsAvailable bool + VerifiedAt *time.Time BasePrice *currency.Amount SubLocationTypeChangeable bool IsContainer bool @@ -89,6 +90,7 @@ type InstanceType struct { Cloud string CanModifyFirewallRules bool ReservedInstancePoolID string + TunneledSSH bool } func MakeGenericInstanceTypeID(instanceType InstanceType) InstanceTypeID { @@ -374,6 +376,7 @@ func normalizeInstanceTypes(types []InstanceType) []InstanceType { normalized[i].BasePrice = nil normalized[i].Quota = InstanceTypeQuota{} normalized[i].EstimatedDeployTime = nil + normalized[i].VerifiedAt = nil } return normalized } diff --git a/v1/kubernetes.go b/v1/kubernetes.go index e263283..55cae4b 100644 --- a/v1/kubernetes.go +++ b/v1/kubernetes.go @@ -5,21 +5,21 @@ import ( "encoding/json" "fmt" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" ) var ( - ErrRefIDRequired = errors.New("refID is required") - ErrNameRequired = errors.New("name is required") - ErrNodeGroupInvalidStatus = errors.New("invalid node group status") - ErrClusterInvalidStatus = errors.New("invalid cluster status") - ErrClusterUserClusterNameRequired = errors.New("clusterName is required") - ErrClusterUserClusterCertificateAuthorityDataBase64Required = errors.New("clusterCertificateAuthorityDataBase64 is required") - ErrClusterUserClusterServerURLRequired = errors.New("clusterServerURL is required") - ErrClusterUserUsernameRequired = errors.New("username is required") - ErrClusterUserUserClientCertificateDataBase64Required = errors.New("userClientCertificateDataBase64 is required") - ErrClusterUserUserClientKeyDataBase64Required = errors.New("userClientKeyDataBase64 is required") - ErrClusterUserKubeconfigBase64Required = errors.New("kubeconfigBase64 is required") + ErrRefIDRequired = clouderrors.New("refID is required") + ErrNameRequired = clouderrors.New("name is required") + ErrNodeGroupInvalidStatus = clouderrors.New("invalid node group status") + ErrClusterInvalidStatus = clouderrors.New("invalid cluster status") + ErrClusterUserClusterNameRequired = clouderrors.New("clusterName is required") + ErrClusterUserClusterCertificateAuthorityDataBase64Required = clouderrors.New("clusterCertificateAuthorityDataBase64 is required") + ErrClusterUserClusterServerURLRequired = clouderrors.New("clusterServerURL is required") + ErrClusterUserUsernameRequired = clouderrors.New("username is required") + ErrClusterUserUserClientCertificateDataBase64Required = clouderrors.New("userClientCertificateDataBase64 is required") + ErrClusterUserUserClientKeyDataBase64Required = clouderrors.New("userClientKeyDataBase64 is required") + ErrClusterUserKubeconfigBase64Required = clouderrors.New("kubeconfigBase64 is required") ) // Cluster represents the complete specification of a Brev Kubernetes cluster. @@ -115,7 +115,7 @@ func (c *Cluster) MarshalJSON() ([]byte, error) { func (c *Cluster) UnmarshalJSON(data []byte) error { var clusterJSON clusterJSON if err := json.Unmarshal(data, &clusterJSON); err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } subnetIDs := make([]CloudProviderResourceID, len(clusterJSON.SubnetIDs)) @@ -125,7 +125,7 @@ func (c *Cluster) UnmarshalJSON(data []byte) error { status, err := stringToClusterStatus(clusterJSON.Status) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } newCluster, err := NewCluster(ClusterSettings{ @@ -145,7 +145,7 @@ func (c *Cluster) UnmarshalJSON(data []byte) error { Tags: clusterJSON.Tags, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } *c = *newCluster @@ -183,7 +183,7 @@ func stringToClusterStatus(status string) (ClusterStatus, error) { case ClusterStatusFailed.value: return ClusterStatusFailed, nil } - return ClusterStatusUnknown, errors.Join(ErrClusterInvalidStatus, fmt.Errorf("invalid status: %s", status)) + return ClusterStatusUnknown, clouderrors.Join(ErrClusterInvalidStatus, fmt.Errorf("invalid status: %s", status)) } func (c *Cluster) GetID() CloudProviderResourceID { @@ -298,7 +298,7 @@ func (s *ClusterSettings) validate() error { if s.Name == "" { errs = append(errs, ErrNameRequired) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } // NewCluster creates a new Cluster from the provided settings. @@ -306,7 +306,7 @@ func NewCluster(settings ClusterSettings) (*Cluster, error) { settings.setDefaults() err := settings.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &Cluster{ id: settings.ID, @@ -389,12 +389,12 @@ func (n *NodeGroup) MarshalJSON() ([]byte, error) { func (n *NodeGroup) UnmarshalJSON(data []byte) error { var nodeGroupJSON nodeGroupJSON if err := json.Unmarshal(data, &nodeGroupJSON); err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } status, err := stringToNodeGroupStatus(nodeGroupJSON.Status) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } newNodeGroup, err := NewNodeGroup(NodeGroupSettings{ @@ -409,7 +409,7 @@ func (n *NodeGroup) UnmarshalJSON(data []byte) error { Tags: nodeGroupJSON.Tags, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } *n = *newNodeGroup @@ -447,7 +447,7 @@ func stringToNodeGroupStatus(status string) (NodeGroupStatus, error) { case NodeGroupStatusFailed.value: return NodeGroupStatusFailed, nil } - return NodeGroupStatusUnknown, errors.Join(ErrNodeGroupInvalidStatus, fmt.Errorf("invalid status: %s", status)) + return NodeGroupStatusUnknown, clouderrors.Join(ErrNodeGroupInvalidStatus, fmt.Errorf("invalid status: %s", status)) } func (n *NodeGroup) GetName() string { @@ -527,7 +527,7 @@ func (s *NodeGroupSettings) validate() error { if s.Name == "" { errs = append(errs, ErrNameRequired) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } // NewNodeGroup creates a new NodeGroup from the provided settings. @@ -535,7 +535,7 @@ func NewNodeGroup(settings NodeGroupSettings) (*NodeGroup, error) { settings.setDefaults() err := settings.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &NodeGroup{ name: settings.Name, @@ -652,7 +652,7 @@ func (s *ClusterUserSettings) validate() error { if s.KubeconfigBase64 == "" { errs = append(errs, ErrClusterUserKubeconfigBase64Required) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } // NewClusterUser creates a new ClusterUser from the provided settings. @@ -660,7 +660,7 @@ func NewClusterUser(settings ClusterUserSettings) (*ClusterUser, error) { settings.setDefaults() err := settings.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &ClusterUser{ clusterName: settings.ClusterName, diff --git a/v1/providers/aws/kubernetes.go b/v1/providers/aws/kubernetes.go index 3936c90..4b4c172 100644 --- a/v1/providers/aws/kubernetes.go +++ b/v1/providers/aws/kubernetes.go @@ -18,7 +18,7 @@ import ( k8scmd "k8s.io/client-go/tools/clientcmd/api" "sigs.k8s.io/aws-iam-authenticator/pkg/token" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" cloudk8s "github.com/brevdev/cloud/internal/kubernetes" "github.com/brevdev/cloud/internal/rsa" v1 "github.com/brevdev/cloud/v1" @@ -55,7 +55,7 @@ func (c *AWSClient) CreateCluster(ctx context.Context, args v1.CreateClusterArgs ID: args.VPCID, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create a map of subnetID->subnet for this VPC so that we can find the target subnet @@ -68,7 +68,7 @@ func (c *AWSClient) CreateCluster(ctx context.Context, args v1.CreateClusterArgs subnets := make([]*v1.Subnet, len(args.SubnetIDs)) for i, subnetID := range args.SubnetIDs { if _, ok := subnetMap[string(subnetID)]; !ok { - return nil, errors.WrapAndTrace(fmt.Errorf("subnet ID %s does not match VPC %s", subnetID, vpc.GetID())) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("subnet ID %s does not match VPC %s", subnetID, vpc.GetID())) } else { subnets[i] = subnetMap[string(subnetID)] } @@ -77,7 +77,7 @@ func (c *AWSClient) CreateCluster(ctx context.Context, args v1.CreateClusterArgs // Create the cluster awsCluster, err := c.createEKSCluster(ctx, eksClient, iamClient, subnets, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevCluster, err := v1.NewCluster(v1.ClusterSettings{ @@ -95,7 +95,7 @@ func (c *AWSClient) CreateCluster(ctx context.Context, args v1.CreateClusterArgs Tags: args.Tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevCluster, nil } @@ -103,17 +103,17 @@ func (c *AWSClient) CreateCluster(ctx context.Context, args v1.CreateClusterArgs func (c *AWSClient) createEKSCluster(ctx context.Context, eksClient *eks.Client, iamClient *iam.Client, subnets []*v1.Subnet, args v1.CreateClusterArgs) (*ekstypes.Cluster, error) { serviceRole, err := c.createServiceRole(ctx, iamClient, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } eksCluster, err := c.createCluster(ctx, eksClient, args, serviceRole, subnets) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } err = c.installEKSAddons(ctx, eksClient, eksCluster) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return eksCluster, nil @@ -162,7 +162,7 @@ func (c *AWSClient) createServiceRole(ctx context.Context, iamClient *iam.Client } output, err := iamClient.CreateRole(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Attach the AmazonEKSClusterPolicy to the role @@ -171,7 +171,7 @@ func (c *AWSClient) createServiceRole(ctx context.Context, iamClient *iam.Client PolicyArn: aws.String("arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return output.Role, nil @@ -219,7 +219,7 @@ func (c *AWSClient) createCluster(ctx context.Context, eksClient *eks.Client, ar output, err := eksClient.CreateCluster(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return output.Cluster, nil @@ -264,10 +264,10 @@ func (c *AWSClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1 }) if err != nil { var noSuchEntityError *ekstypes.ResourceNotFoundException - if errors.As(err, &noSuchEntityError) { + if clouderrors.As(err, &noSuchEntityError) { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnetIDs := make([]v1.CloudProviderResourceID, 0, len(eksCluster.Cluster.ResourcesVpcConfig.SubnetIds)) @@ -277,7 +277,7 @@ func (c *AWSClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1 nodeGroups, err := c.getClusterNodeGroups(ctx, eksClient, eksCluster.Cluster) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // List all addons and use their status to determine if the cluster is ready @@ -285,7 +285,7 @@ func (c *AWSClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1 ClusterName: eksCluster.Cluster.Name, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } inactiveAddons := 0 @@ -295,7 +295,7 @@ func (c *AWSClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1 AddonName: aws.String(name), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if addon.Addon.Status != ekstypes.AddonStatusActive { inactiveAddons++ @@ -325,7 +325,7 @@ func (c *AWSClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1 Tags: v1.Tags(eksCluster.Cluster.Tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevCluster, nil } @@ -371,7 +371,7 @@ func (c *AWSClient) getClusterNodeGroups(ctx context.Context, eksClient *eks.Cli ClusterName: eksCluster.Name, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Then fetch the details of each node group @@ -382,12 +382,12 @@ func (c *AWSClient) getClusterNodeGroups(ctx context.Context, eksClient *eks.Cli NodegroupName: aws.String(eksNodeGroupName), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevNodeGroup, err := parseEKSNodeGroup(eksNodeGroup.Nodegroup) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nodeGroups = append(nodeGroups, brevNodeGroup) } @@ -409,7 +409,7 @@ func parseEKSNodeGroup(eksNodeGroup *ekstypes.Nodegroup) (*v1.NodeGroup, error) Tags: v1.Tags(eksNodeGroup.Tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -433,7 +433,7 @@ func parseEKSNodeGroupStatus(status ekstypes.NodegroupStatus) v1.NodeGroupStatus func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroupArgs) (*v1.NodeGroup, error) { err := validateCreateNodeGroupArgs(args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } eksClient := eks.NewFromConfig(c.awsConfig) @@ -444,7 +444,7 @@ func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroup ID: args.ClusterID, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Convert the target cluster's subnet IDs to AWS subnet IDs @@ -456,7 +456,7 @@ func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroup // Create the node role that will be attached to all nodes in the node group nodeRoleARN, err := c.createNodeRole(ctx, iamClient, cluster, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Convert the tags to AWS tags @@ -477,7 +477,7 @@ func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroup // AWS expects the disk size in GiB, so we need to convert the disk size to GiB diskSizeGiB, err := args.DiskSize.ByteCountInUnitInt32(v1.Gibibyte) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } output, err := eksClient.CreateNodegroup(ctx, &eks.CreateNodegroupInput{ @@ -485,8 +485,8 @@ func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroup NodegroupName: aws.String(args.Name), NodeRole: aws.String(nodeRoleARN), ScalingConfig: &ekstypes.NodegroupScalingConfig{ - MinSize: aws.Int32(int32(args.MinNodeCount)), //nolint:gosec // checked in input validation - MaxSize: aws.Int32(int32(args.MaxNodeCount)), //nolint:gosec // checked in input validation + MinSize: aws.Int32(int32(args.MinNodeCount)), + MaxSize: aws.Int32(int32(args.MaxNodeCount)), }, DiskSize: aws.Int32(diskSizeGiB), Subnets: subnetIDs, @@ -496,12 +496,12 @@ func (c *AWSClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroup Tags: tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevNodeGroup, err := parseEKSNodeGroup(output.Nodegroup) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -532,7 +532,7 @@ func validateCreateNodeGroupArgs(args v1.CreateNodeGroupArgs) error { if args.MinNodeCount > math.MaxInt32 { errs = append(errs, errNodeGroupMinNodeCountMustBeLessThanOrEqualToMaxInt32) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } func (c *AWSClient) createNodeRole(ctx context.Context, iamClient *iam.Client, cluster *v1.Cluster, args v1.CreateNodeGroupArgs) (string, error) { @@ -578,7 +578,7 @@ func (c *AWSClient) createNodeRole(ctx context.Context, iamClient *iam.Client, c } output, err := iamClient.CreateRole(ctx, input) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } // Attach the required managed policies to the role @@ -593,7 +593,7 @@ func (c *AWSClient) createNodeRole(ctx context.Context, iamClient *iam.Client, c PolicyArn: aws.String(policyArn), }) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } } @@ -609,15 +609,15 @@ func (c *AWSClient) GetNodeGroup(ctx context.Context, args v1.GetNodeGroupArgs) }) if err != nil { var noSuchEntityError *ekstypes.ResourceNotFoundException - if errors.As(err, &noSuchEntityError) { + if clouderrors.As(err, &noSuchEntityError) { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevNodeGroup, err := parseEKSNodeGroup(eksNodeGroup.Nodegroup) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -627,14 +627,14 @@ func (c *AWSClient) ModifyNodeGroup(ctx context.Context, args v1.ModifyNodeGroup err := validateModifyNodeGroupArgs(args) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } cluster, err := c.GetCluster(ctx, v1.GetClusterArgs{ ID: args.ClusterID, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } nodeGroup, err := c.GetNodeGroup(ctx, v1.GetNodeGroupArgs{ @@ -642,20 +642,20 @@ func (c *AWSClient) ModifyNodeGroup(ctx context.Context, args v1.ModifyNodeGroup ID: args.ID, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } _, err = eksClient.UpdateNodegroupConfig(ctx, &eks.UpdateNodegroupConfigInput{ ClusterName: aws.String(cluster.GetName()), NodegroupName: aws.String(nodeGroup.GetName()), ScalingConfig: &ekstypes.NodegroupScalingConfig{ - DesiredSize: aws.Int32(int32(args.MinNodeCount)), //nolint:gosec // checked in input validation - MinSize: aws.Int32(int32(args.MinNodeCount)), //nolint:gosec // checked in input validation - MaxSize: aws.Int32(int32(args.MaxNodeCount)), //nolint:gosec // checked in input validation + DesiredSize: aws.Int32(int32(args.MinNodeCount)), + MinSize: aws.Int32(int32(args.MinNodeCount)), + MaxSize: aws.Int32(int32(args.MaxNodeCount)), }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil } @@ -677,7 +677,7 @@ func validateModifyNodeGroupArgs(args v1.ModifyNodeGroupArgs) error { if args.MaxNodeCount > math.MaxInt32 { errs = append(errs, errNodeGroupMaxNodeCountMustBeLessThanOrEqualToMaxInt32) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroupArgs) error { @@ -689,7 +689,7 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup ID: args.ClusterID, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Fetch the target node group @@ -698,7 +698,7 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup ID: args.ID, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Get the roles associated with the node group @@ -707,7 +707,7 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup PathPrefix: aws.String(iamPath), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d roles associated with node group", len(roles.Roles)), @@ -725,13 +725,13 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup PrincipalArn: role.Arn, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the role err = c.deleteRole(ctx, iamClient, role) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -745,7 +745,7 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup NodegroupName: aws.String(nodeGroup.GetName()), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil @@ -755,7 +755,7 @@ func (c *AWSClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGroup func (c *AWSClient) SetClusterUser(ctx context.Context, args v1.SetClusterUserArgs) (*v1.ClusterUser, error) { err := validatePutUserArgs(args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Fetch the cluster the user key will be added to @@ -763,43 +763,43 @@ func (c *AWSClient) SetClusterUser(ctx context.Context, args v1.SetClusterUserAr ID: args.ClusterID, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) } // Create a clientset to interact with the cluster using the bearer token and CA certificate clientset, err := c.newK8sClient(ctx, cluster) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) } // Prepare the private key for the CSR privateKeyBytes, err := base64.StdEncoding.DecodeString(args.RSAPEMBase64) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode base64 string: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode base64 string: %w", err)) } // Parse the private key privateKey, err := rsa.BytesToRSAKey(privateKeyBytes) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to parse private key: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to parse private key: %w", err)) } // Create the client certificate to allow for external access to the cluster for the holders of this private key signedCertificate, err := cloudk8s.ClientCertificateData(ctx, clientset, args.Username, privateKey) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get signed certificate: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get signed certificate: %w", err)) } // Make the user a cluster admin err = cloudk8s.SetUserRole(ctx, clientset, args.Username, args.Role) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to set user role: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to set user role: %w", err)) } // Get the certificate authority data certificateAuthorityData, err := base64.StdEncoding.DecodeString(cluster.GetClusterCACertificateBase64()) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode certificate authority data: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode certificate authority data: %w", err)) } // Generate the complete kubeconfig @@ -820,7 +820,7 @@ func (c *AWSClient) SetClusterUser(ctx context.Context, args v1.SetClusterUserAr }, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to write kubeconfig: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to write kubeconfig: %w", err)) } brevClusterUser, err := v1.NewClusterUser(v1.ClusterUserSettings{ @@ -833,7 +833,7 @@ func (c *AWSClient) SetClusterUser(ctx context.Context, args v1.SetClusterUserAr KubeconfigBase64: base64.StdEncoding.EncodeToString(kubeconfigBytes), }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create cluster user: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create cluster user: %w", err)) } return brevClusterUser, nil } @@ -852,7 +852,7 @@ func validatePutUserArgs(args v1.SetClusterUserArgs) error { if args.RSAPEMBase64 == "" { errs = append(errs, errRSAPEMBase64IsRequired) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } func (c *AWSClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterArgs) error { @@ -864,7 +864,7 @@ func (c *AWSClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterArgs ID: args.ID, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the cluster @@ -873,7 +873,7 @@ func (c *AWSClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterArgs Name: aws.String(cluster.GetName()), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Get the roles associated with the cluster @@ -881,7 +881,7 @@ func (c *AWSClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterArgs PathPrefix: aws.String(iamRolePathPrefix), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d roles associated with cluster", len(roles.Roles)), @@ -892,7 +892,7 @@ func (c *AWSClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterArgs for _, role := range roles.Roles { err = c.deleteRole(ctx, iamClient, role) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -905,7 +905,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role RoleName: role.RoleName, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d instance profiles associated with role", len(instanceProfiles.InstanceProfiles)), @@ -922,7 +922,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role RoleName: role.RoleName, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the instance profile @@ -934,7 +934,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role InstanceProfileName: instanceProfile.InstanceProfileName, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -943,7 +943,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role RoleName: role.RoleName, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d policies associated with role", len(attachedPolicies.AttachedPolicies)), @@ -959,7 +959,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role PolicyArn: policy.PolicyArn, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -969,7 +969,7 @@ func (c *AWSClient) deleteRole(ctx context.Context, iamClient *iam.Client, role RoleName: role.RoleName, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil @@ -992,13 +992,13 @@ func getNodeGroupIAMRolePath(clusterRefID string, nodeGroupRefID string) string func (c *AWSClient) newK8sClient(ctx context.Context, cluster *v1.Cluster) (*kubernetes.Clientset, error) { newK8sConfig, err := c.newK8sConfig(ctx, cluster) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create k8s config: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create k8s config: %w", err)) } // Create a clientset to interact with the cluster using the bearer token and CA certificate clientset, err := kubernetes.NewForConfig(newK8sConfig) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) } return clientset, nil @@ -1008,7 +1008,7 @@ func (c *AWSClient) newK8sConfig(ctx context.Context, cluster *v1.Cluster) (*res // Decode the cluster CA certificate clusterCACertificate, err := base64.StdEncoding.DecodeString(cluster.GetClusterCACertificateBase64()) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode cluster CA certificate: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode cluster CA certificate: %w", err)) } // Get a bearer token to authenticate to the cluster @@ -1016,14 +1016,14 @@ func (c *AWSClient) newK8sConfig(ctx context.Context, cluster *v1.Cluster) (*res cache := false tokenGenerator, err := token.NewGenerator(forwardSessionName, cache) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create token generator: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create token generator: %w", err)) } token, err := tokenGenerator.GetWithOptions(ctx, &token.GetTokenOptions{ ClusterID: cluster.GetName(), }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to generate token: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to generate token: %w", err)) } return &rest.Config{ diff --git a/v1/providers/aws/network.go b/v1/providers/aws/network.go index e68f7c8..019a507 100644 --- a/v1/providers/aws/network.go +++ b/v1/providers/aws/network.go @@ -11,7 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/aws/smithy-go" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" ) @@ -23,7 +23,7 @@ func (c *AWSClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v1.V // If there are no public subnets but there are private subnets, return an error, as we need at least one // public subnet to create NAT gateways for private subnets. if len(publicSubnetArgs) == 0 && len(privateSubnetArgs) > 0 { - return nil, errors.WrapAndTrace(fmt.Errorf("VPC creation with private subnets requires at least one public subnet, but no public subnets were provided for VPC %s", args.RefID)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("VPC creation with private subnets requires at least one public subnet, but no public subnets were provided for VPC %s", args.RefID)) } // Create the AWS client in the specified region @@ -32,7 +32,7 @@ func (c *AWSClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v1.V // Create the VPC and subnets awsVPC, subnets, err := c.createCompleteVPC(ctx, awsClient, args, publicSubnetArgs, privateSubnetArgs) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } tags := make(map[string]string) @@ -53,7 +53,7 @@ func (c *AWSClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v1.V Tags: v1.Tags(tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevVPC, nil } @@ -73,31 +73,31 @@ func (c *AWSClient) createCompleteVPC(ctx context.Context, awsClient *ec2.Client // Create the VPC vpc, err := c.createVPC(ctx, awsClient, args) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } // Enable DNS support for the VPC err = c.enableVPCDNSSupport(ctx, awsClient, vpc) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } // Enable DNS hostnames for the VPC err = c.enableVPCDNSHostnames(ctx, awsClient, vpc) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } // Create an Internet Gateway for the VPC _, err = c.createInternetGateway(ctx, awsClient, vpc, args) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } // Get the availability zones in the context region availabilityZones, err := getAvailabilityZones(ctx, awsClient) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } var subnets []*v1.Subnet @@ -111,13 +111,13 @@ func (c *AWSClient) createCompleteVPC(ctx context.Context, awsClient *ec2.Client // Create the public subnet publicSubnet, err := c.createPublicSubnet(ctx, awsClient, vpc, subnetArgs, args, availabilityZone) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } publicSubnets = append(publicSubnets, publicSubnet) brevSubnet, err := awsSubnetToCloudSubnet(publicSubnet, v1.SubnetTypePublic, vpc) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } subnets = append(subnets, brevSubnet) } @@ -131,12 +131,12 @@ func (c *AWSClient) createCompleteVPC(ctx context.Context, awsClient *ec2.Client // Create the private subnet privateSubnet, err := c.createPrivateSubnet(ctx, awsClient, vpc, natGatewaySubnet, subnetArgs) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } brevSubnet, err := awsSubnetToCloudSubnet(privateSubnet, v1.SubnetTypePrivate, vpc) if err != nil { - return nil, nil, errors.WrapAndTrace(err) + return nil, nil, clouderrors.WrapAndTrace(err) } subnets = append(subnets, brevSubnet) } @@ -147,7 +147,7 @@ func (c *AWSClient) createCompleteVPC(ctx context.Context, awsClient *ec2.Client func getAvailabilityZones(ctx context.Context, awsClient *ec2.Client) ([]string, error) { describeAvailabilityZonesOutput, err := awsClient.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{}) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } availabilityZones := []string{} @@ -191,7 +191,7 @@ func (c *AWSClient) createVPC(ctx context.Context, awsClient *ec2.Client, args v } output, err := awsClient.CreateVpc(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return output.Vpc, nil @@ -208,7 +208,7 @@ func (c *AWSClient) enableVPCDNSSupport(ctx context.Context, awsClient *ec2.Clie c.logger.Debug(ctx, "enabling DNS support for VPC", v1.Field{Key: "vpcID", Value: *vpc.VpcId}) _, err := awsClient.ModifyVpcAttribute(ctx, input) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil } @@ -224,7 +224,7 @@ func (c *AWSClient) enableVPCDNSHostnames(ctx context.Context, awsClient *ec2.Cl c.logger.Debug(ctx, "enabling DNS hostnames for VPC", v1.Field{Key: "vpcID", Value: *vpc.VpcId}) _, err := awsClient.ModifyVpcAttribute(ctx, input) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil } @@ -256,7 +256,7 @@ func (c *AWSClient) createInternetGateway(ctx context.Context, awsClient *ec2.Cl } createOutput, err := awsClient.CreateInternetGateway(ctx, createInput) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } internetGateway := createOutput.InternetGateway @@ -271,7 +271,7 @@ func (c *AWSClient) createInternetGateway(ctx context.Context, awsClient *ec2.Cl VpcId: vpc.VpcId, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return internetGateway, nil @@ -294,7 +294,7 @@ func awsSubnetToCloudSubnet(awsSubnet *types.Subnet, subnetType v1.SubnetType, v Tags: v1.Tags(tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevSubnet, nil } @@ -338,7 +338,7 @@ func (c *AWSClient) createPublicSubnet(ctx context.Context, awsClient *ec2.Clien } output, err := awsClient.CreateSubnet(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnet := output.Subnet @@ -346,7 +346,7 @@ func (c *AWSClient) createPublicSubnet(ctx context.Context, awsClient *ec2.Clien // Get or create the Public Route Table for the VPC publicRouteTable, err := c.getOrCreatePublicRouteTable(ctx, awsClient, vpc, createVPCArgs) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Associate the Public Subnet with the Public Route Table @@ -355,7 +355,7 @@ func (c *AWSClient) createPublicSubnet(ctx context.Context, awsClient *ec2.Clien SubnetId: subnet.SubnetId, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return subnet, nil @@ -378,7 +378,7 @@ func (c *AWSClient) getOrCreatePublicRouteTable(ctx context.Context, awsClient * }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // If there are multiple public route tables, return an error @@ -420,7 +420,7 @@ func (c *AWSClient) getOrCreatePublicRouteTable(ctx context.Context, awsClient * } output, err := awsClient.CreateRouteTable(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } routeTable := output.RouteTable @@ -428,7 +428,7 @@ func (c *AWSClient) getOrCreatePublicRouteTable(ctx context.Context, awsClient * // Get or create the Internet Gateway internetGateway, err := c.getOrCreateInternetGateway(ctx, awsClient, vpc, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create the route to the Internet Gateway @@ -438,7 +438,7 @@ func (c *AWSClient) getOrCreatePublicRouteTable(ctx context.Context, awsClient * DestinationCidrBlock: aws.String("0.0.0.0/0"), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return routeTable, nil @@ -461,7 +461,7 @@ func (c *AWSClient) getOrCreateInternetGateway(ctx context.Context, awsClient *e }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // If there are multiple internet gateways, return an error @@ -502,7 +502,7 @@ func (c *AWSClient) getOrCreateInternetGateway(ctx context.Context, awsClient *e } output, err := awsClient.CreateInternetGateway(ctx, input) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return output.InternetGateway, nil @@ -547,13 +547,13 @@ func (c *AWSClient) createPrivateSubnet(ctx context.Context, awsClient *ec2.Clie } createSubnetOutput, err := awsClient.CreateSubnet(ctx, createSubnetInput) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Get or create the NAT Gateway natGateway, err := c.createNatGateway(ctx, awsClient, vpc, natGatewaySubnet, createSubnetArgs) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create a private route table @@ -579,7 +579,7 @@ func (c *AWSClient) createPrivateSubnet(ctx context.Context, awsClient *ec2.Clie } createRouteTableOutput, err := awsClient.CreateRouteTable(ctx, createRouteTableInput) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } routeTable := createRouteTableOutput.RouteTable @@ -590,7 +590,7 @@ func (c *AWSClient) createPrivateSubnet(ctx context.Context, awsClient *ec2.Clie SubnetId: createSubnetOutput.Subnet.SubnetId, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create a route to the NAT Gateway @@ -600,7 +600,7 @@ func (c *AWSClient) createPrivateSubnet(ctx context.Context, awsClient *ec2.Clie GatewayId: natGateway.NatGatewayId, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return createSubnetOutput.Subnet, nil @@ -612,7 +612,7 @@ func (c *AWSClient) createNatGateway(ctx context.Context, awsClient *ec2.Client, Domain: types.DomainTypeVpc, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create the NAT Gateway in the provided subnet @@ -646,7 +646,7 @@ func (c *AWSClient) createNatGateway(ctx context.Context, awsClient *ec2.Client, } createNatGatewayOutput, err := awsClient.CreateNatGateway(ctx, createNatGatewayInput) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } natGateway := createNatGatewayOutput.NatGateway @@ -666,7 +666,7 @@ func (c *AWSClient) createNatGateway(ctx context.Context, awsClient *ec2.Client, NatGatewayIds: []string{*natGateway.NatGatewayId}, }, 10*time.Minute) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return natGateway, nil @@ -678,7 +678,7 @@ func (c *AWSClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, er awsVPC, err := getVPC(ctx, awsClient, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } tags := make(map[string]string) @@ -695,7 +695,7 @@ func (c *AWSClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, er subnets, err := getVPCSubnets(ctx, awsClient, awsVPC) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevVPC, err := v1.NewVPC(v1.VPCSettings{ @@ -711,7 +711,7 @@ func (c *AWSClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, er Tags: v1.Tags(tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevVPC, nil } @@ -722,10 +722,10 @@ func getVPC(ctx context.Context, awsClient *ec2.Client, args v1.GetVPCArgs) (*ty }) if err != nil { var apiErr smithy.APIError - if errors.As(err, &apiErr) && apiErr.ErrorCode() == "InvalidVpcID.NotFound" { + if clouderrors.As(err, &apiErr) && apiErr.ErrorCode() == "InvalidVpcID.NotFound" { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if len(describeVPCsOutput.Vpcs) == 0 { @@ -750,7 +750,7 @@ func getVPCStatus(ctx context.Context, awsClient *ec2.Client, awsVPC *types.Vpc) }, }) if err != nil { - return v1.VPCStatusAvailable, errors.WrapAndTrace(err) + return v1.VPCStatusAvailable, clouderrors.WrapAndTrace(err) } for _, natGateway := range natGateways.NatGateways { @@ -772,7 +772,7 @@ func getVPCSubnets(ctx context.Context, awsClient *ec2.Client, awsVPC *types.Vpc }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnets := make([]*v1.Subnet, 0) @@ -796,7 +796,7 @@ func getVPCSubnets(ctx context.Context, awsClient *ec2.Client, awsVPC *types.Vpc Tags: v1.Tags(tags), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnets = append(subnets, brevSubnet) } @@ -808,7 +808,7 @@ func (c *AWSClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) error err := c.deleteVPC(ctx, awsClient, string(args.ID)) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil } @@ -816,22 +816,22 @@ func (c *AWSClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) error func (c *AWSClient) deleteVPC(ctx context.Context, awsClient *ec2.Client, vpcID string) error { err := c.deleteNATGateways(ctx, awsClient, vpcID) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } err = c.deleteInternetGateways(ctx, awsClient, vpcID) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } err = c.deleteSubnets(ctx, awsClient, vpcID) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } err = c.deleteRouteTables(ctx, awsClient, vpcID) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the VPC @@ -840,7 +840,7 @@ func (c *AWSClient) deleteVPC(ctx context.Context, awsClient *ec2.Client, vpcID VpcId: aws.String(vpcID), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil @@ -857,7 +857,7 @@ func (c *AWSClient) deleteNATGateways(ctx context.Context, awsClient *ec2.Client }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d NAT gateways", len(describeNatGatewaysOutput.NatGateways)), @@ -878,7 +878,7 @@ func (c *AWSClient) deleteNATGateways(ctx context.Context, awsClient *ec2.Client NatGatewayId: natGateway.NatGatewayId, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Wait until the NAT Gateway is deleted @@ -894,7 +894,7 @@ func (c *AWSClient) deleteNATGateways(ctx context.Context, awsClient *ec2.Client NatGatewayIds: []string{*natGateway.NatGatewayId}, }, 10*time.Minute) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Release the Elastic IP address @@ -906,7 +906,7 @@ func (c *AWSClient) deleteNATGateways(ctx context.Context, awsClient *ec2.Client AllocationId: natGateway.NatGatewayAddresses[0].AllocationId, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -924,7 +924,7 @@ func (c *AWSClient) deleteInternetGateways(ctx context.Context, awsClient *ec2.C }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } c.logger.Debug(ctx, fmt.Sprintf("found %d Internet gateways", len(describeInternetGatewaysOutput.InternetGateways)), @@ -941,7 +941,7 @@ func (c *AWSClient) deleteInternetGateways(ctx context.Context, awsClient *ec2.C VpcId: aws.String(vpcID), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the Internet Gateway @@ -953,7 +953,7 @@ func (c *AWSClient) deleteInternetGateways(ctx context.Context, awsClient *ec2.C InternetGatewayId: internetGateway.InternetGatewayId, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -971,7 +971,7 @@ func (c *AWSClient) deleteSubnets(ctx context.Context, awsClient *ec2.Client, vp }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete all subnets @@ -988,7 +988,7 @@ func (c *AWSClient) deleteSubnets(ctx context.Context, awsClient *ec2.Client, vp SubnetId: subnet.SubnetId, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -1010,7 +1010,7 @@ func (c *AWSClient) deleteRouteTables(ctx context.Context, awsClient *ec2.Client }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete all route tables @@ -1026,7 +1026,7 @@ func (c *AWSClient) deleteRouteTables(ctx context.Context, awsClient *ec2.Client RouteTableId: routeTable.RouteTableId, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } diff --git a/v1/providers/fluidstack/instance.go b/v1/providers/fluidstack/instance.go index 6e5e9c2..992a520 100644 --- a/v1/providers/fluidstack/instance.go +++ b/v1/providers/fluidstack/instance.go @@ -143,7 +143,8 @@ func convertFluidStackInstanceToV1Instance(fsInstance openapi.Instance) *v1.Inst Status: v1.Status{ LifecycleStatus: lifecycleStatus, }, - Tags: make(map[string]string), + Tags: make(map[string]string), + TunneledSSH: false, } for key, value := range fsInstance.Tags { diff --git a/v1/providers/fluidstack/instancetype.go b/v1/providers/fluidstack/instancetype.go index a677966..d77e358 100644 --- a/v1/providers/fluidstack/instancetype.go +++ b/v1/providers/fluidstack/instancetype.go @@ -111,5 +111,6 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy Location: location, Provider: CloudProviderID, Cloud: CloudProviderID, + TunneledSSH: false, } } diff --git a/v1/providers/lambdalabs/instance.go b/v1/providers/lambdalabs/instance.go index c47d503..32a93e4 100644 --- a/v1/providers/lambdalabs/instance.go +++ b/v1/providers/lambdalabs/instance.go @@ -184,11 +184,12 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api }, - SSHUser: "ubuntu", - SSHPort: 22, - Stoppable: false, - Rebootable: true, - Location: instance.Region.Name, + SSHUser: "ubuntu", + SSHPort: 22, + Stoppable: false, + Rebootable: true, + Location: instance.Region.Name, + TunneledSSH: false, } inst.InstanceTypeID = v1.MakeGenericInstanceTypeIDFromInstance(inst) return &inst diff --git a/v1/providers/lambdalabs/instance_test.go b/v1/providers/lambdalabs/instance_test.go index 6020659..ef4cff4 100644 --- a/v1/providers/lambdalabs/instance_test.go +++ b/v1/providers/lambdalabs/instance_test.go @@ -55,6 +55,7 @@ func TestLambdaLabsClient_CreateInstance_Success(t *testing.T) { assert.Equal(t, instanceID, string(instance.CloudID)) assert.Contains(t, instance.Name, "test-instance") assert.Equal(t, v1.LifecycleStatusRunning, instance.Status.LifecycleStatus) + assert.False(t, instance.TunneledSSH) } func TestLambdaLabsClient_CreateInstance_WithoutPublicKey(t *testing.T) { @@ -142,6 +143,7 @@ func TestLambdaLabsClient_GetInstance_Success(t *testing.T) { assert.Equal(t, instanceID, string(instance.CloudID)) assert.Equal(t, "test-instance", instance.Name) assert.Equal(t, v1.LifecycleStatusRunning, instance.Status.LifecycleStatus) + assert.False(t, instance.TunneledSSH) } func TestLambdaLabsClient_GetInstance_NotFound(t *testing.T) { @@ -175,7 +177,9 @@ func TestLambdaLabsClient_ListInstances_Success(t *testing.T) { require.NoError(t, err) assert.Len(t, instances, 2) assert.Equal(t, "instance-1", string(instances[0].CloudID)) + assert.False(t, instances[0].TunneledSSH) assert.Equal(t, "instance-2", string(instances[1].CloudID)) + assert.False(t, instances[1].TunneledSSH) } func TestLambdaLabsClient_ListInstances_Empty(t *testing.T) { diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index 2f91c6d..7c662f3 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -206,6 +206,7 @@ func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType ope BasePrice: &amount, Provider: CloudProviderID, Cloud: CloudProviderID, + TunneledSSH: false, } it.ID = v1.MakeGenericInstanceTypeID(it) return it, nil diff --git a/v1/providers/lambdalabs/instancetype_test.go b/v1/providers/lambdalabs/instancetype_test.go index 9295d7f..7549aef 100644 --- a/v1/providers/lambdalabs/instancetype_test.go +++ b/v1/providers/lambdalabs/instancetype_test.go @@ -32,6 +32,7 @@ func TestLambdaLabsClient_GetInstanceTypes_Success(t *testing.T) { require.NotNil(t, a10Type) assert.Equal(t, "gpu_1x_a10", a10Type.Type) assert.True(t, a10Type.IsAvailable) + assert.False(t, a10Type.TunneledSSH) assert.Len(t, a10Type.SupportedGPUs, 1) assert.Equal(t, int32(1), a10Type.SupportedGPUs[0].Count) assert.Equal(t, v1.ManufacturerNVIDIA, a10Type.SupportedGPUs[0].Manufacturer) diff --git a/v1/providers/launchpad/gen/launchpad/test/api_auth_test.go b/v1/providers/launchpad/gen/launchpad/test/api_auth_test.go index f2db4fd..bb71399 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_auth_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_auth_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_AuthAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test AuthAPIService V1AuthLoginCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.AuthAPI.V1AuthLoginCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_AuthAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test AuthAPIService V1AuthLogoutCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.AuthAPI.V1AuthLogoutCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_AuthAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test AuthAPIService V1AuthPasswordChangeCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.AuthAPI.V1AuthPasswordChangeCreate(context.Background()).Execute() @@ -55,11 +50,9 @@ func Test_openapi_AuthAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test AuthAPIService V1AuthRedirectRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.AuthAPI.V1AuthRedirectRetrieve(context.Background()).Execute() @@ -67,7 +60,5 @@ func Test_openapi_AuthAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_deployments_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_deployments_test.go index 5dbe6e5..6801704 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_deployments_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_deployments_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogDeploymentsAPI.V1CatalogDeploymentsBulkPartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogDeploymentsAPI.V1CatalogDeploymentsCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -57,11 +52,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -71,11 +64,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsInstancesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -85,11 +76,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogDeploymentsAPI.V1CatalogDeploymentsList(context.Background()).Execute() @@ -97,11 +86,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -111,11 +98,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -125,11 +110,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -139,11 +122,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -154,11 +135,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -169,11 +148,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsNotesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -184,11 +161,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -198,11 +173,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsPipelinesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -212,11 +185,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsPipelinesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -226,11 +197,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsPipelinesTriggerCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -240,11 +209,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -254,11 +221,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsServicesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -268,11 +233,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsServicesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -282,11 +245,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsSshKeysCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -296,11 +257,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsSshKeysDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -310,11 +269,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsSshKeysList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -324,22 +281,18 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsStatsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test httpRes, err := apiClient.CatalogDeploymentsAPI.V1CatalogDeploymentsStatsRetrieve(context.Background()).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsTasksCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -349,11 +302,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsTasksList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -363,11 +314,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsTasksRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var deploymentId string @@ -378,11 +327,9 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogDeploymentsAPIService V1CatalogDeploymentsUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -392,7 +339,5 @@ func Test_openapi_CatalogDeploymentsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_experiences_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_experiences_test.go index 651490a..9ed1c59 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_experiences_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_experiences_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesBulkCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogExperiencesAPI.V1CatalogExperiencesBulkCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogExperiencesAPI.V1CatalogExperiencesBulkPartialUpdate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogExperiencesAPI.V1CatalogExperiencesCreate(context.Background()).Execute() @@ -55,11 +50,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -68,11 +61,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -82,11 +73,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogExperiencesAPI.V1CatalogExperiencesList(context.Background()).Execute() @@ -94,11 +83,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -108,11 +95,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -122,11 +107,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -136,11 +119,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -151,11 +132,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -166,11 +145,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesNotesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var experienceId string @@ -181,11 +158,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -195,11 +170,9 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -209,22 +182,18 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesStatsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test httpRes, err := apiClient.CatalogExperiencesAPI.V1CatalogExperiencesStatsRetrieve(context.Background()).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogExperiencesAPIService V1CatalogExperiencesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -234,7 +203,5 @@ func Test_openapi_CatalogExperiencesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_gpu_os_choices_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_gpu_os_choices_test.go index 45859a9..1efcbd4 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_gpu_os_choices_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_gpu_os_choices_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogGpuOsChoicesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogGpuOsChoicesAPIService V1CatalogGpuOsChoicesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogGpuOsChoicesAPI.V1CatalogGpuOsChoicesCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogGpuOsChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogGpuOsChoicesAPIService V1CatalogGpuOsChoicesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogGpuOsChoicesAPI.V1CatalogGpuOsChoicesList(context.Background()).Execute() @@ -43,7 +40,5 @@ func Test_openapi_CatalogGpuOsChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_instance_types_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_instance_types_test.go index de18433..2f6a7e7 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_instance_types_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_instance_types_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogInstanceTypesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogInstanceTypesAPIService V1CatalogInstanceTypesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogInstanceTypesAPI.V1CatalogInstanceTypesList(context.Background()).Execute() @@ -31,7 +30,5 @@ func Test_openapi_CatalogInstanceTypesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_persona_choices_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_persona_choices_test.go index 2ed0af8..93b07d2 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_persona_choices_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_persona_choices_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogPersonaChoicesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogPersonaChoicesAPIService V1CatalogPersonaChoicesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogPersonaChoicesAPI.V1CatalogPersonaChoicesCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogPersonaChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogPersonaChoicesAPIService V1CatalogPersonaChoicesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogPersonaChoicesAPI.V1CatalogPersonaChoicesList(context.Background()).Execute() @@ -43,7 +40,5 @@ func Test_openapi_CatalogPersonaChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_runtimes_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_runtimes_test.go index a271967..b679b5b 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_runtimes_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_runtimes_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogRuntimesAPI.V1CatalogRuntimesCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -44,11 +41,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -58,11 +53,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogRuntimesAPI.V1CatalogRuntimesList(context.Background()).Execute() @@ -70,11 +63,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -84,11 +75,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -98,11 +87,9 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogRuntimesAPIService V1CatalogRuntimesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -112,7 +99,5 @@ func Test_openapi_CatalogRuntimesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_catalog_vgpu_profile_choices_test.go b/v1/providers/launchpad/gen/launchpad/test/api_catalog_vgpu_profile_choices_test.go index 94e8be5..dc7b8d3 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_catalog_vgpu_profile_choices_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_catalog_vgpu_profile_choices_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_CatalogVgpuProfileChoicesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test CatalogVgpuProfileChoicesAPIService V1CatalogVgpuProfileChoicesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogVgpuProfileChoicesAPI.V1CatalogVgpuProfileChoicesCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_CatalogVgpuProfileChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test CatalogVgpuProfileChoicesAPIService V1CatalogVgpuProfileChoicesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.CatalogVgpuProfileChoicesAPI.V1CatalogVgpuProfileChoicesList(context.Background()).Execute() @@ -43,7 +40,5 @@ func Test_openapi_CatalogVgpuProfileChoicesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_health_test.go b/v1/providers/launchpad/gen/launchpad/test/api_health_test.go index 508bb94..74d62c3 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_health_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_health_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_HealthAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test HealthAPIService HealthRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.HealthAPI.HealthRetrieve(context.Background()).Execute() @@ -31,7 +30,5 @@ func Test_openapi_HealthAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_identity_profile_test.go b/v1/providers/launchpad/gen/launchpad/test/api_identity_profile_test.go index d5ec9d2..2045e75 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_identity_profile_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_identity_profile_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_IdentityProfileAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test IdentityProfileAPIService V1IdentityProfilePartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.IdentityProfileAPI.V1IdentityProfilePartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_IdentityProfileAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test IdentityProfileAPIService V1IdentityProfileRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.IdentityProfileAPI.V1IdentityProfileRetrieve(context.Background()).Execute() @@ -43,7 +40,5 @@ func Test_openapi_IdentityProfileAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_clusters_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_clusters_test.go index 3f1d09d..1b63669 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_clusters_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_clusters_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryClustersAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryClustersAPIService V1InventoryClustersBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryClustersAPI.V1InventoryClustersBulkPartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryClustersAPI.V1InventoryClustersCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -56,11 +51,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -70,11 +63,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryClustersAPI.V1InventoryClustersList(context.Background()).Execute() @@ -82,11 +73,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -96,11 +85,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersPipelinesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var clusterId string @@ -110,11 +97,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersPipelinesTriggerCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -124,11 +109,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersProvisionCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryClustersAPI.V1InventoryClustersProvisionCreate(context.Background()).Execute() @@ -136,11 +119,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersProvisionDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -150,11 +131,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersProvisionPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -164,11 +143,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -178,22 +155,18 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersStatsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test httpRes, err := apiClient.InventoryClustersAPI.V1InventoryClustersStatsRetrieve(context.Background()).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersTenantsCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var clusterId string @@ -203,11 +176,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersTenantsDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var clusterId string @@ -217,11 +188,9 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryClustersAPIService V1InventoryClustersUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -231,7 +200,5 @@ func Test_openapi_InventoryClustersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_gpus_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_gpus_test.go index 4474858..e0e4cca 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_gpus_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_gpus_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryGpusAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryGpusAPIService V1InventoryGpusBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryGpusAPI.V1InventoryGpusBulkPartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryGpusAPI.V1InventoryGpusCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -56,11 +51,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -70,11 +63,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryGpusAPI.V1InventoryGpusList(context.Background()).Execute() @@ -82,11 +73,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -96,11 +85,9 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -110,22 +97,18 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusStatsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test httpRes, err := apiClient.InventoryGpusAPI.V1InventoryGpusStatsRetrieve(context.Background()).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryGpusAPIService V1InventoryGpusUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -135,7 +118,5 @@ func Test_openapi_InventoryGpusAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_instances_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_instances_test.go index 078c4ad..b32544c 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_instances_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_instances_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryInstancesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryInstancesAPI.V1InventoryInstancesBulkPartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryInstancesAPI.V1InventoryInstancesCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -56,11 +51,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -70,11 +63,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryInstancesAPI.V1InventoryInstancesList(context.Background()).Execute() @@ -82,11 +73,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -96,11 +85,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -110,11 +97,9 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryInstancesAPIService V1InventoryInstancesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -124,7 +109,5 @@ func Test_openapi_InventoryInstancesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_locations_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_locations_test.go index fa7658d..ff7176f 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_locations_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_locations_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryLocationsAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryLocationsAPI.V1InventoryLocationsCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -44,11 +41,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -58,11 +53,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryLocationsAPI.V1InventoryLocationsList(context.Background()).Execute() @@ -70,11 +63,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -84,11 +75,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -98,11 +87,9 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryLocationsAPIService V1InventoryLocationsUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -112,7 +99,5 @@ func Test_openapi_InventoryLocationsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_nodes_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_nodes_test.go index 302b4e4..8e3f0e1 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_nodes_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_nodes_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryNodesAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryNodesAPIService V1InventoryNodesBulkCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryNodesAPI.V1InventoryNodesBulkCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryNodesAPI.V1InventoryNodesBulkPartialUpdate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryNodesAPI.V1InventoryNodesCreate(context.Background()).Execute() @@ -55,11 +50,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -68,11 +61,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -82,11 +73,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryNodesAPI.V1InventoryNodesList(context.Background()).Execute() @@ -94,11 +83,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -108,11 +95,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -122,11 +107,9 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryNodesAPIService V1InventoryNodesUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -136,7 +119,5 @@ func Test_openapi_InventoryNodesAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_oems_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_oems_test.go index 3a8a11d..69cb0dc 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_oems_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_oems_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryOemsAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryOemsAPIService V1InventoryOemsCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryOemsAPI.V1InventoryOemsCreate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -44,11 +41,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -58,11 +53,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryOemsAPI.V1InventoryOemsList(context.Background()).Execute() @@ -70,11 +63,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -84,11 +75,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -98,11 +87,9 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryOemsAPIService V1InventoryOemsUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -112,7 +99,5 @@ func Test_openapi_InventoryOemsAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_inventory_providers_test.go b/v1/providers/launchpad/gen/launchpad/test/api_inventory_providers_test.go index 20da614..d64a560 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_inventory_providers_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_inventory_providers_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_InventoryProvidersAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersBulkPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryProvidersAPI.V1InventoryProvidersBulkPartialUpdate(context.Background()).Execute() @@ -31,11 +30,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersCreate", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryProvidersAPI.V1InventoryProvidersCreate(context.Background()).Execute() @@ -43,11 +40,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersDestroy", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -56,11 +51,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersHistoryList", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -70,11 +63,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersList", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.InventoryProvidersAPI.V1InventoryProvidersList(context.Background()).Execute() @@ -82,11 +73,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersPartialUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -96,11 +85,9 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -110,22 +97,18 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersStatsRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test httpRes, err := apiClient.InventoryProvidersAPI.V1InventoryProvidersStatsRetrieve(context.Background()).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) - }) t.Run("Test InventoryProvidersAPIService V1InventoryProvidersUpdate", func(t *testing.T) { - t.Skip("skip test") // remove to run test var id string @@ -135,7 +118,5 @@ func Test_openapi_InventoryProvidersAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/gen/launchpad/test/api_version_test.go b/v1/providers/launchpad/gen/launchpad/test/api_version_test.go index 41a05bf..617c2c7 100644 --- a/v1/providers/launchpad/gen/launchpad/test/api_version_test.go +++ b/v1/providers/launchpad/gen/launchpad/test/api_version_test.go @@ -11,19 +11,18 @@ package openapi import ( "context" + "testing" + openapiclient "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_openapi_VersionAPIService(t *testing.T) { - configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) t.Run("Test VersionAPIService VersionRetrieve", func(t *testing.T) { - t.Skip("skip test") // remove to run test resp, httpRes, err := apiClient.VersionAPI.VersionRetrieve(context.Background()).Execute() @@ -31,7 +30,5 @@ func Test_openapi_VersionAPIService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) - }) - } diff --git a/v1/providers/launchpad/instance_create.go b/v1/providers/launchpad/instance_create.go index 229dabd..03d1266 100644 --- a/v1/providers/launchpad/instance_create.go +++ b/v1/providers/launchpad/instance_create.go @@ -4,8 +4,8 @@ import ( "context" "net" + "github.com/brevdev/cloud/internal/clouderrors" "github.com/brevdev/cloud/internal/collections" - "github.com/brevdev/cloud/internal/errors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" @@ -21,12 +21,12 @@ func (c *LaunchpadClient) CreateInstance(ctx context.Context, attrs v1.CreateIns createAttrs := launchpadCreateAttrs(attrs) err := createAttrs.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } ipAllowlist := c.getLaunchpadIPAllowlist(ctx, attrs.FirewallRules) instanceTypeInfo, err := getInstanceTypeInfo(createAttrs.InstanceType) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } var region openapi.NullableString @@ -70,19 +70,19 @@ func (c *LaunchpadClient) CreateInstance(ctx context.Context, attrs v1.CreateIns if resp != nil { defer func() { if err := resp.Body.Close(); err != nil { - c.logger.Error(ctx, errors.Wrap(err, "cloud/launchpad error closing response body")) + c.logger.Error(ctx, clouderrors.Wrap(err, "cloud/launchpad error closing response body")) } }() } if err != nil { if resp == nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } lpErr := c.handleLaunchpadAPIErr(ctx, resp, err) if !wasCreateDeploymentRequestAlreadyMade(lpErr) { // handleLaunchpadAPIErr casts error to include error message - return nil, errors.WrapAndTrace(lpErr) + return nil, clouderrors.WrapAndTrace(lpErr) } // Error was "create request already made", so we can continue @@ -90,7 +90,7 @@ func (c *LaunchpadClient) CreateInstance(ctx context.Context, attrs v1.CreateIns inst, err := c.GetInstance(ctx, v1.CloudProviderInstanceID(createDeployment.Id)) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return inst, nil } @@ -113,7 +113,7 @@ func (l launchpadCreateAttrs) validate() error { validation.Field(&l.InstanceType, validation.Required), ) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil } @@ -139,7 +139,7 @@ func (c *LaunchpadClient) getLaunchpadIPAllowlist(ctx context.Context, firewallR for _, cidr := range rule.IPRanges { _, ipNet, err := net.ParseCIDR(cidr) if err != nil { - c.logger.Error(ctx, errors.Wrap(err, "cloud/launchpad error parsing cidr"), v1.LogField("cidr", cidr)) + c.logger.Error(ctx, clouderrors.Wrap(err, "cloud/launchpad error parsing cidr"), v1.LogField("cidr", cidr)) continue } ones, bits := ipNet.Mask.Size() @@ -147,7 +147,7 @@ func (c *LaunchpadClient) getLaunchpadIPAllowlist(ctx context.Context, firewallR if ones == bits { ips = append(ips, ipNet.IP.String()) } else { - c.logger.Error(ctx, errors.New("cloud/launchpad only accept singular IPs"), v1.LogField("cidr", cidr)) + c.logger.Error(ctx, clouderrors.New("cloud/launchpad only accept singular IPs"), v1.LogField("cidr", cidr)) } } } @@ -156,5 +156,5 @@ func (c *LaunchpadClient) getLaunchpadIPAllowlist(ctx context.Context, firewallR } func wasCreateDeploymentRequestAlreadyMade(err error) bool { - return errors.ErrorContains(err, "request_id already exist") + return clouderrors.ErrorContains(err, "request_id already exist") } diff --git a/v1/providers/launchpad/instance_get.go b/v1/providers/launchpad/instance_get.go index fbd9d3e..218a174 100644 --- a/v1/providers/launchpad/instance_get.go +++ b/v1/providers/launchpad/instance_get.go @@ -5,7 +5,7 @@ import ( "github.com/alecthomas/units" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" ) @@ -22,26 +22,26 @@ func (c *LaunchpadClient) GetInstance(ctx context.Context, id v1.CloudProviderIn defer resp.Body.Close() //nolint:errcheck // handled in err check } if err != nil && resp == nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if err != nil { - return nil, errors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) + return nil, clouderrors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) } inst, err := launchpadDeploymentToInstance(getDeployment) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &inst, nil } func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, error) { if deployment == nil { - return v1.Instance{}, errors.WrapAndTrace(errors.New("deployment is nil")) + return v1.Instance{}, clouderrors.WrapAndTrace(clouderrors.New("deployment is nil")) } tags, err := launchpadTagsToInstanceTags(deployment.Tags) if err != nil { - return v1.Instance{}, errors.WrapAndTrace(err) + return v1.Instance{}, clouderrors.WrapAndTrace(err) } var totalStorageSize int32 @@ -81,6 +81,7 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, Location: deployment.GetRegion(), PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), + TunneledSSH: false, } cluster := deployment.GetCluster().Cluster @@ -98,13 +99,13 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, func launchpadTagsToInstanceTags(tags interface{}) (map[string]string, error) { tagsMap, ok := tags.(map[string]interface{}) if !ok { - return nil, errors.WrapAndTrace(errors.New("tags interface casting error")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("tags interface casting error")) } result := make(map[string]string) for key, value := range tagsMap { valueString, ok := value.(string) if !ok { - return nil, errors.WrapAndTrace(errors.New("tags interface casting error")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("tags interface casting error")) } result[key] = valueString } diff --git a/v1/providers/launchpad/instance_list.go b/v1/providers/launchpad/instance_list.go index a6ce8fd..197d9b9 100644 --- a/v1/providers/launchpad/instance_list.go +++ b/v1/providers/launchpad/instance_list.go @@ -3,8 +3,8 @@ package v1 import ( "context" + "github.com/brevdev/cloud/internal/clouderrors" "github.com/brevdev/cloud/internal/collections" - "github.com/brevdev/cloud/internal/errors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" @@ -13,17 +13,17 @@ import ( func (c *LaunchpadClient) ListInstances(ctx context.Context, args v1.ListInstancesArgs) ([]v1.Instance, error) { deployments, err := c.paginateListDeployments(ctx, 1000) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } insts, err := collections.MapE(deployments, func(deployment openapi.Deployment) (v1.Instance, error) { inst, err := launchpadDeploymentToInstance(&deployment) if err != nil { - return v1.Instance{}, errors.WrapAndTrace(err) + return v1.Instance{}, clouderrors.WrapAndTrace(err) } return inst, nil }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if len(args.InstanceIDs) > 0 { @@ -47,10 +47,10 @@ func (c *LaunchpadClient) paginateListDeployments(ctx context.Context, pageSize defer resp.Body.Close() //nolint:errcheck // handled in err check } if err != nil && resp == nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if err != nil { - return nil, errors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) + return nil, clouderrors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) } deployments = append(deployments, listRes.Results...) if len(listRes.Results) < int(pageSize) { diff --git a/v1/providers/launchpad/instance_terminate.go b/v1/providers/launchpad/instance_terminate.go index 741072a..ce59b84 100644 --- a/v1/providers/launchpad/instance_terminate.go +++ b/v1/providers/launchpad/instance_terminate.go @@ -4,14 +4,14 @@ import ( "context" "net/http" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" ) func (c *LaunchpadClient) TerminateInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error { _, err := c.GetInstance(ctx, instanceID) // ensures instance exists and is from credential provider if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } _, resp, err := c.client.CatalogDeploymentsAPI.V1CatalogDeploymentsDestroy(c.makeAuthContext(ctx), string(instanceID)). Execute() @@ -26,11 +26,11 @@ func (c *LaunchpadClient) TerminateInstance(ctx context.Context, instanceID v1.C // If there was no response, but there was an error, return the error if resp == nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // If the response is not 200, return the error if resp.StatusCode != http.StatusOK { - return errors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) + return clouderrors.WrapAndTrace(c.handleLaunchpadAPIErr(ctx, resp, err)) } // We have an error, but the response is 200, so we can consider this a successful terminate request diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index ca9b317..5af6211 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -10,7 +10,7 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" ) @@ -26,7 +26,7 @@ const ( func (c *LaunchpadClient) GetInstanceTypes(ctx context.Context, args v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) { launchpadInstanceTypes, err := c.paginateInstanceTypes(ctx, 100) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } instanceTypes := []v1.InstanceType{} @@ -40,7 +40,7 @@ func (c *LaunchpadClient) GetInstanceTypes(ctx context.Context, args v1.GetInsta // Convert the Launchpad instance type to a v1 instance type instanceType, err := launchpadInstanceTypeToInstanceType(launchpadInstanceType, region) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Collect the instance type if it is selected by the args @@ -102,11 +102,11 @@ func (c *LaunchpadClient) paginateInstanceTypes(ctx context.Context, pageSize in defer func() { err = resp.Body.Close() if err != nil { - c.logger.Error(ctx, errors.Wrap(err, "failed to close response body")) + c.logger.Error(ctx, clouderrors.Wrap(err, "failed to close response body")) } }() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Append results to list @@ -144,7 +144,7 @@ func makeInstanceTypeName(info instanceTypeInfo) string { func getInstanceTypeInfo(name string) (instanceTypeInfo, error) { parts := strings.Split(name, ".") if len(parts) != 3 && len(parts) != 4 { - return instanceTypeInfo{}, errors.Errorf("invalid instance type name: %s", name) + return instanceTypeInfo{}, clouderrors.Errorf("invalid instance type name: %s", name) } cloud := parts[0] @@ -152,13 +152,13 @@ func getInstanceTypeInfo(name string) (instanceTypeInfo, error) { gpuPart := parts[1] xIndex := strings.LastIndex(gpuPart, "x") if xIndex == -1 { - return instanceTypeInfo{}, errors.New("invalid GPU part format") + return instanceTypeInfo{}, clouderrors.New("invalid GPU part format") } gpuName := gpuPart[:xIndex] gpuCountStr := gpuPart[xIndex+1:] gpuCount, err := strconv.ParseInt(gpuCountStr, 10, 32) if err != nil { - return instanceTypeInfo{}, errors.WrapAndTrace(err) + return instanceTypeInfo{}, clouderrors.WrapAndTrace(err) } gpuNetworkDetails := parts[2] @@ -186,7 +186,7 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT // Launchpad returns only a single GPU gpus := launchpadGpusToGpus([]openapi.InstanceTypeGpu{launchpadInstanceType.Gpu}) if len(gpus) != 1 { - return nil, errors.Errorf("expected 1 GPU, got %d", len(gpus)) + return nil, clouderrors.Errorf("expected 1 GPU, got %d", len(gpus)) } gpu := gpus[0] @@ -227,6 +227,7 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT Cloud: launchpadInstanceType.Cloud, ReservedInstancePoolID: launchpadWorkshopIDToReservedInstancePoolID(info.workshopID), EstimatedDeployTime: &estimatedDeployTime, + TunneledSSH: false, } // Make the instance type ID @@ -353,7 +354,9 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { BasePrice: getInstanceTypePrice(gpu), Cloud: cloud, Provider: CloudProviderID, + TunneledSSH: false, } + it.ID = v1.MakeGenericInstanceTypeID(*it) return it } diff --git a/v1/providers/launchpad/instancetype_test.go b/v1/providers/launchpad/instancetype_test.go index 43822f3..bd34ab8 100644 --- a/v1/providers/launchpad/instancetype_test.go +++ b/v1/providers/launchpad/instancetype_test.go @@ -100,14 +100,16 @@ func TestMakeGenericInstanceTypeID(t *testing.T) { Location: "foo", AvailableAzs: []string{"bar"}, Type: "baz", + TunneledSSH: false, }, instanceTypeID: "abc123", }, { name: "no available azs", instanceType: v1.InstanceType{ - Location: "us-east-1", - Type: "a100", + Location: "us-east-1", + Type: "a100", + TunneledSSH: false, }, instanceTypeID: "us-east-1-noSub-a100", }, @@ -117,6 +119,7 @@ func TestMakeGenericInstanceTypeID(t *testing.T) { Location: "us-east-1", Type: "a100", AvailableAzs: []string{"us-east-1a"}, + TunneledSSH: false, }, instanceTypeID: "us-east-1-us-east-1a-a100", }, diff --git a/v1/providers/launchpad/location.go b/v1/providers/launchpad/location.go index 4723442..fa4e0d7 100644 --- a/v1/providers/launchpad/location.go +++ b/v1/providers/launchpad/location.go @@ -3,7 +3,7 @@ package v1 import ( "context" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" v1 "github.com/brevdev/cloud/v1" @@ -12,7 +12,7 @@ import ( func (c *LaunchpadClient) GetLocations(ctx context.Context, args v1.GetLocationsArgs) ([]v1.Location, error) { launchpadInstanceTypes, err := c.paginateInstanceTypes(ctx, 100) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } locations := launchpadInstanceTypesToLocations(launchpadInstanceTypes, args) diff --git a/v1/providers/launchpad/utils.go b/v1/providers/launchpad/utils.go index 607f4d2..796802d 100644 --- a/v1/providers/launchpad/utils.go +++ b/v1/providers/launchpad/utils.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad" ) @@ -14,26 +14,26 @@ import ( func (c *LaunchpadClient) handleLaunchpadAPIErr(ctx context.Context, resp *http.Response, err error) error { c.logger.Info(ctx, "Launchpad Error", v1.LogField("status", resp.Status)) body := "" - defer errors.HandleErrDefer(resp.Body.Close) + defer clouderrors.HandleErrDefer(resp.Body.Close) if apiErr, ok := err.(openapi.GenericOpenAPIError); ok { body = string(apiErr.Body()) } if body == "" { bodyBytes, errr := io.ReadAll(resp.Body) if errr != nil { - c.logger.Error(ctx, errors.Wrap(errr, "Error reading response body")) + c.logger.Error(ctx, clouderrors.Wrap(errr, "Error reading response body")) } body = string(bodyBytes) } - outErr := errors.Errorf("Launchpad API error\n%s\n%s:\nErr: %s\n%s", resp.Request.URL, resp.Status, err.Error(), body) - if errors.ErrorContains(outErr, "no available capacity") { //nolint:gocritic // if else preferred - return errors.WrapAndTrace(errors.Join(v1.ErrInsufficientResources, outErr)) - } else if errors.ErrorContains(outErr, "No Deployment matches the given query") { - return errors.WrapAndTrace(errors.Join(v1.ErrInstanceNotFound, outErr)) + outErr := clouderrors.Errorf("Launchpad API error\n%s\n%s:\nErr: %s\n%s", resp.Request.URL, resp.Status, err.Error(), body) + if clouderrors.ErrorContains(outErr, "no available capacity") { //nolint:gocritic // if else preferred + return clouderrors.WrapAndTrace(clouderrors.Join(v1.ErrInsufficientResources, outErr)) + } else if clouderrors.ErrorContains(outErr, "No Deployment matches the given query") { + return clouderrors.WrapAndTrace(clouderrors.Join(v1.ErrInstanceNotFound, outErr)) // Case where deployment has already received terminate request - can treat this is an idempotent successful terminate request } else if strings.Contains(body, "Deployment is already being destroyed") && resp.StatusCode == http.StatusBadRequest { return nil } - return errors.WrapAndTrace(outErr) + return clouderrors.WrapAndTrace(outErr) } diff --git a/v1/providers/nebius/client.go b/v1/providers/nebius/client.go index 0198f09..9932183 100644 --- a/v1/providers/nebius/client.go +++ b/v1/providers/nebius/client.go @@ -8,7 +8,7 @@ import ( "sort" "strings" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" "github.com/nebius/gosdk" "github.com/nebius/gosdk/auth" @@ -77,7 +77,7 @@ func NewNebiusClientWithOrg(ctx context.Context, refID, serviceAccountKey, tenan sdk, err := gosdk.New(ctx, gosdk.WithCredentials(creds)) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Determine projectID: use provided ID, or find first available project, or use tenant ID @@ -122,7 +122,7 @@ func findProjectForRegion(ctx context.Context, sdk *gosdk.SDK, tenantID, region PageSize: &pageSize, }) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } projects := projectsResp.GetItems() @@ -304,7 +304,7 @@ func (c *NebiusClient) GetLocation(ctx context.Context) (string, error) { Id: c.projectID, }) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } return project.GetSpec().GetRegion(), nil } diff --git a/v1/providers/nebius/credential.go b/v1/providers/nebius/credential.go index 7d1055e..00cb565 100644 --- a/v1/providers/nebius/credential.go +++ b/v1/providers/nebius/credential.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" ) @@ -79,7 +79,7 @@ func (c *NebiusCredential) MakeClientWithOptions(ctx context.Context, location s // Pass empty string and let the client constructor set it client, err := NewNebiusClientWithOrg(ctx, c.RefID, c.ServiceAccountKey, c.TenantID, "", "", location, opts...) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return client, nil } diff --git a/v1/providers/nebius/instance.go b/v1/providers/nebius/instance.go index 6593313..268eb59 100644 --- a/v1/providers/nebius/instance.go +++ b/v1/providers/nebius/instance.go @@ -7,7 +7,7 @@ import ( "time" "github.com/alecthomas/units" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" common "github.com/nebius/gosdk/proto/nebius/common/v1" compute "github.com/nebius/gosdk/proto/nebius/compute/v1" @@ -142,13 +142,13 @@ func (c *NebiusClient) CreateInstance(ctx context.Context, attrs v1.CreateInstan operation, err := c.sdk.Services().Compute().V1().Instance().Create(ctx, createReq) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Wait for the operation to complete and get the actual instance ID finalOp, err := operation.Wait(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } if !finalOp.Successful() { @@ -193,7 +193,7 @@ func (c *NebiusClient) GetInstance(ctx context.Context, instanceID v1.CloudProvi Id: string(instanceID), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return c.convertNebiusInstanceToV1(ctx, instance, nil) @@ -348,12 +348,13 @@ func (c *NebiusClient) convertNebiusInstanceToV1(ctx context.Context, instance * Tags: tags, Status: v1.Status{LifecycleStatus: lifecycleStatus}, // SSH connectivity details - PublicIP: publicIP, - PrivateIP: privateIP, - PublicDNS: publicIP, // Nebius doesn't provide separate DNS, use public IP - Hostname: hostname, - SSHUser: sshUser, - SSHPort: 22, // Standard SSH port + PublicIP: publicIP, + PrivateIP: privateIP, + PublicDNS: publicIP, // Nebius doesn't provide separate DNS, use public IP + Hostname: hostname, + SSHUser: sshUser, + SSHPort: 22, // Standard SSH port + TunneledSSH: false, } inst.InstanceTypeID = v1.MakeGenericInstanceTypeIDFromInstance(*inst) return inst, nil @@ -1343,7 +1344,7 @@ func (c *NebiusClient) parseInstanceType(ctx context.Context, instanceTypeID str ParentId: c.projectID, }) if err != nil { - return "", "", errors.WrapAndTrace(err) + return "", "", clouderrors.WrapAndTrace(err) } c.logger.Info(ctx, "listed platforms", diff --git a/v1/providers/nebius/instance_test.go b/v1/providers/nebius/instance_test.go index 389dea2..320da5d 100644 --- a/v1/providers/nebius/instance_test.go +++ b/v1/providers/nebius/instance_test.go @@ -56,6 +56,7 @@ func TestNebiusClient_MergeInstanceForUpdate(t *testing.T) { CloudID: "current-cloud-id", InstanceType: "current-type", Status: v1.Status{LifecycleStatus: v1.LifecycleStatusRunning}, + TunneledSSH: false, } newInstance := v1.Instance{ @@ -67,6 +68,7 @@ func TestNebiusClient_MergeInstanceForUpdate(t *testing.T) { CloudID: "new-cloud-id", InstanceType: "new-type", Status: v1.Status{LifecycleStatus: v1.LifecycleStatusStopped}, + TunneledSSH: true, } merged := client.MergeInstanceForUpdate(currInstance, newInstance) diff --git a/v1/providers/nebius/instancetype.go b/v1/providers/nebius/instancetype.go index 103d665..e5b42ec 100644 --- a/v1/providers/nebius/instancetype.go +++ b/v1/providers/nebius/instancetype.go @@ -8,7 +8,7 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" billing "github.com/nebius/gosdk/proto/nebius/billing/v1alpha1" common "github.com/nebius/gosdk/proto/nebius/common/v1" @@ -22,7 +22,7 @@ func (c *NebiusClient) GetInstanceTypes(ctx context.Context, args v1.GetInstance ParentId: c.projectID, // List platforms available in this project }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Get all available locations for quota-aware enumeration @@ -32,7 +32,7 @@ func (c *NebiusClient) GetInstanceTypes(ctx context.Context, args v1.GetInstance if args.Locations.IsAll() { //nolint:gocritic // prefer if statement over switch statement allLocations, err := c.GetLocations(ctx, v1.GetLocationsArgs{}) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } locations = allLocations } else if len(args.Locations) > 0 { @@ -186,6 +186,7 @@ func (c *NebiusClient) getInstanceTypesForLocation(ctx context.Context, platform ElasticRootVolume: true, // Nebius supports dynamic disk allocation SupportedStorage: c.buildSupportedStorage(), Provider: CloudProviderID, // Nebius is the provider + TunneledSSH: false, } // Add GPU information if available @@ -228,7 +229,7 @@ func (c *NebiusClient) getQuotaMap(ctx context.Context) (map[string]*quotas.Quot PageSize: 1000, // Get all quotas in one request }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Build a map of quota name + region -> quota allowance @@ -273,7 +274,6 @@ func (c *NebiusClient) checkPresetQuotaAvailability(resources *compute.PresetRes return false } - //nolint:gosec // Safe conversion: quota limits are controlled by cloud provider available := int64(*quota.Spec.Limit) - int64(quota.Status.Usage) if available < int64(resources.GpuCount) { return false // Not enough GPU quota @@ -287,7 +287,6 @@ func (c *NebiusClient) checkPresetQuotaAvailability(resources *compute.PresetRes cpuQuotaKey := fmt.Sprintf("compute.instance.non-gpu.vcpu:%s", region) if cpuQuota, exists := quotaMap[cpuQuotaKey]; exists { if cpuQuota.Status != nil && cpuQuota.Spec != nil && cpuQuota.Spec.Limit != nil { - //nolint:gosec // Safe conversion: quota limits are controlled by cloud provider cpuAvailable := int64(*cpuQuota.Spec.Limit) - int64(cpuQuota.Status.Usage) if cpuAvailable < int64(resources.VcpuCount) { return false @@ -300,7 +299,6 @@ func (c *NebiusClient) checkPresetQuotaAvailability(resources *compute.PresetRes if memQuota, exists := quotaMap[memoryQuotaKey]; exists { if memQuota.Status != nil && memQuota.Spec != nil && memQuota.Spec.Limit != nil { memoryRequired := int64(resources.MemoryGibibytes) * 1024 * 1024 * 1024 // Convert GiB to bytes - //nolint:gosec // Safe conversion: quota limits are controlled by cloud provider memAvailable := int64(*memQuota.Spec.Limit) - int64(memQuota.Status.Usage) if memAvailable < memoryRequired { return false diff --git a/v1/providers/nebius/kubernetes.go b/v1/providers/nebius/kubernetes.go index 68c310b..e6aaeef 100644 --- a/v1/providers/nebius/kubernetes.go +++ b/v1/providers/nebius/kubernetes.go @@ -16,7 +16,7 @@ import ( "k8s.io/client-go/tools/clientcmd" k8scmd "k8s.io/client-go/tools/clientcmd/api" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" cloudk8s "github.com/brevdev/cloud/internal/kubernetes" "github.com/brevdev/cloud/internal/rsa" v1 "github.com/brevdev/cloud/v1" @@ -51,16 +51,16 @@ func (c *NebiusClient) CreateCluster(ctx context.Context, args v1.CreateClusterA // Validate arguments if len(args.SubnetIDs) == 0 { - return nil, errors.WrapAndTrace(errNoSubnetIDsSpecifiedForVPC) + return nil, clouderrors.WrapAndTrace(errNoSubnetIDsSpecifiedForVPC) } else if len(args.SubnetIDs) > 1 { - return nil, errors.WrapAndTrace(errMultipleSubnetIDsNotAllowedForVPC) + return nil, clouderrors.WrapAndTrace(errMultipleSubnetIDsNotAllowedForVPC) } subnetID := string(args.SubnetIDs[0]) // Fetch the target location location, err := c.GetLocation(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Fetch the target VPC @@ -68,13 +68,13 @@ func (c *NebiusClient) CreateCluster(ctx context.Context, args v1.CreateClusterA ID: args.VPCID, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Validate VPC err = validateVPC(vpc) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create a map of subnetID->subnet for this VPC so that we can find the target subnet @@ -86,7 +86,7 @@ func (c *NebiusClient) CreateCluster(ctx context.Context, args v1.CreateClusterA // Get the target subnet from the map var subnet *v1.Subnet if _, ok := subnetMap[subnetID]; !ok { - return nil, errors.WrapAndTrace(fmt.Errorf("subnet ID %s does not match VPC %s", subnetID, vpc.GetID())) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("subnet ID %s does not match VPC %s", subnetID, vpc.GetID())) } else { subnet = subnetMap[subnetID] } @@ -122,7 +122,7 @@ func (c *NebiusClient) CreateCluster(ctx context.Context, args v1.CreateClusterA }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevCluster, err := v1.NewCluster(v1.ClusterSettings{ @@ -139,7 +139,7 @@ func (c *NebiusClient) CreateCluster(ctx context.Context, args v1.CreateClusterA Tags: args.Tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevCluster, nil } @@ -151,7 +151,7 @@ func validateVPC(vpc *v1.VPC) error { for _, subnet := range vpc.GetSubnets() { larger, err := cidrBlockLargerThanMask(subnet.GetCidrBlock(), 24) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } if !larger { continue @@ -172,7 +172,7 @@ func validateVPC(vpc *v1.VPC) error { errs = append(errs, errVPCHasNoPrivateSubnets) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } func (c *NebiusClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) (*v1.Cluster, error) { @@ -186,19 +186,19 @@ func (c *NebiusClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) ( if grpcstatus.Code(err) == grpccodes.NotFound { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nebiusSubnet, err := nebiusSubnetService.Get(ctx, &nebiusvpc.GetSubnetRequest{ Id: cluster.Spec.ControlPlane.SubnetId, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nodeGroups, err := c.getClusterNodeGroups(ctx, cluster) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevCluster, err := v1.NewCluster(v1.ClusterSettings{ @@ -215,7 +215,7 @@ func (c *NebiusClient) GetCluster(ctx context.Context, args v1.GetClusterArgs) ( Tags: v1.Tags(cluster.Metadata.Labels), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevCluster, err } @@ -247,14 +247,14 @@ func (c *NebiusClient) getClusterNodeGroups(ctx context.Context, cluster *nebius ParentId: cluster.Metadata.Id, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nodeGroups := make([]*v1.NodeGroup, len(nebiusNodeGroups.Items)) for i, nebiusNodeGroup := range nebiusNodeGroups.Items { brevNodeGroup, err := parseNebiusNodeGroup(nebiusNodeGroup) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nodeGroups[i] = brevNodeGroup } @@ -280,7 +280,7 @@ func parseNebiusClusterStatus(status *nebiusmk8s.ClusterStatus) v1.ClusterStatus func (c *NebiusClient) SetClusterUser(ctx context.Context, args v1.SetClusterUserArgs) (*v1.ClusterUser, error) { err := validatePutUserArgs(args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Fetch the cluster the user key will be added to @@ -288,43 +288,43 @@ func (c *NebiusClient) SetClusterUser(ctx context.Context, args v1.SetClusterUse ID: args.ClusterID, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) } // Create a clientset to interact with the cluster using the bearer token and CA certificate clientset, err := c.newK8sClient(ctx, cluster) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) } // Prepare the private key for the CSR privateKeyBytes, err := base64.StdEncoding.DecodeString(args.RSAPEMBase64) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode base64 string: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode base64 string: %w", err)) } // Parse the private key privateKey, err := rsa.BytesToRSAKey(privateKeyBytes) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to parse private key: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to parse private key: %w", err)) } // Create the client certificate to allow for external access to the cluster for the holders of this private key signedCertificate, err := cloudk8s.ClientCertificateData(ctx, clientset, args.Username, privateKey) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get signed certificate: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get signed certificate: %w", err)) } // Make the user a cluster admin err = cloudk8s.SetUserRole(ctx, clientset, args.Username, args.Role) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to set user role: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to set user role: %w", err)) } // Get the certificate authority data certificateAuthorityData, err := base64.StdEncoding.DecodeString(cluster.GetClusterCACertificateBase64()) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode certificate authority data: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode certificate authority data: %w", err)) } // Generate the complete kubeconfig @@ -345,7 +345,7 @@ func (c *NebiusClient) SetClusterUser(ctx context.Context, args v1.SetClusterUse }, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to write kubeconfig: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to write kubeconfig: %w", err)) } brevClusterUser, err := v1.NewClusterUser(v1.ClusterUserSettings{ @@ -358,7 +358,7 @@ func (c *NebiusClient) SetClusterUser(ctx context.Context, args v1.SetClusterUse KubeconfigBase64: base64.StdEncoding.EncodeToString(kubeconfigBytes), }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create cluster user: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create cluster user: %w", err)) } return brevClusterUser, nil } @@ -377,7 +377,7 @@ func validatePutUserArgs(args v1.SetClusterUserArgs) error { if args.RSAPEMBase64 == "" { errs = append(errs, errRSAPEMBase64IsRequired) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGroupArgs) (*v1.NodeGroup, error) { @@ -385,7 +385,7 @@ func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGr err := validateCreateNodeGroupArgs(args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Fetch the cluster the user key will be added to @@ -393,7 +393,7 @@ func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGr ID: args.ClusterID, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) } // Placeholder for parsing instance type @@ -413,7 +413,7 @@ func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGr // Nebius expects the disk size in GiB, so we need to convert the disk size to GiB diskSizeGiB, err := args.DiskSize.ByteCountInUnitInt64(v1.Gibibyte) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // create the node groups @@ -450,7 +450,7 @@ func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGr }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevNodeGroup, err := v1.NewNodeGroup(v1.NodeGroupSettings{ @@ -465,7 +465,7 @@ func (c *NebiusClient) CreateNodeGroup(ctx context.Context, args v1.CreateNodeGr Tags: args.Tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -505,12 +505,12 @@ func (c *NebiusClient) GetNodeGroup(ctx context.Context, args v1.GetNodeGroupArg if grpcstatus.Code(err) == grpccodes.NotFound { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevNodeGroup, err := parseNebiusNodeGroup(nodeGroup) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -528,7 +528,7 @@ func parseNebiusNodeGroup(nodeGroup *nebiusmk8s.NodeGroup) (*v1.NodeGroup, error Tags: v1.Tags(nodeGroup.Metadata.Labels), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevNodeGroup, nil } @@ -553,14 +553,14 @@ func (c *NebiusClient) ModifyNodeGroup(ctx context.Context, args v1.ModifyNodeGr err := validateModifyNodeGroupArgs(args) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } nodeGroup, err := nebiusNodeGroupService.Get(ctx, &nebiusmk8s.GetNodeGroupRequest{ Id: string(args.ID), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } _, err = nebiusNodeGroupService.Update(ctx, &nebiusmk8s.UpdateNodeGroupRequest{ @@ -597,7 +597,7 @@ func (c *NebiusClient) ModifyNodeGroup(ctx context.Context, args v1.ModifyNodeGr }, }) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to modify node group: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to modify node group: %w", err)) } return nil @@ -623,14 +623,14 @@ func (c *NebiusClient) DeleteNodeGroup(ctx context.Context, args v1.DeleteNodeGr ID: args.ID, }) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to get node group: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to get node group: %w", err)) } _, err = nebiusNodeGroupService.Delete(ctx, &nebiusmk8s.DeleteNodeGroupRequest{ Id: string(nodeGroup.GetID()), }) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to delete node group: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to delete node group: %w", err)) } return nil @@ -644,14 +644,14 @@ func (c *NebiusClient) DeleteCluster(ctx context.Context, args v1.DeleteClusterA ID: args.ID, }) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to get cluster: %w", err)) } _, err = nebiusClusterService.Delete(ctx, &nebiusmk8s.DeleteClusterRequest{ Id: string(cluster.GetID()), }) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to delete cluster: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to delete cluster: %w", err)) } return nil @@ -661,13 +661,13 @@ func (c *NebiusClient) newK8sClient(ctx context.Context, cluster *v1.Cluster) (* // Decode the cluster CA certificate clusterCACertificate, err := base64.StdEncoding.DecodeString(cluster.GetClusterCACertificateBase64()) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to decode cluster CA certificate: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to decode cluster CA certificate: %w", err)) } // Get a bearer token to authenticate to the cluster bearerToken, err := c.sdk.BearerToken(ctx) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get bearer token: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get bearer token: %w", err)) } // Create a clientset to interact with the cluster using the bearer token and CA certificate @@ -679,7 +679,7 @@ func (c *NebiusClient) newK8sClient(ctx context.Context, cluster *v1.Cluster) (* }, }) if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create clientset: %w", err)) } return clientset, nil diff --git a/v1/providers/nebius/network.go b/v1/providers/nebius/network.go index e6724d4..6c0c88c 100644 --- a/v1/providers/nebius/network.go +++ b/v1/providers/nebius/network.go @@ -11,7 +11,7 @@ import ( grpccodes "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" ) @@ -25,18 +25,18 @@ func (c *NebiusClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v // Fetch the target location location, err := c.GetLocation(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } err = validateCreateVPCArgs(args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create the network vpcID, err := createNetwork(ctx, nebiusNetworkService, nebiusPoolService, c.projectID, args) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Create the subnets @@ -44,7 +44,7 @@ func (c *NebiusClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v for _, subnetArgs := range args.Subnets { subnet, err := c.createSubnet(ctx, nebiusSubnetService, c.projectID, vpcID, subnetArgs) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnets = append(subnets, subnet) } @@ -61,7 +61,7 @@ func (c *NebiusClient) CreateVPC(ctx context.Context, args v1.CreateVPCArgs) (*v Tags: args.Tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevVPC, nil } @@ -71,7 +71,7 @@ func validateCreateVPCArgs(args v1.CreateVPCArgs) error { for _, subnet := range args.Subnets { larger, err := cidrBlockLargerThanMask(subnet.CidrBlock, 24) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } if !larger { return errVPCSubnetCIDRBlockMustBeGreaterThan24 @@ -83,7 +83,7 @@ func validateCreateVPCArgs(args v1.CreateVPCArgs) error { func cidrBlockLargerThanMask(cidrBlock string, mask int) (bool, error) { _, ipnet, err := net.ParseCIDR(cidrBlock) if err != nil { - return false, errors.WrapAndTrace(err) + return false, clouderrors.WrapAndTrace(err) } ones, _ := ipnet.Mask.Size() return ones < mask, nil @@ -122,13 +122,13 @@ func createNetwork(ctx context.Context, nebiusNetworkService nebiusvpcv1.Network }, }) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } // Here we must wait for the pool to be created, as otherwise we cannot proceed to create the network. createPoolOperation, err = createPoolOperation.Wait(ctx) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } poolID := createPoolOperation.ResourceID() @@ -148,7 +148,7 @@ func createNetwork(ctx context.Context, nebiusNetworkService nebiusvpcv1.Network }, }) if err != nil { - return "", errors.WrapAndTrace(err) + return "", clouderrors.WrapAndTrace(err) } return createNetworkOperation.ResourceID(), nil @@ -173,7 +173,7 @@ func (c *NebiusClient) createSubnet(ctx context.Context, nebiusSubnetService neb // Fetch the target location location, err := c.GetLocation(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Add the required labels @@ -205,11 +205,11 @@ func (c *NebiusClient) createSubnet(ctx context.Context, nebiusSubnetService neb }, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } createSubnetOperation, err = createSubnetOperation.Wait(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } brevSubnet, err := v1.NewSubnet(v1.SubnetSettings{ @@ -223,7 +223,7 @@ func (c *NebiusClient) createSubnet(ctx context.Context, nebiusSubnetService neb Tags: args.Tags, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevSubnet, nil } @@ -235,7 +235,7 @@ func (c *NebiusClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, // Fetch the target location location, err := c.GetLocation(ctx) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } network, err := nebiusNetworkService.Get(ctx, &nebiusvpc.GetNetworkRequest{ @@ -245,14 +245,14 @@ func (c *NebiusClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, if grpcstatus.Code(err) == grpccodes.NotFound { return nil, v1.ErrResourceNotFound } - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } nebiusSubnets, err := nebiusSubnetService.ListByNetwork(ctx, &nebiusvpc.ListSubnetsByNetworkRequest{ NetworkId: network.Metadata.Id, }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnets := make([]*v1.Subnet, 0) @@ -268,7 +268,7 @@ func (c *NebiusClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, Tags: v1.Tags(subnet.Metadata.Labels), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } subnets = append(subnets, brevSubnet) } @@ -285,7 +285,7 @@ func (c *NebiusClient) GetVPC(ctx context.Context, args v1.GetVPCArgs) (*v1.VPC, Tags: v1.Tags(network.Metadata.Labels), }) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return brevVPC, nil } @@ -312,7 +312,7 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err Id: string(args.ID), }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Find the network's subnets @@ -320,7 +320,7 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err NetworkId: network.Metadata.Id, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete the subnets @@ -329,7 +329,7 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err Id: subnet.Metadata.Id, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -339,7 +339,7 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err }) if err != nil { if grpcstatus.Code(err) != grpccodes.NotFound { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Pool not found, continue } @@ -359,13 +359,13 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err }, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Here we must wait for the network to be updated, as otherwise we cannot proceed to delete the pool. _, err = updateNetworkOperation.Wait(ctx) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Delete pool @@ -373,13 +373,13 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err Id: pool.Metadata.Id, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } // Here we must wait for the pool to be deleted, as otherwise we cannot proceed to delete the network. _, err = deletePoolOperation.Wait(ctx) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } } @@ -388,7 +388,7 @@ func (c *NebiusClient) DeleteVPC(ctx context.Context, args v1.DeleteVPCArgs) err Id: network.Metadata.Id, }) if err != nil { - return errors.WrapAndTrace(err) + return clouderrors.WrapAndTrace(err) } return nil diff --git a/v1/providers/shadeform/instance.go b/v1/providers/shadeform/instance.go index 6f4e089..e2f2f1f 100644 --- a/v1/providers/shadeform/instance.go +++ b/v1/providers/shadeform/instance.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/alecthomas/units" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/shadeform/gen/shadeform" "github.com/google/uuid" @@ -36,7 +36,7 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns // Check if the instance type is allowed by configuration allowed, _ := c.isInstanceTypeAllowed(attrs.InstanceType) if !allowed { - return nil, errors.WrapAndTrace(fmt.Errorf("instance type: %v is not deployable", attrs.InstanceType)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("instance type: %v is not deployable", attrs.InstanceType)) } sshKeyID := "" @@ -55,31 +55,31 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns var err error sshKeyID, err = c.addSSHKey(ctx, keyPairName, attrs.PublicKey) if err != nil && !strings.Contains(err.Error(), "name must be unique") { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to add SSH key: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to add SSH key: %w", err)) } } region := attrs.Location cloud, shadeInstanceType, err := c.getShadeformCloudAndInstanceType(attrs.InstanceType) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } cloudEnum, err := openapi.NewCloudFromValue(cloud) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Add refID tag refIDTag, err := c.createTag(refIDTagName, attrs.RefID) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Add cloudRefID tag cloudCredRefIDTag, err := c.createTag(cloudCredRefIDTagName, c.GetReferenceID()) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } tags := []string{refIDTag, cloudCredRefIDTag} @@ -87,14 +87,14 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns for key, value := range attrs.Tags { createdTag, err := c.createTag(key, value) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } tags = append(tags, createdTag) } base64Script, err := c.GenerateFirewallScript(attrs.FirewallRules) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } req := openapi.CreateRequest{ @@ -118,17 +118,17 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns defer func() { _ = httpResp.Body.Close() }() } if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to create instance: %w", handleShadeformAPIErrorResponse(httpResp))) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to create instance: %w", handleShadeformAPIErrorResponse(httpResp))) } if resp == nil { - return nil, errors.WrapAndTrace(fmt.Errorf("no instance returned from create request")) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("no instance returned from create request")) } // Since Shadeform doesn't return the full instance that's created, we need to make a second API call to get // the created instance after we call create createdInstance, err := c.GetInstance(authCtx, v1.CloudProviderInstanceID(resp.Id)) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return createdInstance, nil @@ -139,7 +139,7 @@ func handleShadeformAPIErrorResponse(httpResp *http.Response) error { httpStatusCode := httpResp.StatusCode httpMessageBytes, err := io.ReadAll(httpResp.Body) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to read shadeform API response body: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to read shadeform API response body: %w", err)) } // Most well-structured errors are 409, so handle these as a special case @@ -148,7 +148,7 @@ func handleShadeformAPIErrorResponse(httpResp *http.Response) error { var shadeformErrorResponse DefaultErrorResponse err = json.Unmarshal(httpMessageBytes, &shadeformErrorResponse) if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to unmarshal shadeform API response body: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to unmarshal shadeform API response body: %w", err)) } // Handle Shadeform specific errors and attempt to translate them into Brev errors @@ -156,12 +156,12 @@ func handleShadeformAPIErrorResponse(httpResp *http.Response) error { return v1.ErrInsufficientResources } else { // For all other error codes, return the error object from the API response - return errors.WrapAndTrace(fmt.Errorf("shadeform API error: error code: %v, error: %v", shadeformErrorResponse.ErrorCode, shadeformErrorResponse.Error)) + return clouderrors.WrapAndTrace(fmt.Errorf("shadeform API error: error code: %v, error: %v", shadeformErrorResponse.ErrorCode, shadeformErrorResponse.Error)) } } // For all other HTTP status codes, return the status code and body - return errors.WrapAndTrace(fmt.Errorf("shadeform HTTP error: [%d], %s", httpStatusCode, string(httpMessageBytes))) + return clouderrors.WrapAndTrace(fmt.Errorf("shadeform HTTP error: [%d], %s", httpStatusCode, string(httpMessageBytes))) } func (c *ShadeformClient) getInstanceNameForShadeform(refID string, providedName string) string { @@ -191,11 +191,11 @@ func (c *ShadeformClient) addSSHKey(ctx context.Context, keyPairName string, pub } if err != nil { httpMessage, _ := io.ReadAll(httpResp.Body) - return "", errors.WrapAndTrace(fmt.Errorf("failed to add SSH Key: %w, %s", err, string(httpMessage))) + return "", clouderrors.WrapAndTrace(fmt.Errorf("failed to add SSH Key: %w, %s", err, string(httpMessage))) } if resp == nil { - return "", errors.WrapAndTrace(fmt.Errorf("no instance returned from post request")) + return "", clouderrors.WrapAndTrace(fmt.Errorf("no instance returned from post request")) } return resp.Id, nil @@ -209,16 +209,16 @@ func (c *ShadeformClient) GetInstance(ctx context.Context, instanceID v1.CloudPr defer func() { _ = httpResp.Body.Close() }() } if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get instance: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get instance: %w", err)) } if resp == nil { - return nil, errors.WrapAndTrace(fmt.Errorf("no instance returned from get request")) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("no instance returned from get request")) } instance, err := c.convertInstanceInfoResponseToV1Instance(*resp) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return instance, nil @@ -232,7 +232,7 @@ func (c *ShadeformClient) TerminateInstance(ctx context.Context, instanceID v1.C defer func() { _ = httpResp.Body.Close() }() } if err != nil { - return errors.WrapAndTrace(fmt.Errorf("failed to terminate instance: %w", err)) + return clouderrors.WrapAndTrace(fmt.Errorf("failed to terminate instance: %w", err)) } return nil @@ -246,14 +246,14 @@ func (c *ShadeformClient) ListInstances(ctx context.Context, _ v1.ListInstancesA defer func() { _ = httpResp.Body.Close() }() } if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to list instances: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to list instances: %w", err)) } var instances []v1.Instance for _, instance := range resp.Instances { singleInstance, err := c.convertShadeformInstanceToV1Instance(instance) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } instances = append(instances, *singleInstance) } @@ -299,18 +299,18 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo o tags, err := c.convertShadeformTagToV1Tag(instanceInfo.Tags) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } refID, found := tags[refIDTagName] if !found { - return nil, errors.WrapAndTrace(errors.New("could not find refID tag")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("could not find refID tag")) } delete(tags, refIDTagName) cloudCredRefID, found := tags[cloudCredRefIDTagName] if !found { - return nil, errors.WrapAndTrace(errors.New("could not find cloudCredRefID tag")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("could not find cloudCredRefID tag")) } delete(tags, cloudCredRefIDTagName) @@ -339,6 +339,7 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo o Rebootable: true, RefID: refID, CloudCredRefID: cloudCredRefID, + TunneledSSH: false, } return instance, nil @@ -352,18 +353,18 @@ func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance tags, err := c.convertShadeformTagToV1Tag(shadeformInstance.Tags) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } refID, found := tags[refIDTagName] if !found { - return nil, errors.WrapAndTrace(errors.New("could not find refID tag")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("could not find refID tag")) } delete(tags, refIDTagName) cloudCredRefID, found := tags[cloudCredRefIDTagName] if !found { - return nil, errors.WrapAndTrace(errors.New("could not find cloudCredRefID tag")) + return nil, clouderrors.WrapAndTrace(clouderrors.New("could not find cloudCredRefID tag")) } delete(tags, cloudCredRefIDTagName) @@ -392,6 +393,7 @@ func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance RefID: refID, Tags: tags, CloudCredRefID: cloudCredRefID, + TunneledSSH: false, } return instance, nil @@ -402,7 +404,7 @@ func (c *ShadeformClient) convertShadeformTagToV1Tag(shadeformTags []string) (v1 for _, tag := range shadeformTags { key, value, err := c.getTag(tag) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } tags[key] = value } @@ -411,7 +413,7 @@ func (c *ShadeformClient) convertShadeformTagToV1Tag(shadeformTags []string) (v1 func (c *ShadeformClient) createTag(key string, value string) (string, error) { if strings.Contains(key, "=") { - return "", errors.WrapAndTrace(errors.New("tags cannot contain the '=' character")) + return "", clouderrors.WrapAndTrace(clouderrors.New("tags cannot contain the '=' character")) } return fmt.Sprintf("%v=%v", key, value), nil @@ -420,7 +422,7 @@ func (c *ShadeformClient) createTag(key string, value string) (string, error) { func (c *ShadeformClient) getTag(shadeformTag string) (string, string, error) { key, value, found := strings.Cut(shadeformTag, "=") if !found { - return "", "", errors.WrapAndTrace(fmt.Errorf("tag %v does not conform to the key value tag format", shadeformTag)) + return "", "", clouderrors.WrapAndTrace(fmt.Errorf("tag %v does not conform to the key value tag format", shadeformTag)) } return key, value, nil } diff --git a/v1/providers/shadeform/instancetype.go b/v1/providers/shadeform/instancetype.go index 8bd2e2e..b63f18c 100644 --- a/v1/providers/shadeform/instancetype.go +++ b/v1/providers/shadeform/instancetype.go @@ -9,7 +9,7 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/shadeform/gen/shadeform" ) @@ -36,7 +36,7 @@ func (c *ShadeformClient) GetInstanceTypes(ctx context.Context, args v1.GetInsta defer func() { _ = httpResp.Body.Close() }() } if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get instance types: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get instance types: %w", err)) } var instanceTypes []v1.InstanceType @@ -45,7 +45,7 @@ func (c *ShadeformClient) GetInstanceTypes(ctx context.Context, args v1.GetInsta for _, sfInstanceType := range resp.InstanceTypes { instanceTypesFromShadeformInstanceType, err := c.convertShadeformInstanceTypeToV1InstanceType(sfInstanceType) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } // Filter the list down to the instance types that are allowed by the configuration filter and the args for _, singleInstanceType := range instanceTypesFromShadeformInstanceType { @@ -108,7 +108,7 @@ func (c *ShadeformClient) GetLocations(ctx context.Context, _ v1.GetLocationsArg } if err != nil { - return nil, errors.WrapAndTrace(fmt.Errorf("failed to get locations: %w", err)) + return nil, clouderrors.WrapAndTrace(fmt.Errorf("failed to get locations: %w", err)) } // Shadeform doesn't have a dedicated locations API but we can get the same result from using the @@ -150,13 +150,13 @@ func (c *ShadeformClient) isInstanceTypeAllowed(instanceType string) (bool, erro // Convert to Cloud and Instance Type cloud, shadeInstanceType, err := c.getShadeformCloudAndInstanceType(instanceType) if err != nil { - return false, errors.WrapAndTrace(err) + return false, clouderrors.WrapAndTrace(err) } // Convert to API Cloud Enum cloudEnum, err := openapi.NewCloudFromValue(cloud) if err != nil { - return false, errors.WrapAndTrace(err) + return false, clouderrors.WrapAndTrace(err) } return c.config.isAllowed(*cloudEnum, shadeInstanceType), nil @@ -176,7 +176,7 @@ func (c *ShadeformClient) getInstanceTypeID(instanceType string, region string) func (c *ShadeformClient) getShadeformCloudAndInstanceType(instanceType string) (string, string, error) { shadeformCloud, shadeformInstanceType, found := strings.Cut(instanceType, "_") if !found { - return "", "", errors.WrapAndTrace(errors.New("could not determine shadeform cloud and instance type from instance type")) + return "", "", clouderrors.WrapAndTrace(clouderrors.New("could not determine shadeform cloud and instance type from instance type")) } return shadeformCloud, shadeformInstanceType, nil } @@ -213,7 +213,7 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform basePrice, err := convertHourlyPriceToAmount(shadeformInstanceType.HourlyPrice) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } gpuName := shadeformGPUTypeToBrevGPUName(shadeformInstanceType.Configuration.GpuType) @@ -257,6 +257,7 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform Provider: CloudProviderID, Cloud: cloud, EstimatedDeployTime: estimatedDeployTime, + TunneledSSH: false, }) } @@ -268,7 +269,7 @@ func convertHourlyPriceToAmount(hourlyPrice int32) (*currency.Amount, error) { amount, err := currency.NewAmount(number, UsdCurrentCode) if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &amount, nil } diff --git a/v1/providers/shadeform/instancetype_test.go b/v1/providers/shadeform/instancetype_test.go index 27e074b..cdf206b 100644 --- a/v1/providers/shadeform/instancetype_test.go +++ b/v1/providers/shadeform/instancetype_test.go @@ -12,14 +12,14 @@ import ( func TestIsSelectedByArgs(t *testing.T) { t.Parallel() - x8664nvidiaaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "aws"} - x8664nvidiagcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "gcp"} - x8664intelaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "aws"} - x8664intelgcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "gcp"} - arm64nvidiaaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "aws"} - arm64nvidiagcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "gcp"} - arm64intelaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "aws"} - arm64intelgcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "gcp"} + x8664nvidiaaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "aws", TunneledSSH: false} + x8664nvidiagcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "gcp", TunneledSSH: false} + x8664intelaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "aws", TunneledSSH: false} + x8664intelgcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureX86_64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "gcp", TunneledSSH: false} + arm64nvidiaaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "aws", TunneledSSH: false} + arm64nvidiagcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerNVIDIA}}, Cloud: "gcp", TunneledSSH: false} + arm64intelaws := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "aws", TunneledSSH: false} + arm64intelgcp := v1.InstanceType{SupportedArchitectures: []v1.Architecture{v1.ArchitectureARM64}, SupportedGPUs: []v1.GPU{{Manufacturer: v1.ManufacturerIntel}}, Cloud: "gcp", TunneledSSH: false} all := []v1.InstanceType{x8664nvidiaaws, x8664intelaws, arm64nvidiaaws, arm64intelaws, x8664nvidiagcp, arm64nvidiagcp, x8664intelgcp, arm64intelgcp} diff --git a/v1/vpc.go b/v1/vpc.go index 878e5c0..2533776 100644 --- a/v1/vpc.go +++ b/v1/vpc.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/brevdev/cloud/internal/errors" + "github.com/brevdev/cloud/internal/clouderrors" ) // VPC represents the complete specification of a Brev VPC. @@ -150,7 +150,7 @@ func (s *VPCSettings) validate() error { if s.Status == "" { errs = append(errs, fmt.Errorf("status is required")) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } // NewVPC creates a new VPC from the provided settings. @@ -158,7 +158,7 @@ func NewVPC(settings VPCSettings) (*VPC, error) { settings.setDefaults() err := settings.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &VPC{ name: settings.Name, @@ -285,7 +285,7 @@ func (s *SubnetSettings) validate() error { errs = append(errs, fmt.Errorf("id is required")) } - return errors.WrapAndTrace(errors.Join(errs...)) + return clouderrors.WrapAndTrace(clouderrors.Join(errs...)) } // NewSubnet creates a new Subnet from the provided settings. @@ -293,7 +293,7 @@ func NewSubnet(settings SubnetSettings) (*Subnet, error) { settings.setDefaults() err := settings.validate() if err != nil { - return nil, errors.WrapAndTrace(err) + return nil, clouderrors.WrapAndTrace(err) } return &Subnet{ name: settings.Name,