Skip to content

Commit

Permalink
Mocks and basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdi committed Jul 21, 2019
1 parent 05da9f8 commit 956d286
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 141 deletions.
40 changes: 39 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ Commands:
* `retagrg` - Takes tags form a given resource group (`--rg`) and applies them to all of the resources in the resource group. If any existing tags are already there, the new ones with be appended. Adding `--cleantags` will clean ALL the tags on resources before adding new ones.



## Changelog

0.4.7
Expand Down Expand Up @@ -163,5 +162,4 @@ Commands:

Dariusz Dwornikowski,

Nordcloud PAT team (Hold my 🍺, not hold my 🐴🐴)

Nordcloud PAT team (Hold my 🍺, not hold my 🐴🐴)
1 change: 0 additions & 1 deletion cmd/cli/commands/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ var checkCommand = &cobra.Command{
}

return nil
},
}
23 changes: 12 additions & 11 deletions internal/azure/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"bitbucket.org/nordcloud/tagmanager/internal/azure/session"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources/resourcesapi"
"github.com/pkg/errors"
)

Expand All @@ -18,6 +19,17 @@ type BackupEntry struct {
Tags map[string]*string `json:"tags"`
}

type Restorer interface {
Restore() error
}

type TagRestorer struct {
Session *session.AzureSession
ResourcesClient resourcesapi.ClientAPI
ReplaceTags bool
Backup []BackupEntry
}

//NewBackupFromMatched make a file backup from the matching resources
func NewBackupFromMatched(matched map[string]Matched, directory string) string {
var backup []BackupEntry
Expand Down Expand Up @@ -45,17 +57,6 @@ func NewBackupFromMatched(matched map[string]Matched, directory string) string {
return tmpfile.Name()
}

type Restorer interface {
Restore() error
}

type TagRestorer struct {
Session *session.AzureSession
ResourcesClient *resources.Client
ReplaceTags bool
Backup []BackupEntry
}

func (t TagRestorer) Restore() error {
for _, backupEntry := range t.Backup {
fmt.Printf("Restoring tags for [%s]\n", backupEntry.ID)
Expand Down
99 changes: 0 additions & 99 deletions internal/azure/functions.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/azure/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (r ResourceGroupScanner) GetResourcesByResourceGroup(rg string) ([]Resource
}

resource := list.Value()

tab = append(tab, Resource{
Platform: "azure",
ID: *resource.ID,
Expand All @@ -132,6 +131,5 @@ func (r ResourceGroupScanner) GetResourcesByResourceGroup(rg string) ([]Resource
Tags: resource.Tags,
})
}

return tab, nil
}
Loading

0 comments on commit 956d286

Please sign in to comment.