Skip to content

Commit

Permalink
Merge branch 'master' into equinix-metal-provider-init
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarhee authored Apr 6, 2021
2 parents d1522cd + bb70d31 commit dc2225f
Show file tree
Hide file tree
Showing 141 changed files with 2,426 additions and 1,502 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "tagged-release"
on:
push:
tags:
- "*"
workflow_dispatch:
tags:
description: 'Release'
jobs:
tagged-release:
name: "Tagged Release"
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Test
run: go build -v && go test ./...
- name: Build for linux
run: go build -o terraformer-all-linux-amd64
- name: Build for mac
run: GOOS=darwin go build -o terraformer-all-darwin-amd64
- name: Build for windows
run: GOOS=windows go build -o terraformer-all-windows-amd64
- name: Build for all providers
run: go run build/multi-build/main.go

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
terraformer-*
17 changes: 17 additions & 0 deletions .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.'
days-before-issue-stale: 60
days-before-issue-close: 7
days-before-pr-close: -1
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ A CLI tool that generates `tf`/`json` and `tfstate` files based on existing infr
* [Logz.io](#use-with-logzio)
* [Commercetools](#use-with-commercetools)
* [Mikrotik](#use-with-mikrotik)
* [Xen Orchestra](#use-with-xenorchestra)
* [GmailFilter](#use-with-gmailfilter)
- [Contributing](#contributing)
- [Developing](#developing)
Expand Down Expand Up @@ -231,6 +232,7 @@ sudo mv terraformer-${PROVIDER}-darwin-amd64 /usr/local/bin/terraformer
If you want to use a package manager:

- [Homebrew](https://brew.sh/) users can use `brew install terraformer`.
- [MacPorts](https://www.macports.org/) users can use `sudo port install terraformer`.
- [Chocolatey](https://chocolatey.org/) users can use `choco install terraformer`.

Links to download Terraform Providers:
Expand Down Expand Up @@ -258,12 +260,13 @@ Links to download Terraform Providers:
* GitHub provider >=2.2.1 - [here](https://releases.hashicorp.com/terraform-provider-github/)
* Monitoring & System Management
* Datadog provider >2.1.0 - [here](https://releases.hashicorp.com/terraform-provider-datadog/)
* New Relic provider >1.5.0 - [here](https://releases.hashicorp.com/terraform-provider-newrelic/)
* New Relic provider >2.0.0 - [here](https://releases.hashicorp.com/terraform-provider-newrelic/)
* Community
* Keycloak provider >=1.19.0 - [here](https://github.com/mrparkers/terraform-provider-keycloak/)
* Logz.io provider >=1.1.1 - [here](https://github.com/jonboydell/logzio_terraform_provider/)
* Commercetools provider >= 0.21.0 - [here](https://github.com/labd/terraform-provider-commercetools)
* Mikrotik provider >= 0.2.2 - [here](https://github.com/ddelnano/terraform-provider-mikrotik)
* Xen Orchestra provider >= 0.18.0 - [here](https://github.com/ddelnano/terraform-provider-xenorchestra)
* GmailFilter provider >= 1.0.1 - [here](https://github.com/yamamoto-febc/terraform-provider-gmailfilter)

Information on provider plugins:
Expand Down Expand Up @@ -562,6 +565,8 @@ In that case terraformer will not know with which region resources are associate
* `aws_ecr_lifecycle_policy`
* `aws_ecr_repository`
* `aws_ecr_repository_policy`
* `ecrpublic`
* `aws_ecrpublic_repository`
* `efs`
* `aws_efs_access_point`
* `aws_efs_file_system`
Expand Down Expand Up @@ -609,6 +614,7 @@ In that case terraformer will not know with which region resources are associate
* `kms`
* `aws_kms_key`
* `aws_kms_alias`
* `aws_kms_grant`
* `lambda`
* `aws_lambda_event_source_mapping`
* `aws_lambda_function`
Expand Down Expand Up @@ -651,7 +657,6 @@ In that case terraformer will not know with which region resources are associate
* `aws_route_table_association`
* `s3`
* `aws_s3_bucket`
* `aws_s3_bucket_policy`
* `secretsmanager`
* `aws_secretsmanager_secret`
* `securityhub`
Expand All @@ -678,6 +683,8 @@ In that case terraformer will not know with which region resources are associate
* `aws_sns_topic_subscription`
* `sqs`
* `aws_sqs_queue`
* `ssm`
* `aws_ssm_parameter`
* `subnet`
* `aws_subnet`
* `swf`
Expand Down Expand Up @@ -733,6 +740,7 @@ AWS services that are global will be imported without specified region even if s
List of global AWS services:
* `budgets`
* `cloudfront`
* `ecrpublic`
* `iam`
* `organization`
* `route53`
Expand Down Expand Up @@ -1593,8 +1601,7 @@ List of supported Datadog services:
Example:
```
NEWRELIC_API_KEY=[API-KEY]
./terraformer import newrelic -r alert,dashboard,infra,synthetics
./terraformer import newrelic -r alert,dashboard,infra,synthetics --api-key=NRAK-XXXXXXXX --account-id=XXXXX
```
List of supported New Relic resources:
Expand Down Expand Up @@ -1712,7 +1719,7 @@ List of supported [commercetools](https://commercetools.com/de/) resources:
### Use with [Mikrotik](https://wiki.mikrotik.com/wiki/Manual:TOC)
This provider uses the [terraform-provider-mikrotik](https://github.com/ddelnano/terraform-provider-mikrotik). The terraformer provider was build by [Dom Del Nano](https://github.com/ddelnano).
This provider uses the [terraform-provider-mikrotik](https://github.com/ddelnano/terraform-provider-mikrotik). The terraformer provider was built by [Dom Del Nano](https://github.com/ddelnano).
Example:
Expand All @@ -1729,6 +1736,23 @@ List of supported mikrotik resources:
* `mikrotik_dhcp_lease`
### Use with [Xen Orchestra](https://xen-orchestra.com/)
This provider uses the [terraform-provider-xenorchestra](https://github.com/ddelnano/terraform-provider-xenorchestra). The terraformer provider was built by [Dom Del Nano](https://github.com/ddelnano) on behalf of [Vates SAS](https://vates.fr/) who is sponsoring Dom to work on the project.
Example:
```
## Warning! You should not expose your xenorchestra creds through your bash history. Export them to your shell in a safe way when doing this for real!

XOA_URL=ws://your-xenorchestra-domain XOA_USER=username XOA_PASSWORD=password terraformer import xenorchestra -r=acl
```
List of supported xenorchestra resources:
* `xenorchestra_acl`
* `xenorchestra_resource_set`
### Use with GmailFilter
Expand Down
30 changes: 21 additions & 9 deletions build/multi-build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ const fileSuffix = ".go"
const packageCmdPath = "cmd"

func main() {
//provider := os.Args[1]
// provider := os.Args[1]
allProviders := []string{}
files, err := ioutil.ReadDir(packageCmdPath)
if err != nil {
log.Println(err)
}
for _, f := range files {
if strings.HasPrefix(f.Name(), filePrefix) {
providerName := strings.Replace(f.Name(), filePrefix, "", -1)
providerName = strings.Replace(providerName, fileSuffix, "", -1)
providerName := strings.ReplaceAll(f.Name(), filePrefix, "")
providerName = strings.ReplaceAll(providerName, fileSuffix, "")
allProviders = append(allProviders, providerName)
}
}
Expand All @@ -48,14 +48,17 @@ func main() {
for _, f := range files {
if strings.HasPrefix(f.Name(), filePrefix) {
if !strings.HasPrefix(f.Name(), filePrefix+provider+fileSuffix) {
providerName := strings.Replace(f.Name(), filePrefix, "", -1)
providerName = strings.Replace(providerName, fileSuffix, "", -1)
providerName := strings.ReplaceAll(f.Name(), filePrefix, "")
providerName = strings.ReplaceAll(providerName, fileSuffix, "")
deletedProvider = append(deletedProvider, providerName)
}
}
}
// move files for deleted providers
os.MkdirAll(packageCmdPath+"/tmp", os.ModePerm)
err := os.MkdirAll(packageCmdPath+"/tmp", os.ModePerm)
if err != nil {
log.Fatal("err:", err)
}
for _, provider := range deletedProvider {
err := os.Rename(packageCmdPath+"/"+filePrefix+provider+fileSuffix, packageCmdPath+"/tmp/"+filePrefix+provider+fileSuffix)
if err != nil {
Expand All @@ -65,6 +68,9 @@ func main() {

// comment deleted providers in code
rootCode, err := ioutil.ReadFile(packageCmdPath + "/root.go")
if err != nil {
log.Fatal("err:", err)
}
lines := strings.Split(string(rootCode), "\n")
newRootCodeLines := make([]string, len(lines))
for i, line := range lines {
Expand All @@ -79,7 +85,10 @@ func main() {
newRootCodeLines[i] = line
}
newRootCode := strings.Join(newRootCodeLines, "\n")
ioutil.WriteFile(packageCmdPath+"/root.go", []byte(newRootCode), os.ModePerm)
err = ioutil.WriteFile(packageCmdPath+"/root.go", []byte(newRootCode), os.ModePerm)
if err != nil {
log.Fatal("err:", err)
}

// build....
cmd := exec.Command("go", "build", "-v", "-o", binaryName)
Expand All @@ -94,8 +103,11 @@ func main() {
}
fmt.Println(outb.String())

//revert code and files
ioutil.WriteFile(packageCmdPath+"/root.go", []byte(rootCode), os.ModePerm)
// revert code and files
err = ioutil.WriteFile(packageCmdPath+"/root.go", rootCode, os.ModePerm)
if err != nil {
log.Fatal("err:", err)
}
for _, provider := range deletedProvider {
err := os.Rename(packageCmdPath+"/tmp/"+filePrefix+provider+fileSuffix, "cmd/"+filePrefix+provider+fileSuffix)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion cmd/provider_cmd_newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ import (
)

func newCmdNewRelicImporter(options ImportOptions) *cobra.Command {
apiKey := ""
accountID := ""
region := ""
cmd := &cobra.Command{
Use: "newrelic",
Short: "Import current state to Terraform configuration from New Relic",
Long: "Import current state to Terraform configuration from New Relic",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newNewRelicProvider()
err := Import(provider, options, []string{})
err := Import(provider, options, []string{apiKey, accountID, region})
if err != nil {
return err
}
Expand All @@ -36,6 +39,9 @@ func newCmdNewRelicImporter(options ImportOptions) *cobra.Command {
}

cmd.AddCommand(listCmd(newNewRelicProvider()))
cmd.PersistentFlags().StringVar(&apiKey, "api-key", "", "Your Personal API Key")
cmd.PersistentFlags().StringVar(&accountID, "account-id", "", "Your Account ID")
cmd.PersistentFlags().StringVar(&region, "region", "US", "")
baseProviderFlags(cmd.PersistentFlags(), &options, "alert", "dashboard=id1:id2:id4")
return cmd
}
Expand Down
Empty file modified cmd/provider_cmd_tencentcloud.go
100755 → 100644
Empty file.
44 changes: 44 additions & 0 deletions cmd/provider_cmd_xenorchestra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019 The Terraformer Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cmd

import (
xenorchestra_terraforming "github.com/GoogleCloudPlatform/terraformer/providers/xenorchestra"
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/spf13/cobra"
)

func newCmdXenorchestraImporter(options ImportOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "xenorchestra",
Short: "Import current state to Terraform configuration from Xen Orchestra",
Long: "Import current state to Terraform configuration from Xen Orchestra",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newXenorchestraProvider()
err := Import(provider, options, []string{})
if err != nil {
return err
}
return nil
},
}

cmd.AddCommand(listCmd(newXenorchestraProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "instance", "acl=name1:name2:name3")
return cmd
}

func newXenorchestraProvider() terraformutils.ProviderGenerator {
return &xenorchestra_terraforming.XenorchestraProvider{}
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func providerImporterSubcommands() []func(options ImportOptions) *cobra.Command
newCmdLogzioImporter,
newCmdCommercetoolsImporter,
newCmdMikrotikImporter,
newCmdXenorchestraImporter,
newCmdGmailfilterImporter,
}
}
Expand Down Expand Up @@ -110,6 +111,7 @@ func providerGenerators() map[string]func() terraformutils.ProviderGenerator {
newLogzioProvider,
newCommercetoolsProvider,
newMikrotikProvider,
newXenorchestraProvider,
newGmailfilterProvider,
} {
list[providerGen().GetName()] = providerGen
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

const version = "v0.8.11"
const version = "v0.8.12"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down
Loading

0 comments on commit dc2225f

Please sign in to comment.