Skip to content

Commit

Permalink
fix: bug where v2 resource lister was not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Feb 14, 2022
1 parent 45174b3 commit e8b6493
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/nuke/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (s *scanner) list(authorizers azure.Authorizers, tenantId, subscriptionId,
for _, r := range rs {
s.items <- &queue.Item{
Authorizers: authorizers,
TenantId: tenantId,
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
Resource: r,
Expand Down
10 changes: 8 additions & 2 deletions pkg/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Item struct {
Reason string

Authorizers azure.Authorizers
TenantId string
SubscriptionId string
ResourceGroup string

Expand All @@ -57,15 +58,20 @@ func (i *Item) Print() {

// List gets all resource items of the same resource type like the Item.
func (i *Item) List() ([]resource.Resource, error) {
listers := resource.GetListers()
listers := resource.GetListersV2()
/*
sess, err := i.Region.Session(i.Type)
if err != nil {
return nil, err
}
return listers[i.Type](sess)
*/
return listers[i.Type](i.Authorizers, i.SubscriptionId, i.ResourceGroup)
return listers[i.Type](resource.ListerOpts{
Authorizers: i.Authorizers,
TenantId: i.TenantId,
SubscriptionId: i.SubscriptionId,
ResourceGroup: i.ResourceGroup,
})
}

func (i *Item) GetProperty(key string) (string, error) {
Expand Down
12 changes: 7 additions & 5 deletions resources/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (

type Disk struct {
client compute.DisksClient
name *string
name string
rg string
}

func init() {
Expand Down Expand Up @@ -51,7 +52,8 @@ func ListDisk(opts resource.ListerOpts) ([]resource.Resource, error) {
for _, g := range list.Values() {
resources = append(resources, &Disk{
client: client,
name: g.Name,
name: *g.Name,
rg: opts.ResourceGroup,
})
}

Expand All @@ -64,18 +66,18 @@ func ListDisk(opts resource.ListerOpts) ([]resource.Resource, error) {
}

func (r *Disk) Remove() error {
_, err := r.client.Delete(context.TODO(), "Default", *r.name)
_, err := r.client.Delete(context.TODO(), r.rg, r.name)
return err
}

func (r *Disk) Properties() types.Properties {
properties := types.NewProperties()

properties.Set("Name", *r.name)
properties.Set("Name", r.name)

return properties
}

func (r *Disk) String() string {
return *r.name
return r.name
}

0 comments on commit e8b6493

Please sign in to comment.