Skip to content

Commit

Permalink
Merge pull request #3331 from andrewsykim/refactor-resource-tracker
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

refactor resource tracker to be usable across packages

Puts ResourceTracker into its own package `pkg/resources/tracker` so it can be called from different packges without hitting import cycle e.g. `pkg/reources/digitalocean/resource.go`. This is so that we can group cloud specific code into their own packages (`pkg/resources/aws/`. `pkg/resources/gce/`, etc) rather than dump all the resource code from all clouds into `pkg/resources`
  • Loading branch information
Kubernetes Submit Queue committed Sep 6, 2017
2 parents bd3daf4 + d9fa618 commit 26ca294
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 334 deletions.
11 changes: 6 additions & 5 deletions cmd/kops/delete_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/kops/pkg/apis/kops/registry"
"k8s.io/kops/pkg/kubeconfig"
"k8s.io/kops/pkg/resources"
"k8s.io/kops/pkg/resources/tracker"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
Expand Down Expand Up @@ -148,7 +149,7 @@ func RunDeleteCluster(f *util.Factory, out io.Writer, options *DeleteClusterOpti
return err
}

clusterResources := make(map[string]*resources.ResourceTracker)
clusterResources := make(map[string]*tracker.Resource)
for k, resource := range allResources {
if resource.Shared {
continue
Expand All @@ -162,16 +163,16 @@ func RunDeleteCluster(f *util.Factory, out io.Writer, options *DeleteClusterOpti
wouldDeleteCloudResources = true

t := &tables.Table{}
t.AddColumn("TYPE", func(r *resources.ResourceTracker) string {
t.AddColumn("TYPE", func(r *tracker.Resource) string {
return r.Type
})
t.AddColumn("ID", func(r *resources.ResourceTracker) string {
t.AddColumn("ID", func(r *tracker.Resource) string {
return r.ID
})
t.AddColumn("NAME", func(r *resources.ResourceTracker) string {
t.AddColumn("NAME", func(r *tracker.Resource) string {
return r.Name
})
var l []*resources.ResourceTracker
var l []*tracker.Resource
for _, v := range clusterResources {
l = append(l, v)
}
Expand Down
1 change: 1 addition & 0 deletions hack/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ k8s.io/kops/pkg/pretty
k8s.io/kops/pkg/resources
k8s.io/kops/pkg/resources/digitalocean
k8s.io/kops/pkg/resources/digitalocean/dns
k8s.io/kops/pkg/resources/tracker
k8s.io/kops/pkg/systemd
k8s.io/kops/pkg/templates
k8s.io/kops/pkg/testutils
Expand Down
Loading

0 comments on commit 26ca294

Please sign in to comment.