This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
46 changed files
with
7,705 additions
and
526 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
Oops, something went wrong.