From efd0d7b4662b0bb0bebf7827f9b3b508a2f298b6 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Wed, 24 Apr 2024 20:52:41 -0400 Subject: [PATCH] chore: remove unused code (#1236) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- .../{code_quality.yml => code-quality.yml} | 2 +- README.md | 2 +- fwprovider/provider.go | 2 +- fwprovider/tests/resource_container_test.go | 3 +- proxmox/types/helpers.go | 9 -- proxmoxtf/datasource/cluster/firewall.go | 65 --------------- .../datasource/firewall/security_group.go | 83 ------------------- .../datasource/firewall/security_groups.go | 26 ------ proxmoxtf/datasource/node.go | 3 +- proxmoxtf/provider/schema.go | 1 - proxmoxtf/resource/container/container.go | 52 ++++++------ proxmoxtf/resource/file.go | 1 - proxmoxtf/resource/group.go | 14 ++-- proxmoxtf/resource/pool.go | 8 +- proxmoxtf/resource/role.go | 8 +- proxmoxtf/resource/user.go | 16 ++-- proxmoxtf/resource/validators/firewall.go | 13 +-- proxmoxtf/resource/vm/network/schema.go | 1 - proxmoxtf/resource/vm/vm.go | 36 ++++---- qodana.yaml | 9 ++ 20 files changed, 83 insertions(+), 271 deletions(-) rename .github/workflows/{code_quality.yml => code-quality.yml} (94%) delete mode 100644 proxmoxtf/datasource/cluster/firewall.go create mode 100644 qodana.yaml diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code-quality.yml similarity index 94% rename from .github/workflows/code_quality.yml rename to .github/workflows/code-quality.yml index 188c0cdc..afa5d3cf 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code-quality.yml @@ -14,7 +14,7 @@ jobs: pull-requests: write checks: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit fetch-depth: 0 # a full history is required for pull request analysis diff --git a/README.md b/README.md index 61bb180c..3885bddc 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This repository is a fork of 0)...) + diags = append(diags, disk.Read(ctx, d, allDiskInfo, vmID, client, nodeName, len(clone) > 0)...) if vmConfig.EFIDisk != nil { efiDisk := map[string]interface{}{} @@ -3742,7 +3742,7 @@ func vmReadCustom( } else { // disk format may not be returned by config API if it is default for the storage, and that may be different // from the default qcow2, so we need to read it from the storage API to make sure we have the correct value - volume, err := api.Node(nodeName).Storage(fileIDParts[0]).GetDatastoreFile(ctx, vmConfig.EFIDisk.FileVolume) + volume, err := client.Node(nodeName).Storage(fileIDParts[0]).GetDatastoreFile(ctx, vmConfig.EFIDisk.FileVolume) if err != nil { diags = append(diags, diag.FromErr(e)...) } else { @@ -4467,7 +4467,7 @@ func vmReadCustom( } } - vmAPI := api.Node(nodeName).VM(vmID) + vmAPI := client.Node(nodeName).VM(vmID) started := d.Get(mkStarted).(bool) agentTimeout, e := getAgentTimeout(d) @@ -4713,7 +4713,7 @@ func vmUpdatePool( func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { config := m.(proxmoxtf.ProviderConfiguration) - api, e := config.GetClient() + client, e := config.GetClient() if e != nil { return diag.FromErr(e) } @@ -4726,7 +4726,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D return diag.FromErr(e) } - e = vmUpdatePool(ctx, d, api.Pool(), vmID) + e = vmUpdatePool(ctx, d, client.Pool(), vmID) if e != nil { return diag.FromErr(e) } @@ -4740,7 +4740,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D oldNodeNameValue, _ := d.GetChange(mkNodeName) oldNodeName := oldNodeNameValue.(string) - vmAPI := api.Node(oldNodeName).VM(vmID) + vmAPI := client.Node(oldNodeName).VM(vmID) trueValue := types.CustomBool(true) migrateBody := &vms.MigrateRequestBody{ @@ -4755,7 +4755,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D } } - vmAPI := api.Node(nodeName).VM(vmID) + vmAPI := client.Node(nodeName).VM(vmID) updateBody := &vms.UpdateRequestBody{ IDEDevices: vms.CustomStorageDevices{ @@ -4994,7 +4994,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D cpuAffinity := cpuBlock[mkCPUAffinity].(string) // Only the root account is allowed to change the CPU architecture, which makes this check necessary. - if api.API().IsRootTicket() || + if client.API().IsRootTicket() || cpuArchitecture != dvCPUArchitecture { updateBody.CPUArchitecture = &cpuArchitecture } @@ -5359,7 +5359,7 @@ func vmUpdateDiskLocationAndSize( ) diag.Diagnostics { config := m.(proxmoxtf.ProviderConfiguration) - api, err := config.GetClient() + client, err := config.GetClient() if err != nil { return diag.FromErr(err) } @@ -5373,7 +5373,7 @@ func vmUpdateDiskLocationAndSize( return diag.FromErr(err) } - vmAPI := api.Node(nodeName).VM(vmID) + vmAPI := client.Node(nodeName).VM(vmID) // Determine if any of the disks are changing location and/or size, and initiate the necessary actions. //nolint: nestif diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 00000000..88af6d93 --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,9 @@ +version: "1.0" +linter: jetbrains/qodana-go:2023.3 +include: + - name: CheckDependencyLicenses +exclude: + - name: All + paths: + - CONTRIBUTORS.md + - README.md