Skip to content
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

Reduces ~140 indirect imports for plugin/framework importers #8208

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

kaovilai
Copy link
Contributor

@kaovilai kaovilai commented Sep 11, 2024

Signed-off-by: Tiger Kaovilai tkaovila@redhat.com

Thank you for contributing to Velero!

Please add a summary of your change

Refactor struct imports to avoid framework importers from needing cloud provider imports.
Moving repository/manager.go to repository/manager/manager.go

This would help a ton with avoiding CVEs false alarms for unrelated plugin.

This change can supplement or replace #8180

Does your change fix a particular issue?

Fixes #8207
Fixes #8157

Problem Demo: vmware-tanzu/velero-plugin-for-microsoft-azure@7e31b61
Fix Demo: vmware-tanzu/velero-plugin-for-microsoft-azure@64ea902
Problem Demo2: kubevirt/kubevirt-velero-plugin@faf9815
Fix Demo2: kubevirt/kubevirt-velero-plugin@2c0e171

Before

❯ git fetch upstream && git checkout upstream/main && go list -f {{.Deps}} ./pkg/install/... | sed 's/ /\n/g' | grep -E 'aws|azure|gcp|s3'  
HEAD is now at 7c9b7c1ba Merge pull request #8144 from Lyndon-Li/data-mover-ms-doc
github.com/Azure/azure-sdk-for-go/sdk/azcore
github.com/Azure/azure-sdk-for-go/sdk/azcore/arm
github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/internal/resource
github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/policy
github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime
github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/log
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers/async
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers/body
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers/fake
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers/loc
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/pollers/op
github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared
github.com/Azure/azure-sdk-for-go/sdk/azcore/log
github.com/Azure/azure-sdk-for-go/sdk/azcore/policy
github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime
github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming
github.com/Azure/azure-sdk-for-go/sdk/azcore/to
github.com/Azure/azure-sdk-for-go/sdk/azcore/tracing
github.com/Azure/azure-sdk-for-go/sdk/azidentity
github.com/Azure/azure-sdk-for-go/sdk/azidentity/internal
github.com/Azure/azure-sdk-for-go/sdk/internal/diag
github.com/Azure/azure-sdk-for-go/sdk/internal/errorinfo
github.com/Azure/azure-sdk-for-go/sdk/internal/exported
github.com/Azure/azure-sdk-for-go/sdk/internal/log
github.com/Azure/azure-sdk-for-go/sdk/internal/poller
github.com/Azure/azure-sdk-for-go/sdk/internal/temporal
github.com/Azure/azure-sdk-for-go/sdk/internal/uuid
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/base
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/generated
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/shared
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/pageblob
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service
github.com/aws/aws-sdk-go-v2/aws
github.com/aws/aws-sdk-go-v2/aws/arn
github.com/aws/aws-sdk-go-v2/aws/defaults
github.com/aws/aws-sdk-go-v2/aws/middleware
github.com/aws/aws-sdk-go-v2/aws/middleware/private/metrics
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/eventstreamapi
github.com/aws/aws-sdk-go-v2/aws/protocol/query
github.com/aws/aws-sdk-go-v2/aws/protocol/restjson
github.com/aws/aws-sdk-go-v2/aws/protocol/xml
github.com/aws/aws-sdk-go-v2/aws/ratelimit
github.com/aws/aws-sdk-go-v2/aws/retry
github.com/aws/aws-sdk-go-v2/aws/signer/internal/v4
github.com/aws/aws-sdk-go-v2/aws/signer/v4
github.com/aws/aws-sdk-go-v2/aws/transport/http
github.com/aws/aws-sdk-go-v2/config
github.com/aws/aws-sdk-go-v2/credentials
github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds
github.com/aws/aws-sdk-go-v2/credentials/endpointcreds
github.com/aws/aws-sdk-go-v2/credentials/endpointcreds/internal/client
github.com/aws/aws-sdk-go-v2/credentials/processcreds
github.com/aws/aws-sdk-go-v2/credentials/ssocreds
github.com/aws/aws-sdk-go-v2/credentials/stscreds
github.com/aws/aws-sdk-go-v2/feature/ec2/imds
github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config
github.com/aws/aws-sdk-go-v2/feature/s3/manager
github.com/aws/aws-sdk-go-v2/internal/auth
github.com/aws/aws-sdk-go-v2/internal/auth/smithy
github.com/aws/aws-sdk-go-v2/internal/awsutil
github.com/aws/aws-sdk-go-v2/internal/configsources
github.com/aws/aws-sdk-go-v2/internal/context
github.com/aws/aws-sdk-go-v2/internal/endpoints
github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2
github.com/aws/aws-sdk-go-v2/internal/ini
github.com/aws/aws-sdk-go-v2/internal/rand
github.com/aws/aws-sdk-go-v2/internal/sdk
github.com/aws/aws-sdk-go-v2/internal/sdkio
github.com/aws/aws-sdk-go-v2/internal/shareddefaults
github.com/aws/aws-sdk-go-v2/internal/strings
github.com/aws/aws-sdk-go-v2/internal/sync/singleflight
github.com/aws/aws-sdk-go-v2/internal/timeconv
github.com/aws/aws-sdk-go-v2/internal/v4a
github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto
github.com/aws/aws-sdk-go-v2/internal/v4a/internal/v4
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding
github.com/aws/aws-sdk-go-v2/service/internal/checksum
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url
github.com/aws/aws-sdk-go-v2/service/internal/s3shared
github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn
github.com/aws/aws-sdk-go-v2/service/internal/s3shared/config
github.com/aws/aws-sdk-go-v2/service/s3
github.com/aws/aws-sdk-go-v2/service/s3/internal/arn
github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations
github.com/aws/aws-sdk-go-v2/service/s3/internal/endpoints
github.com/aws/aws-sdk-go-v2/service/s3/types
github.com/aws/aws-sdk-go-v2/service/sso
github.com/aws/aws-sdk-go-v2/service/sso/internal/endpoints
github.com/aws/aws-sdk-go-v2/service/sso/types
github.com/aws/aws-sdk-go-v2/service/ssooidc
github.com/aws/aws-sdk-go-v2/service/ssooidc/internal/endpoints
github.com/aws/aws-sdk-go-v2/service/ssooidc/types
github.com/aws/aws-sdk-go-v2/service/sts
github.com/aws/aws-sdk-go-v2/service/sts/internal/endpoints
github.com/aws/aws-sdk-go-v2/service/sts/types
github.com/aws/smithy-go
github.com/aws/smithy-go/auth
github.com/aws/smithy-go/auth/bearer
github.com/aws/smithy-go/container/private/cache
github.com/aws/smithy-go/container/private/cache/lru
github.com/aws/smithy-go/context
github.com/aws/smithy-go/document
github.com/aws/smithy-go/encoding
github.com/aws/smithy-go/encoding/httpbinding
github.com/aws/smithy-go/encoding/json
github.com/aws/smithy-go/encoding/xml
github.com/aws/smithy-go/endpoints
github.com/aws/smithy-go/endpoints/private/rulesfn
github.com/aws/smithy-go/internal/sync/singleflight
github.com/aws/smithy-go/io
github.com/aws/smithy-go/logging
github.com/aws/smithy-go/middleware
github.com/aws/smithy-go/private/requestcompression
github.com/aws/smithy-go/ptr
github.com/aws/smithy-go/rand
github.com/aws/smithy-go/sync
github.com/aws/smithy-go/time
github.com/aws/smithy-go/transport/http
github.com/aws/smithy-go/transport/http/internal/io
github.com/aws/smithy-go/waiter
github.com/kopia/kopia/repo/blob/azure
github.com/kopia/kopia/repo/blob/s3
github.com/minio/minio-go/v7/pkg/s3utils
github.com/vmware-tanzu/velero/pkg/repository/udmrepo/kopialib/backend/azure
github.com/vmware-tanzu/velero/pkg/util/azure
google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp
k8s.io/client-go/plugin/pkg/client/auth/azure
k8s.io/client-go/plugin/pkg/client/auth/gcp

After

❯ go list -f {{.Deps}} ./pkg/install/... | sed 's/ /\n/g' | grep -E 'aws|azure|gcp|s3'  

k8s.io/client-go/plugin/pkg/client/auth/azure
k8s.io/client-go/plugin/pkg/client/auth/gcp

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

Related: #6484

@kaovilai kaovilai marked this pull request as ready for review September 11, 2024 02:48
@kaovilai kaovilai changed the title Avoid plugin framework importers from needing cloud provider imports Reduces indirect imports for plugin/framework importers Sep 11, 2024
@kaovilai kaovilai changed the title Reduces indirect imports for plugin/framework importers Reduces ~140 indirect imports for plugin/framework importers Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.

Project coverage is 59.15%. Comparing base (efcf836) to head (f232642).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/repository/manager/manager.go 28.57% 5 Missing ⚠️
pkg/podvolume/util.go 0.00% 4 Missing ⚠️
pkg/cmd/server/server.go 0.00% 1 Missing ⚠️
pkg/controller/backup_deletion_controller.go 80.00% 1 Missing ⚠️
pkg/datamover/dataupload_delete_action.go 0.00% 1 Missing ⚠️
pkg/restore/restore.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8208   +/-   ##
=======================================
  Coverage   59.15%   59.15%           
=======================================
  Files         367      367           
  Lines       30775    30775           
=======================================
  Hits        18206    18206           
  Misses      11112    11112           
  Partials     1457     1457           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

kaovilai added a commit to kaovilai/kubevirt-velero-plugin that referenced this pull request Sep 11, 2024
vmware-tanzu/velero#8208
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
kaovilai added a commit to kaovilai/velero-plugin-for-microsoft-azure that referenced this pull request Sep 11, 2024
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@reasonerjt reasonerjt requested review from ywk253100 and removed request for reasonerjt September 11, 2024 07:11
ywk253100
ywk253100 previously approved these changes Sep 11, 2024
sseago
sseago previously approved these changes Sep 11, 2024
@kaovilai kaovilai dismissed stale reviews from sseago and ywk253100 via 60ffb0f September 11, 2024 14:28
@kaovilai kaovilai force-pushed the refactor-pluginframeworkdep branch 3 times, most recently from 3b50436 to cd76cee Compare September 11, 2024 15:26
sseago
sseago previously approved these changes Sep 11, 2024
@kaovilai kaovilai force-pushed the refactor-pluginframeworkdep branch 2 times, most recently from 639e69e to 2d3c8ca Compare September 12, 2024 03:34
Lyndon-Li
Lyndon-Li previously approved these changes Sep 12, 2024
@kaovilai
Copy link
Contributor Author

rebasing against #8201

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
before
```go
❯ find ./pkg/cmd/server/config -maxdepth 1 -type f | grep .go | xargs -I {} sh -c "echo && echo && echo {} && go list -f {{.Deps}} {} | sed 's/ /\n/g' | grep -E 'github.com/vmware-tanzu/velero/pkg/podvolume'"

./pkg/cmd/server/config/config.go
github.com/vmware-tanzu/velero/pkg/podvolume

./pkg/cmd/server/config/config_test.go
```

after
```go
~/git/velero refactor-pluginframeworkdep
❯ find ./pkg/cmd/server/config -maxdepth 1 -type f | grep .go | xargs -I {} sh -c "echo && echo && echo {} && go list -f {{.Deps}} {} | sed 's/ /\n/g' | grep -E 'github.com/vmware-tanzu/velero/pkg/podvolume'"

./pkg/cmd/server/config/config.go
github.com/vmware-tanzu/velero/pkg/podvolume/configs

./pkg/cmd/server/config/config_test.go
```

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@ywk253100 ywk253100 merged commit 3f9c2dc into vmware-tanzu:main Sep 13, 2024
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants