-
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.
feat: Render
service.go
for entry and config (#42)
- Loading branch information
1 parent
49457a5
commit ba3131c
Showing
8 changed files
with
653 additions
and
17 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
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", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/generic", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/version", "") | ||
case "location": | ||
manager.AddStandardImport("fmt", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/errors", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/version", "") | ||
case "service": | ||
manager.AddStandardImport("context", "") | ||
manager.AddStandardImport("fmt", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/errors", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/filtering", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/util", "") | ||
manager.AddSdkImport("github.com/PaloAltoNetworks/pango/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" | ||
"github.com/PaloAltoNetworks/pango/errors" | ||
"github.com/PaloAltoNetworks/pango/util" | ||
"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
Oops, something went wrong.