Skip to content

Commit

Permalink
Exporter: logging improvements (#1895)
Browse files Browse the repository at this point in the history
- Use 1-based numeration in `databricks_secret_scope` listing instead of 0-based that is
  confusing for users
- Improve logging when listing `databricks_job` resources
  • Loading branch information
alexott authored Jan 3, 2023
1 parent 8c16069 commit 242ff84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ var resourcesMap map[string]importable = map[string]importable{
return err
}
// TODO: don't export users and admins group
for _, g := range ic.allGroups {
for offset, g := range ic.allGroups {
if !ic.MatchesName(g.DisplayName) {
log.Printf("[INFO] Group %s doesn't match %s filter", g.DisplayName, ic.match)
continue
Expand All @@ -528,6 +528,7 @@ var resourcesMap map[string]importable = map[string]importable{
Resource: "databricks_group",
ID: g.ID,
})
log.Printf("[INFO] Scanned %d of %d groups", offset+1, len(ic.allGroups))
}
return nil
},
Expand Down Expand Up @@ -793,7 +794,7 @@ var resourcesMap map[string]importable = map[string]importable{
ID: scope.Name,
Name: scope.Name,
})
log.Printf("[INFO] Imported %d of %d secret scopes", i, len(scopes))
log.Printf("[INFO] Imported %d of %d secret scopes", i+1, len(scopes))
}
}
return nil
Expand Down
5 changes: 3 additions & 2 deletions exporter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (ic *importContext) importJobs(l []jobs.Job) {
a := jobs.NewJobsAPI(ic.Context, ic.Client)
starterAfter := (nowSeconds - (ic.lastActiveDays * 24 * 60 * 60)) * 1000
i := 0
for _, job := range l {
for offset, job := range l {
if !ic.MatchesName(job.Settings.Name) {
log.Printf("[INFO] Job name %s doesn't match selection %s", job.Settings.Name, ic.match)
continue
Expand Down Expand Up @@ -396,8 +396,9 @@ func (ic *importContext) importJobs(l []jobs.Job) {
ID: job.ID(),
})
i++
log.Printf("[INFO] Imported %d of total %d jobs", i, len(l))
log.Printf("[INFO] Scanned %d of total %d jobs", offset+1, len(l))
}
log.Printf("[INFO] %d of total %d jobs are going to be imported", i, len(l))
}

// returns created file name in "files" directory for the export and error if any
Expand Down

0 comments on commit 242ff84

Please sign in to comment.