Skip to content

Commit

Permalink
refactor: Delete unused code (#687)
Browse files Browse the repository at this point in the history
**What problem does this PR solve?**:

**Which issue(s) this PR fixes**:
Fixes #

**How Has This Been Tested?**:
<!--
Please describe the tests that you ran to verify your changes.
Provide output from the tests and any manual steps needed to replicate
the tests.
-->

**Special notes for your reviewer**:
<!--
Use this to provide any additional information to the reviewers.
This may include:
- Best way to review the PR.
- Where the author wants the most review attention on.
- etc.
-->
  • Loading branch information
jimmidyson authored May 22, 2024
1 parent 1e9e020 commit 61026f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 101 deletions.
4 changes: 3 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions api/variables/enums.go

This file was deleted.

70 changes: 0 additions & 70 deletions api/variables/eums_test.go

This file was deleted.

22 changes: 10 additions & 12 deletions api/variables/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ import (
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
)

func MustMarshal(val any) *apiextensionsv1.JSON {
marshaled, err := json.Marshal(val)
if err != nil {
panic(fmt.Errorf("failed to marshal enum value: %w", err))
}

return &apiextensionsv1.JSON{Raw: marshaled}
}

func MarshalToClusterVariable[T any](name string, obj T) (*clusterv1.ClusterVariable, error) {
marshaled, err := json.Marshal(obj)
if err != nil {
Expand All @@ -33,7 +24,9 @@ func MarshalToClusterVariable[T any](name string, obj T) (*clusterv1.ClusterVari
}, nil
}

func UnmarshalClusterConfigVariable(clusterVariables []clusterv1.ClusterVariable) (*ClusterConfigSpec, error) {
func UnmarshalClusterConfigVariable(
clusterVariables []clusterv1.ClusterVariable,
) (*ClusterConfigSpec, error) {
variableName := v1alpha1.ClusterConfigVariableName
clusterConfig := GetClusterVariableByName(variableName, clusterVariables)
if clusterConfig == nil {
Expand All @@ -48,7 +41,9 @@ func UnmarshalClusterConfigVariable(clusterVariables []clusterv1.ClusterVariable
return spec, nil
}

func UnmarshalWorkerConfigVariable(clusterVariables []clusterv1.ClusterVariable) (*WorkerNodeConfigSpec, error) {
func UnmarshalWorkerConfigVariable(
clusterVariables []clusterv1.ClusterVariable,
) (*WorkerNodeConfigSpec, error) {
variableName := v1alpha1.WorkerConfigVariableName
workerConfig := GetClusterVariableByName(variableName, clusterVariables)
if workerConfig == nil {
Expand All @@ -72,7 +67,10 @@ func UnmarshalClusterVariable[T any](clusterVariable *clusterv1.ClusterVariable,
return nil
}

func GetClusterVariableByName(name string, clusterVariables []clusterv1.ClusterVariable) *clusterv1.ClusterVariable {
func GetClusterVariableByName(
name string,
clusterVariables []clusterv1.ClusterVariable,
) *clusterv1.ClusterVariable {
for _, clusterVar := range clusterVariables {
if clusterVar.Name == name {
return &clusterVar
Expand Down

0 comments on commit 61026f7

Please sign in to comment.