-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec3c02e
commit 7abbcd2
Showing
6 changed files
with
60 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package translate | ||
|
||
import "github.com/paloaltonetworks/pan-os-codegen/pkg/imports" | ||
|
||
func RenderImports(templateType string) (string, error) { | ||
manager := imports.NewManager() | ||
|
||
switch templateType { | ||
case "entry": | ||
manager.AddStandardImport("encoding/xml", "") | ||
manager.AddStandardImport("fmt", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/filtering", "filtering") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/generic", "generic") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "util") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/version", "version") | ||
case "location": | ||
manager.AddStandardImport("fmt", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/errors", "errors") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "util") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/version", "version") | ||
case "service": | ||
manager.AddStandardImport("context", "") | ||
manager.AddStandardImport("fmt", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/errors", "errors") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/filtering", "filtering") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "util") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/xmlapi", "xmlapi") | ||
} | ||
|
||
return manager.RenderImports() | ||
} |
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,25 @@ | ||
package translate | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestRenderImports(t *testing.T) { | ||
// given | ||
expectedImports := ` | ||
import ( | ||
"fmt" | ||
errors "github.com/PaloAltoNetworks/pango/errors" | ||
util "github.com/PaloAltoNetworks/pango/util" | ||
version "github.com/PaloAltoNetworks/pango/version" | ||
)` | ||
|
||
// when | ||
actualImports, _ := RenderImports("location") | ||
|
||
// then | ||
assert.NotNil(t, actualImports) | ||
assert.Equal(t, expectedImports, actualImports) | ||
} |
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