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

chore: use separate registry package from libnuke with [email protected] #75

Merged
merged 3 commits into from
Feb 13, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.6

require (
github.com/aws/aws-sdk-go v1.50.4
github.com/ekristen/libnuke v0.8.0
github.com/ekristen/libnuke v0.9.1
github.com/fatih/color v1.16.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ekristen/libnuke v0.8.0 h1:dxs+RosOcstbzvxnLyWN4mq1mAuOqMRUi7LEBC8rk44=
github.com/ekristen/libnuke v0.8.0/go.mod h1:WhYx7LDAkvkXwwfhWCASRn7fbifF8kfyhNsUj5zCCVs=
github.com/ekristen/libnuke v0.9.1 h1:AoX1cggVTanP671Xuh6kJRv0HEp26NLqqPTzwYbz9I0=
github.com/ekristen/libnuke v0.9.1/go.mod h1:WhYx7LDAkvkXwwfhWCASRn7fbifF8kfyhNsUj5zCCVs=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
Expand Down
7 changes: 3 additions & 4 deletions pkg/commands/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"github.com/ekristen/aws-nuke/pkg/commands/global"
"github.com/ekristen/aws-nuke/pkg/common"

"github.com/ekristen/libnuke/pkg/resource"

_ "github.com/ekristen/aws-nuke/resources"
"github.com/ekristen/libnuke/pkg/registry"
)

func execute(c *cli.Context) error {
ls := resource.GetNames()
ls := registry.GetNames()

sort.Strings(ls)

Expand All @@ -25,7 +24,7 @@ func execute(c *cli.Context) error {
continue
}

reg := resource.GetRegistration(name)
reg := registry.GetRegistration(name)

if reg.AlternativeResource != "" {
color.New(color.Bold).Printf("%-55s\n", name)
Expand Down
8 changes: 4 additions & 4 deletions pkg/commands/nuke/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nuke
import (
"context"
"fmt"
"github.com/ekristen/libnuke/pkg/registry"
"slices"
"time"

Expand All @@ -13,7 +14,6 @@ import (

libconfig "github.com/ekristen/libnuke/pkg/config"
libnuke "github.com/ekristen/libnuke/pkg/nuke"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/scanner"
"github.com/ekristen/libnuke/pkg/types"

Expand Down Expand Up @@ -67,7 +67,7 @@ func execute(c *cli.Context) error {
// Parse the user supplied configuration file to pass in part to configure the nuke process.
parsedConfig, err := config.New(libconfig.Options{
Path: c.Path("config"),
Deprecations: resource.GetDeprecatedResourceTypeMapping(),
Deprecations: registry.GetDeprecatedResourceTypeMapping(),
})
if err != nil {
logrus.Errorf("Failed to parse config file %s", c.Path("config"))
Expand Down Expand Up @@ -124,7 +124,7 @@ func execute(c *cli.Context) error {
// Resolve the resource types to be used for the nuke process based on the parameters, global configuration, and
// account level configuration.
resourceTypes := types.ResolveResourceTypes(
resource.GetNames(),
registry.GetNames(),
[]types.Collection{
n.Parameters.Includes,
parsedConfig.ResourceTypes.GetIncludes(),
Expand All @@ -140,7 +140,7 @@ func execute(c *cli.Context) error {
parsedConfig.ResourceTypes.GetAlternatives(),
accountConfig.ResourceTypes.GetAlternatives(),
},
resource.GetAlternativeResourceTypeMapping(),
registry.GetAlternativeResourceTypeMapping(),
)

// Register the scanners for each region that is defined in the configuration.
Expand Down
4 changes: 2 additions & 2 deletions pkg/nuke/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package nuke
import (
"github.com/aws/aws-sdk-go/aws/session"

"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/registry"
)

// Account is the resource scope that all resources in AWS Nuke are registered against.
const Account resource.Scope = "account"
const Account registry.Scope = "account"

// ListerOpts are the options for the Lister functions of each individual resource. It is passed in as an interface{}
// so that each implementing tool can define their own options for the lister. Each resource then asserts the type on
Expand Down
3 changes: 2 additions & 1 deletion resources/accessanalyzer-analyzers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/accessanalyzer"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -23,7 +24,7 @@ type AccessAnalyzer struct {
}

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AccessAnalyzerResource,
Scope: nuke.Account,
Lister: &AccessAnalyzerLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/accessanalyzer-archiverules.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/aws/aws-sdk-go/service/accessanalyzer"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -14,7 +15,7 @@ import (
const AccessAnalyzerArchiveRuleResource = "ArchiveRule"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AccessAnalyzerArchiveRuleResource,
Scope: nuke.Account,
Lister: &AccessAnalyzerArchiveRuleLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/acm-certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/acm"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -15,7 +16,7 @@ import (
const ACMCertificateResource = "ACMCertificate"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: ACMCertificateResource,
Scope: nuke.Account,
Lister: &ACMCertificateLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/acmpca-certificateauthorities.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/acmpca"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -17,7 +18,7 @@ import (
const ACMPCACertificateAuthorityResource = "ACMPCACertificateAuthority"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: ACMPCACertificateAuthorityResource,
Scope: nuke.Account,
Lister: &ACMPCACertificateAuthorityLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/acmpca-certificateauthoritystates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/acmpca"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -17,7 +18,7 @@ import (
const ACMPCACertificateAuthorityStateResource = "ACMPCACertificateAuthorityState"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: ACMPCACertificateAuthorityStateResource,
Scope: nuke.Account,
Lister: &ACMPCACertificateAuthorityStateLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigateway-apikeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"

"github.com/ekristen/aws-nuke/pkg/nuke"
Expand All @@ -14,7 +15,7 @@ import (
const APIGatewayAPIKeyResource = "APIGatewayAPIKey"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayAPIKeyResource,
Scope: nuke.Account,
Lister: &APIGatewayAPIKeyLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigateway-clientcertificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"

"github.com/ekristen/aws-nuke/pkg/nuke"
Expand All @@ -14,7 +15,7 @@ import (
const APIGatewayClientCertificateResource = "APIGatewayClientCertificate"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayClientCertificateResource,
Scope: nuke.Account,
Lister: &APIGatewayClientCertificateLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigateway-domainnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"

"github.com/ekristen/aws-nuke/pkg/nuke"
Expand All @@ -14,7 +15,7 @@ import (
const APIGatewayDomainNameResource = "APIGatewayDomainName"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayDomainNameResource,
Scope: nuke.Account,
Lister: &APIGatewayDomainNameLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigateway-restapis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -15,7 +16,7 @@ import (
const APIGatewayRestAPIResource = "APIGatewayRestAPI"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayRestAPIResource,
Scope: nuke.Account,
Lister: &APIGatewayRestAPILister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigateway-usageplans.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -15,7 +16,7 @@ import (
const APIGatewayUsagePlanResource = "APIGatewayUsagePlan"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayUsagePlanResource,
Scope: nuke.Account,
Lister: &APIGatewayUsagePlanLister{},
Expand Down
7 changes: 5 additions & 2 deletions resources/apigateway-vpclinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/ekristen/aws-nuke/pkg/nuke"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

"github.com/ekristen/aws-nuke/pkg/nuke"
)

const APIGatewayVpcLinkResource = "APIGatewayVpcLink"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayVpcLinkResource,
Scope: nuke.Account,
Lister: &APIGatewayVpcLinkLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigatewayv2-apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigatewayv2"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -15,7 +16,7 @@ import (
const APIGatewayV2APIResource = "APIGatewayV2API"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayV2APIResource,
Scope: nuke.Account,
Lister: &APIGatewayV2APILister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/apigatewayv2-vpc-links.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigatewayv2"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -15,7 +16,7 @@ import (
const APIGatewayV2VpcLinkResource = "APIGatewayV2VpcLink"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: APIGatewayV2VpcLinkResource,
Scope: nuke.Account,
Lister: &APIGatewayV2VpcLinkLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/appconfig-applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appconfig"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -21,7 +22,7 @@ type AppConfigApplication struct {
const AppConfigApplicationResource = "AppConfigApplication"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AppConfigApplicationResource,
Scope: nuke.Account,
Lister: &AppConfigApplicationLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/appconfig-configurationprofiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appconfig"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -24,7 +25,7 @@ type AppConfigConfigurationProfile struct {
const AppConfigConfigurationProfileResource = "AppConfigConfigurationProfile"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AppConfigConfigurationProfileResource,
Scope: nuke.Account,
Lister: &AppConfigConfigurationProfileLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/appconfig-deploymentstrategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appconfig"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -23,7 +24,7 @@ type AppConfigDeploymentStrategy struct {
const AppConfigDeploymentStrategyResource = "AppConfigDeploymentStrategy"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AppConfigDeploymentStrategyResource,
Scope: nuke.Account,
Lister: &AppConfigDeploymentStrategyLister{},
Expand Down
3 changes: 2 additions & 1 deletion resources/appconfig-environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appconfig"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

Expand All @@ -24,7 +25,7 @@ type AppConfigEnvironment struct {
const AppConfigEnvironmentResource = "AppConfigEnvironment"

func init() {
resource.Register(&resource.Registration{
registry.Register(&registry.Registration{
Name: AppConfigEnvironmentResource,
Scope: nuke.Account,
Lister: &AppConfigEnvironmentLister{},
Expand Down
Loading