Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Cost estimation infra + aws (#603)
Browse files Browse the repository at this point in the history
* apiserver

* orchestrator

* aws cost estimation

* review

* fix linters and tests

* Fix error wrapping and revert null errors change

---------

Co-authored-by: Sam Betts <[email protected]>
  • Loading branch information
fishkerez and Tehsmash authored Sep 8, 2023
1 parent e9d1bf2 commit 799b5c9
Show file tree
Hide file tree
Showing 46 changed files with 7,705 additions and 526 deletions.
2,695 changes: 2,342 additions & 353 deletions api/client/client.gen.go

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions api/models/assetrelationship.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package models

import (
"encoding/json"
"fmt"
)

func (a *AssetRelationship) ToAsset() (*Asset, error) {
if a == nil {
return nil, fmt.Errorf("asset relationship is nil")
}

B, err := json.Marshal(a)
if err != nil {
return nil, fmt.Errorf("failed to marshal: %w", err)
}

var asset Asset
if err := json.Unmarshal(B, &asset); err != nil {
return nil, fmt.Errorf("failed to unmarshal: %w", err)
}

return &asset, nil
}
71 changes: 71 additions & 0 deletions api/models/assetscanestimation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package models

func (r *AssetScanEstimation) GetState() (AssetScanEstimationStateState, bool) {
var state AssetScanEstimationStateState
var ok bool

if r.State != nil {
state, ok = r.State.GetState()
}

return state, ok
}

func (r *AssetScanEstimation) GetID() (string, bool) {
var id string
var ok bool

if r.Id != nil {
id, ok = *r.Id, true
}

return id, ok
}

func (r *AssetScanEstimation) GetScanEstimationID() (string, bool) {
var scanEstimationID string
var ok bool

if r.ScanEstimation != nil && r.ScanEstimation.Id != nil {
scanEstimationID, ok = *r.ScanEstimation.Id, true
}

return scanEstimationID, ok
}

func (r *AssetScanEstimation) GetAssetID() (string, bool) {
var assetID string
var ok bool

if r.Asset != nil {
assetID, ok = r.Asset.Id, true
}

return assetID, ok
}

func (s *AssetScanEstimationState) GetState() (AssetScanEstimationStateState, bool) {
var state AssetScanEstimationStateState
var ok bool

if s.State != nil {
state, ok = *s.State, true
}

return state, ok
}
27 changes: 27 additions & 0 deletions api/models/assetscantemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package models

func (a *AssetScanTemplate) UseSpotInstances() bool {
if a == nil {
return false
}

if a.ScannerInstanceCreationConfig != nil && a.ScannerInstanceCreationConfig.UseSpotInstances {
return true
}
return false
}
Loading

0 comments on commit 799b5c9

Please sign in to comment.