Skip to content

refactor: Delete unused code #687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading