-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from cycloidio/sd-azurerm-provider
AzureRM provider implementation
- Loading branch information
Showing
22 changed files
with
1,225 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package azurerm | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cycloidio/terracognita/errcode" | ||
"github.com/cycloidio/terracognita/provider" | ||
"github.com/cycloidio/terracognita/tag" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func cacheVirtualNetworks(ctx context.Context, a *azurerm, rt string, tags []tag.Tag) ([]provider.Resource, error) { | ||
rs, err := a.cache.Get(rt) | ||
if err != nil { | ||
if errors.Cause(err) != errcode.ErrCacheKeyNotFound { | ||
return nil, errors.WithStack(err) | ||
} | ||
|
||
rs, err = virtualNetworks(ctx, a, rt, tags) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to get virtual networks") | ||
} | ||
|
||
err = a.cache.Set(rt, rs) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return rs, nil | ||
} | ||
|
||
func getVirtualNetworkNames(ctx context.Context, a *azurerm, rt string, tags []tag.Tag) ([]string, error) { | ||
rs, err := cacheVirtualNetworks(ctx, a, rt, tags) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
names := make([]string, 0, len(rs)) | ||
for _, i := range rs { | ||
names = append(names, i.Data().Get("name").(string)) | ||
} | ||
|
||
return names, nil | ||
} |
Oops, something went wrong.