Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Add properties to servicecatalog resources #598

Merged
merged 1 commit into from
Feb 8, 2021
Merged
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
23 changes: 17 additions & 6 deletions resources/servicecatalog-portfolio-constraints-attachements.go
Original file line number Diff line number Diff line change
@@ -6,13 +6,15 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
log "github.com/sirupsen/logrus"
)

type ServiceCatalogConstraintPortfolioAttachment struct {
svc *servicecatalog.ServiceCatalog
constraintID *string
portfolioID *string
svc *servicecatalog.ServiceCatalog
constraintID *string
portfolioID *string
portfolioName *string
}

func init() {
@@ -64,9 +66,10 @@ func ListServiceCatalogPrincipalProductAttachments(sess *session.Session) ([]Res

for _, constraintDetail := range resp.ConstraintDetails {
resources = append(resources, &ServiceCatalogConstraintPortfolioAttachment{
svc: svc,
portfolioID: portfolio.Id,
constraintID: constraintDetail.ConstraintId,
svc: svc,
portfolioID: portfolio.Id,
constraintID: constraintDetail.ConstraintId,
portfolioName: portfolio.DisplayName,
})
}

@@ -89,6 +92,14 @@ func (f *ServiceCatalogConstraintPortfolioAttachment) Remove() error {
return err
}

func (f *ServiceCatalogConstraintPortfolioAttachment) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("PortfolioID", f.portfolioID)
properties.Set("ConstraintID", f.constraintID)
properties.Set("PortfolioName", f.portfolioName)
return properties
}

func (f *ServiceCatalogConstraintPortfolioAttachment) String() string {
return fmt.Sprintf("%s -> %s", *f.constraintID, *f.portfolioID)
}
23 changes: 17 additions & 6 deletions resources/servicecatalog-portfolio-principal-attachements.go
Original file line number Diff line number Diff line change
@@ -6,12 +6,14 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogPrincipalPortfolioAttachment struct {
svc *servicecatalog.ServiceCatalog
portfolioID *string
principalARN *string
svc *servicecatalog.ServiceCatalog
portfolioID *string
principalARN *string
portfolioName *string
}

func init() {
@@ -60,9 +62,10 @@ func ListServiceCatalogPrincipalPortfolioAttachments(sess *session.Session) ([]R

for _, principal := range resp.Principals {
resources = append(resources, &ServiceCatalogPrincipalPortfolioAttachment{
svc: svc,
principalARN: principal.PrincipalARN,
portfolioID: portfolio.Id,
svc: svc,
principalARN: principal.PrincipalARN,
portfolioID: portfolio.Id,
portfolioName: portfolio.DisplayName,
})
}

@@ -86,6 +89,14 @@ func (f *ServiceCatalogPrincipalPortfolioAttachment) Remove() error {
return err
}

func (f *ServiceCatalogPrincipalPortfolioAttachment) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("PortfolioID", f.portfolioID)
properties.Set("PrincipalARN", f.principalARN)
properties.Set("PortfolioName", f.portfolioName)
return properties
}

func (f *ServiceCatalogPrincipalPortfolioAttachment) String() string {
return fmt.Sprintf("%s -> %s", *f.principalARN, *f.portfolioID)
}
34 changes: 24 additions & 10 deletions resources/servicecatalog-portfolio-product-attachements.go
Original file line number Diff line number Diff line change
@@ -6,12 +6,15 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogPortfolioProductAttachment struct {
svc *servicecatalog.ServiceCatalog
productID *string
portfolioID *string
svc *servicecatalog.ServiceCatalog
productID *string
portfolioID *string
portfolioName *string
productName *string
}

func init() {
@@ -21,7 +24,7 @@ func init() {
func ListServiceCatalogPortfolioProductAttachments(sess *session.Session) ([]Resource, error) {
svc := servicecatalog.New(sess)
resources := []Resource{}
products := []*string{}
products := make(map[*string]*string)

params := &servicecatalog.SearchProductsAsAdminInput{
PageSize: aws.Int64(20),
@@ -35,7 +38,7 @@ func ListServiceCatalogPortfolioProductAttachments(sess *session.Session) ([]Res
}

for _, productViewDetail := range resp.ProductViewDetails {
products = append(products, productViewDetail.ProductViewSummary.ProductId)
products[productViewDetail.ProductViewSummary.ProductId] = productViewDetail.ProductViewSummary.Name
}

if resp.NextPageToken == nil {
@@ -49,9 +52,9 @@ func ListServiceCatalogPortfolioProductAttachments(sess *session.Session) ([]Res
PageSize: aws.Int64(20),
}

for _, product := range products {
for productID, productName := range products {

portfolioParams.ProductId = product
portfolioParams.ProductId = productID

resp, err := svc.ListPortfoliosForProduct(portfolioParams)
if err != nil {
@@ -60,9 +63,11 @@ func ListServiceCatalogPortfolioProductAttachments(sess *session.Session) ([]Res

for _, portfolioDetail := range resp.PortfolioDetails {
resources = append(resources, &ServiceCatalogPortfolioProductAttachment{
svc: svc,
productID: product,
portfolioID: portfolioDetail.Id,
svc: svc,
productID: productID,
portfolioID: portfolioDetail.Id,
portfolioName: portfolioDetail.DisplayName,
productName: productName,
})
}

@@ -86,6 +91,15 @@ func (f *ServiceCatalogPortfolioProductAttachment) Remove() error {
return err
}

func (f *ServiceCatalogPortfolioProductAttachment) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("PortfolioID", f.portfolioID)
properties.Set("PortfolioName", f.portfolioName)
properties.Set("ProductID", f.productID)
properties.Set("ProductName", f.productName)
return properties
}

func (f *ServiceCatalogPortfolioProductAttachment) String() string {
return fmt.Sprintf("%s -> %s", *f.productID, *f.portfolioID)
}
23 changes: 17 additions & 6 deletions resources/servicecatalog-portfolio-share-attachements.go
Original file line number Diff line number Diff line change
@@ -6,12 +6,14 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogPortfolioShareAttachment struct {
svc *servicecatalog.ServiceCatalog
portfolioID *string
accountID *string
svc *servicecatalog.ServiceCatalog
portfolioID *string
accountID *string
portfolioName *string
}

func init() {
@@ -59,9 +61,10 @@ func ListServiceCatalogPortfolioShareAttachments(sess *session.Session) ([]Resou

for _, account := range resp.AccountIds {
resources = append(resources, &ServiceCatalogPortfolioShareAttachment{
svc: svc,
portfolioID: portfolio.Id,
accountID: account,
svc: svc,
portfolioID: portfolio.Id,
accountID: account,
portfolioName: portfolio.DisplayName,
})
}

@@ -80,6 +83,14 @@ func (f *ServiceCatalogPortfolioShareAttachment) Remove() error {
return err
}

func (f *ServiceCatalogPortfolioShareAttachment) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("PortfolioID", f.portfolioID)
properties.Set("PortfolioName", f.portfolioName)
properties.Set("AccountID", f.accountID)
return properties
}

func (f *ServiceCatalogPortfolioShareAttachment) String() string {
return fmt.Sprintf("%s -> %s", *f.portfolioID, *f.accountID)
}
29 changes: 23 additions & 6 deletions resources/servicecatalog-portfolio-tagoptions-attachements.go
Original file line number Diff line number Diff line change
@@ -6,13 +6,17 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
log "github.com/sirupsen/logrus"
)

type ServiceCatalogTagOptionPortfolioAttachment struct {
svc *servicecatalog.ServiceCatalog
tagOptionID *string
resourceID *string
svc *servicecatalog.ServiceCatalog
tagOptionID *string
resourceID *string
tagOptionKey *string
tagOptionValue *string
resourceName *string
}

func init() {
@@ -64,9 +68,12 @@ func ListServiceCatalogTagOptionPortfolioAttachments(sess *session.Session) ([]R

for _, resourceDetail := range resp.ResourceDetails {
resources = append(resources, &ServiceCatalogTagOptionPortfolioAttachment{
svc: svc,
tagOptionID: tagOption.Id,
resourceID: resourceDetail.Id,
svc: svc,
tagOptionID: tagOption.Id,
resourceID: resourceDetail.Id,
resourceName: resourceDetail.Name,
tagOptionKey: tagOption.Key,
tagOptionValue: tagOption.Value,
})
}

@@ -90,6 +97,16 @@ func (f *ServiceCatalogTagOptionPortfolioAttachment) Remove() error {
return err
}

func (f *ServiceCatalogTagOptionPortfolioAttachment) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("TagOptionID", f.tagOptionID)
properties.Set("TagOptionKey", f.tagOptionKey)
properties.Set("TagOptionValue", f.tagOptionValue)
properties.Set("ResourceID", f.resourceID)
properties.Set("ResourceName", f.resourceName)
return properties
}

func (f *ServiceCatalogTagOptionPortfolioAttachment) String() string {
return fmt.Sprintf("%s -> %s", *f.tagOptionID, *f.resourceID)
}
21 changes: 17 additions & 4 deletions resources/servicecatalog-portfolios.go
Original file line number Diff line number Diff line change
@@ -4,11 +4,14 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogPortfolio struct {
svc *servicecatalog.ServiceCatalog
ID *string
svc *servicecatalog.ServiceCatalog
ID *string
displayName *string
providerName *string
}

func init() {
@@ -31,8 +34,10 @@ func ListServiceCatalogPortfolios(sess *session.Session) ([]Resource, error) {

for _, portfolioDetail := range resp.PortfolioDetails {
resources = append(resources, &ServiceCatalogPortfolio{
svc: svc,
ID: portfolioDetail.Id,
svc: svc,
ID: portfolioDetail.Id,
displayName: portfolioDetail.DisplayName,
providerName: portfolioDetail.ProviderName,
})
}

@@ -55,6 +60,14 @@ func (f *ServiceCatalogPortfolio) Remove() error {
return err
}

func (f *ServiceCatalogPortfolio) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ID", f.ID)
properties.Set("DisplayName", f.displayName)
properties.Set("ProviderName", f.providerName)
return properties
}

func (f *ServiceCatalogPortfolio) String() string {
return *f.ID
}
18 changes: 14 additions & 4 deletions resources/servicecatalog-products.go
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogProduct struct {
svc *servicecatalog.ServiceCatalog
ID *string
svc *servicecatalog.ServiceCatalog
ID *string
name *string
}

func init() {
@@ -31,8 +33,9 @@ func ListServiceCatalogProducts(sess *session.Session) ([]Resource, error) {

for _, productView := range resp.ProductViewDetails {
resources = append(resources, &ServiceCatalogProduct{
svc: svc,
ID: productView.ProductViewSummary.ProductId,
svc: svc,
ID: productView.ProductViewSummary.ProductId,
name: productView.ProductViewSummary.Name,
})
}

@@ -55,6 +58,13 @@ func (f *ServiceCatalogProduct) Remove() error {
return err
}

func (f *ServiceCatalogProduct) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ID", f.ID)
properties.Set("Name", f.name)
return properties
}

func (f *ServiceCatalogProduct) String() string {
return *f.ID
}
13 changes: 13 additions & 0 deletions resources/servicecatalog-provisionedproducts.go
Original file line number Diff line number Diff line change
@@ -4,12 +4,15 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type ServiceCatalogProvisionedProduct struct {
svc *servicecatalog.ServiceCatalog
ID *string
terminateToken *string
name *string
productID *string
}

func init() {
@@ -39,6 +42,8 @@ func ListServiceCatalogProvisionedProducts(sess *session.Session) ([]Resource, e
svc: svc,
ID: provisionedProduct.Id,
terminateToken: provisionedProduct.IdempotencyToken,
name: provisionedProduct.Name,
productID: provisionedProduct.ProductId,
})
}

@@ -62,6 +67,14 @@ func (f *ServiceCatalogProvisionedProduct) Remove() error {
return err
}

func (f *ServiceCatalogProvisionedProduct) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ID", f.ID)
properties.Set("Name", f.name)
properties.Set("ProductID", f.productID)
return properties
}

func (f *ServiceCatalogProvisionedProduct) String() string {
return *f.ID
}
21 changes: 17 additions & 4 deletions resources/servicecatalog-tagoptions.go
Original file line number Diff line number Diff line change
@@ -4,12 +4,15 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/rebuy-de/aws-nuke/pkg/types"
log "github.com/sirupsen/logrus"
)

type ServiceCatalogTagOption struct {
svc *servicecatalog.ServiceCatalog
ID *string
svc *servicecatalog.ServiceCatalog
ID *string
key *string
value *string
}

func init() {
@@ -36,8 +39,10 @@ func ListServiceCatalogTagOptions(sess *session.Session) ([]Resource, error) {

for _, tagOptionDetail := range resp.TagOptionDetails {
resources = append(resources, &ServiceCatalogTagOption{
svc: svc,
ID: tagOptionDetail.Id,
svc: svc,
ID: tagOptionDetail.Id,
key: tagOptionDetail.Key,
value: tagOptionDetail.Value,
})
}

@@ -60,6 +65,14 @@ func (f *ServiceCatalogTagOption) Remove() error {
return err
}

func (f *ServiceCatalogTagOption) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ID", f.ID)
properties.Set("Key", f.key)
properties.Set("Value", f.value)
return properties
}

func (f *ServiceCatalogTagOption) String() string {
return *f.ID
}