Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nACL optimization - output #232

Closed
wants to merge 130 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
8ae3193
updated subcmds
YairSlobodin1 Aug 5, 2024
2187816
readme
YairSlobodin1 Aug 5, 2024
13ae9a2
Merge branch 'main' into first_step_optimization
YairSlobodin1 Aug 6, 2024
851e02c
generic
YairSlobodin1 Aug 6, 2024
210ddcc
merge
YairSlobodin1 Aug 6, 2024
20ffe15
Merge branch 'main' into use_models
YairSlobodin1 Aug 12, 2024
4aeaef5
updated
YairSlobodin1 Aug 18, 2024
9a4f06d
Merge branch 'main' into use_models
YairSlobodin1 Aug 21, 2024
cec430e
use ipblock size
YairSlobodin1 Aug 26, 2024
b8ee61b
minor changes
YairSlobodin1 Aug 26, 2024
c117941
template
YairSlobodin1 Aug 26, 2024
7e70c95
fixed
YairSlobodin1 Aug 26, 2024
19123f9
minor change
YairSlobodin1 Aug 26, 2024
067edfe
another change
YairSlobodin1 Aug 26, 2024
20ab99f
Merge branch 'optimize' into read_sgs
YairSlobodin1 Aug 26, 2024
2b7f244
added synth prefix
YairSlobodin1 Aug 26, 2024
8203f78
unexported two functions
YairSlobodin1 Aug 26, 2024
5fbeefc
wip
YairSlobodin1 Aug 26, 2024
19c5483
rename folder name
YairSlobodin1 Aug 26, 2024
b228063
Merge branch 'optimize' into read_sgs
YairSlobodin1 Aug 26, 2024
ebe6148
Merge branch 'read_sgs' into output
YairSlobodin1 Aug 26, 2024
74737e7
renaming
YairSlobodin1 Aug 26, 2024
d17ce6d
Merge branch 'optimize' into read_sgs
YairSlobodin1 Aug 26, 2024
32f3104
Merge branch 'read_sgs' into output
YairSlobodin1 Aug 26, 2024
02030ac
updated
YairSlobodin1 Aug 26, 2024
4fb97b4
updated template
YairSlobodin1 Aug 26, 2024
47fe8bb
merge
YairSlobodin1 Aug 26, 2024
1371e59
Merge branch 'read_sgs' into output
YairSlobodin1 Aug 26, 2024
0c9cfe2
wip
YairSlobodin1 Aug 26, 2024
eebd628
template
YairSlobodin1 Aug 27, 2024
26473b3
done
YairSlobodin1 Aug 28, 2024
010ee9d
fixed
YairSlobodin1 Sep 1, 2024
524956c
fixed
YairSlobodin1 Sep 2, 2024
02231d3
use ToIPAddressString
YairSlobodin1 Sep 2, 2024
150f697
Merge branch 'use_models' into optimize
YairSlobodin1 Sep 2, 2024
a005a82
Merge branch 'optimize' into read_sgs
YairSlobodin1 Sep 2, 2024
9692f06
Merge branch 'read_sgs' into output
YairSlobodin1 Sep 2, 2024
002a952
Merge branch 'output' into tcp_algo
YairSlobodin1 Sep 2, 2024
aabe195
wip
YairSlobodin1 Sep 2, 2024
b163645
wip
YairSlobodin1 Sep 3, 2024
1e9a621
wip
YairSlobodin1 Sep 8, 2024
c4f9ed4
wip
YairSlobodin1 Sep 8, 2024
820a023
check protocol is not nil
YairSlobodin1 Sep 8, 2024
2916159
Merge branch 'use_models' into optimize
YairSlobodin1 Sep 8, 2024
a683181
Merge branch 'optimize' into read_sgs
YairSlobodin1 Sep 8, 2024
77a3fe0
Merge branch 'read_sgs' into output
YairSlobodin1 Sep 8, 2024
e3fb24b
Merge branch 'output' into all_algo
YairSlobodin1 Sep 8, 2024
9286689
inbound udp
YairSlobodin1 Sep 9, 2024
a7f68f5
lint
YairSlobodin1 Sep 11, 2024
d25bf9c
make mod
YairSlobodin1 Sep 11, 2024
87180ef
merge wip
YairSlobodin1 Sep 11, 2024
dc400bf
update
YairSlobodin1 Sep 11, 2024
8e5cb2d
wip
YairSlobodin1 Sep 11, 2024
a861722
wip
YairSlobodin1 Sep 12, 2024
40c3a52
fixed
YairSlobodin1 Sep 12, 2024
4af3f7a
merged
YairSlobodin1 Sep 12, 2024
380c62e
fixed
YairSlobodin1 Sep 12, 2024
c22aad0
fixed
YairSlobodin1 Sep 12, 2024
81f6194
fixed
YairSlobodin1 Sep 12, 2024
197ed31
fixed
YairSlobodin1 Sep 12, 2024
3ab9859
merge
YairSlobodin1 Sep 12, 2024
9078e5c
wip
YairSlobodin1 Sep 12, 2024
dfb8a7d
wip
YairSlobodin1 Sep 12, 2024
8895149
implement ip functions
YairSlobodin1 Sep 12, 2024
c8fe2d7
all protocol rule covers the holes
YairSlobodin1 Sep 12, 2024
0a0decd
wip
YairSlobodin1 Sep 24, 2024
cf119cc
wip
YairSlobodin1 Sep 24, 2024
a51e158
documentation
YairSlobodin1 Sep 24, 2024
bd2acb8
merge main
YairSlobodin1 Sep 25, 2024
67f320b
merge
YairSlobodin1 Sep 25, 2024
f93c27c
Merge branch 'optimize' into read_sgs
YairSlobodin1 Sep 25, 2024
6be5ee0
fixed
YairSlobodin1 Sep 25, 2024
2f9991a
wip
YairSlobodin1 Sep 25, 2024
bf9438f
wip
YairSlobodin1 Sep 25, 2024
e3d4668
wip
YairSlobodin1 Sep 25, 2024
ebb4b3b
wip
YairSlobodin1 Sep 25, 2024
f34b9b7
fixed
YairSlobodin1 Sep 25, 2024
3d120cc
Merge branch 'main' into optimize
YairSlobodin1 Sep 25, 2024
f228c0b
Merge branch 'optimize' into read_sgs
YairSlobodin1 Sep 25, 2024
d3c7703
Merge branch 'read_sgs' into output
YairSlobodin1 Sep 25, 2024
b2b0b99
merge
YairSlobodin1 Sep 25, 2024
09528ae
Merge branch 'main' into optimize
YairSlobodin1 Sep 29, 2024
5001289
Merge branch 'optimize' into read_sgs
YairSlobodin1 Sep 29, 2024
a89e1fe
merge
YairSlobodin1 Sep 29, 2024
16764ca
Merge branch 'output' into all_algo
YairSlobodin1 Sep 29, 2024
ca64cee
avoid code dup
YairSlobodin1 Sep 30, 2024
49f4a47
fixed
YairSlobodin1 Sep 30, 2024
766f737
fix output fmts
YairSlobodin1 Sep 30, 2024
d326453
Merge branch 'output' into all_algo
YairSlobodin1 Sep 30, 2024
e6bb1b3
tests template
YairSlobodin1 Sep 30, 2024
34410ed
tests data
YairSlobodin1 Sep 30, 2024
28a55ec
wip
YairSlobodin1 Sep 30, 2024
4919d00
Read sgs (#192)
YairSlobodin1 Oct 1, 2024
0fa5920
Merge branch 'main' into optimize
YairSlobodin1 Oct 1, 2024
3145c59
merge
YairSlobodin1 Oct 1, 2024
cd621ce
Merge branch 'output' into all_algo
YairSlobodin1 Oct 1, 2024
2de0e77
wip
YairSlobodin1 Oct 1, 2024
02cae44
Optimize output and flags (#193)
YairSlobodin1 Oct 2, 2024
b496279
wip
YairSlobodin1 Oct 2, 2024
6fcb85f
Merge branch 'main' into optimize
YairSlobodin1 Oct 7, 2024
bca5f6f
Merge branch 'optimize' into all_algo
YairSlobodin1 Oct 7, 2024
11effb7
fix merging
YairSlobodin1 Oct 7, 2024
2bb0719
models new version, cubes, wip
YairSlobodin1 Oct 8, 2024
fadb26b
portset
YairSlobodin1 Oct 9, 2024
3cdadc6
convert ip cubes, generic ipCubeToRule
YairSlobodin1 Oct 9, 2024
69ca412
delete test
YairSlobodin1 Oct 9, 2024
c2512d9
make fmt
YairSlobodin1 Oct 9, 2024
28c3a3b
remove utils func
YairSlobodin1 Oct 9, 2024
9cd8663
models v0.5.1
YairSlobodin1 Oct 9, 2024
da1c7d2
fixed
YairSlobodin1 Oct 9, 2024
4f54945
another test, fixed icmp bug
YairSlobodin1 Oct 9, 2024
fe6f4e3
small fixes
YairSlobodin1 Oct 20, 2024
2f08925
fixed
YairSlobodin1 Oct 20, 2024
fb59982
added isSynth argument
YairSlobodin1 Oct 20, 2024
27bbf91
read sg targets, rename attached to targets
YairSlobodin1 Oct 20, 2024
40e87d3
tf comment, read targets
YairSlobodin1 Oct 20, 2024
5616f9e
fixed
YairSlobodin1 Oct 21, 2024
93f805c
added a test
YairSlobodin1 Oct 21, 2024
3ec4c70
fixed
YairSlobodin1 Oct 22, 2024
5ed0542
read acls
YairSlobodin1 Oct 29, 2024
0372fb5
fixed flags
YairSlobodin1 Oct 29, 2024
7919f35
wip
YairSlobodin1 Oct 29, 2024
7066232
typo
YairSlobodin1 Oct 29, 2024
79c033c
Merge branch 'flags' into output
YairSlobodin1 Oct 29, 2024
c9a434a
json output
YairSlobodin1 Oct 29, 2024
2eb5a5c
>=
YairSlobodin1 Oct 29, 2024
068a2eb
Merge branch 'json_optimize' into optimization_locals
YairSlobodin1 Oct 29, 2024
4c976b9
Merge branch 'optimization_locals' into read_nacls
YairSlobodin1 Oct 29, 2024
d5b4b03
Merge branch 'read_nacls' into flags
YairSlobodin1 Oct 29, 2024
4c8cf3f
Merge branch 'flags' into output
YairSlobodin1 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions cmd/subcmds/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,39 @@ SPDX-License-Identifier: Apache-2.0

package subcmds

import "github.com/spf13/cobra"
import (
"fmt"

"github.com/spf13/cobra"

"github.com/np-guard/vpc-network-config-synthesis/pkg/ir"
"github.com/np-guard/vpc-network-config-synthesis/pkg/optimize"
)

func NewOptimizeCommand(args *inArgs) *cobra.Command {
cmd := &cobra.Command{
Use: "optimize",
Short: "Optimize is not supported yet",
Long: `Optimize is not supported yet`,
Short: "optimization of existing SG and nACLs",
Long: `optimization of existing SG and nACLs`,
}

cmd.AddCommand(NewOptimizeACLCommand(args))
// sub cmds
cmd.AddCommand(NewOptimizeSGCommand(args))
cmd.AddCommand(NewOptimizeACLCommand(args))

return cmd
}

func optimization(cmd *cobra.Command, args *inArgs, newOptimizer func(ir.Collection, string) optimize.Optimizer, isSG bool) error {
cmd.SilenceUsage = true // if we got this far, flags are syntactically correct, so no need to print usage
collection, err := parseCollection(args, isSG)
if err != nil {
return fmt.Errorf("could not parse config file %v: %w", args.configFile, err)
}
optimizer := newOptimizer(collection, args.firewallName)
optimizedCollection, err := optimizer.Optimize()
if err != nil {
return err
}
return writeOutput(args, optimizedCollection, collection.VpcNames(), false)
}
17 changes: 13 additions & 4 deletions cmd/subcmds/optimizeACL.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@ SPDX-License-Identifier: Apache-2.0

package subcmds

import "github.com/spf13/cobra"
import (
"github.com/spf13/cobra"

acloptimizer "github.com/np-guard/vpc-network-config-synthesis/pkg/optimize/acl"
)

const aclNameFlag = "acl-name"

func NewOptimizeACLCommand(args *inArgs) *cobra.Command {
cmd := &cobra.Command{
Use: "acl",
Short: "OptimizeACL is not supported yet",
Long: `OptimizeACL is not supported yet`,
Short: "OptimizeACL attempts to reduce the number of nACL rules in an nACL without changing the semantic.",
Long: `OptimizeACL attempts to reduce the number of nACL rules in an nACL without changing the semantic.`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
return nil
return optimization(cmd, args, acloptimizer.NewACLOptimizer, false)
},
}

// flags
cmd.PersistentFlags().StringVarP(&args.firewallName, aclNameFlag, "n", "", "which nacl to optimize")

return cmd
}
17 changes: 13 additions & 4 deletions cmd/subcmds/optimizeSG.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@ SPDX-License-Identifier: Apache-2.0

package subcmds

import "github.com/spf13/cobra"
import (
"github.com/spf13/cobra"

sgoptimizer "github.com/np-guard/vpc-network-config-synthesis/pkg/optimize/sg"
)

const sgNameFlag = "sg-name"

func NewOptimizeSGCommand(args *inArgs) *cobra.Command {
cmd := &cobra.Command{
Use: "sg",
Short: "OptimizeSG is not supported yet",
Long: `OptimizeSG is not supported yet`,
Short: "OptimizeSG attempts to reduce the number of security group rules in a SG without changing the semantic.",
Long: `OptimizeSG attempts to reduce the number of security group rules in a SG without changing the semantic.`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
return nil
return optimization(cmd, args, sgoptimizer.NewSGOptimizer, true)
},
}

// flags
cmd.PersistentFlags().StringVarP(&args.firewallName, sgNameFlag, "n", "", "which security group to optimize")

return cmd
}
58 changes: 24 additions & 34 deletions cmd/subcmds/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,30 @@ import (
"os"
"path/filepath"

"github.com/np-guard/vpc-network-config-synthesis/pkg/io"
"github.com/np-guard/vpc-network-config-synthesis/pkg/io/confio"
"github.com/np-guard/vpc-network-config-synthesis/pkg/io/csvio"
"github.com/np-guard/vpc-network-config-synthesis/pkg/io/mdio"
"github.com/np-guard/vpc-network-config-synthesis/pkg/io/tfio"

"github.com/np-guard/vpc-network-config-synthesis/pkg/ir"
)

const defaultFilePermission = 0o644
const defaultDirectoryPermission = 0o755

func writeOutput(args *inArgs, collection ir.Collection, vpcNames []ir.ID) error {
if err := updateOutputFormat(args); err != nil {
return err
}
if args.outputDir != "" && args.outputFmt == apiOutputFormat {
return fmt.Errorf("-d cannot be used with format json")
}
func writeOutput(args *inArgs, collection ir.Collection, vpcNames []string, isSynth bool) error {
if args.outputDir != "" { // create the directory if needed
if err := os.MkdirAll(args.outputDir, defaultDirectoryPermission); err != nil {
return err
}
}
if err := writeLocals(args, collection, vpcNames); err != nil {

if err := writeLocals(args, vpcNames, collection); err != nil {
return err
}

var data *bytes.Buffer
var err error
if args.outputDir == "" {
if data, err = writeCollection(args, collection, ""); err != nil {
if data, err = writeCollection(args, collection, "", isSynth); err != nil {
return err
}
return writeToFile(args.outputFile, data)
Expand All @@ -55,7 +48,7 @@ func writeOutput(args *inArgs, collection ir.Collection, vpcNames []ir.ID) error
if args.prefix != "" {
args.outputFile = args.outputDir + "/" + args.prefix + "_" + suffix
}
if data, err = writeCollection(args, collection, vpc); err != nil {
if data, err = writeCollection(args, collection, vpc, isSynth); err != nil {
return err
}
if err := writeToFile(args.outputFile, data); err != nil {
Expand All @@ -65,53 +58,50 @@ func writeOutput(args *inArgs, collection ir.Collection, vpcNames []ir.ID) error
return nil
}

func writeCollection(args *inArgs, collection ir.Collection, vpc string) (*bytes.Buffer, error) {
func writeCollection(args *inArgs, collection ir.Collection, vpc string, isSynth bool) (*bytes.Buffer, error) {
var data bytes.Buffer
writer, err := pickWriter(args, &data)
if err != nil {
return nil, err
}
if err := collection.Write(writer, vpc); err != nil {
if err := collection.Write(writer, vpc, isSynth); err != nil {
return nil, err
}
return &data, nil
}

func writeToFile(outputFile string, data *bytes.Buffer) error {
if outputFile == "" {
fmt.Println(data.String())
return nil
}
return os.WriteFile(outputFile, data.Bytes(), defaultFilePermission)
}

func pickWriter(args *inArgs, data *bytes.Buffer) (ir.Writer, error) {
w := bufio.NewWriter(data)
switch args.outputFmt {
case tfOutputFormat:
return tfio.NewWriter(w), nil
case csvOutputFormat:
return csvio.NewWriter(w), nil
return io.NewCSVWriter(w), nil
case mdOutputFormat:
return mdio.NewWriter(w), nil
case apiOutputFormat:
return io.NewMDWriter(w), nil
case jsonOutputFormat:
return confio.NewWriter(w, args.configFile)
default:
return nil, fmt.Errorf("bad output format: %q", args.outputFmt)
}
return nil, fmt.Errorf("bad output format: %q", args.outputFmt)
}

func writeLocals(args *inArgs, collection ir.Collection, vpcNames []ir.ID) error {
if !args.locals {
func writeToFile(outputFile string, data *bytes.Buffer) error {
if outputFile == "" {
fmt.Println(data.String())
return nil
}
if args.outputFmt != tfOutputFormat {
return fmt.Errorf("--locals flag requires setting the output format to tf")
}
return os.WriteFile(outputFile, data.Bytes(), defaultFilePermission)
}

_, isACLCollection := collection.(*ir.ACLCollection)
func writeLocals(args *inArgs, vpcNames []ir.ID, collection ir.Collection) error {
if !args.locals {
return nil
}
var data *bytes.Buffer
var err error

_, isACLCollection := collection.(*ir.ACLCollection)

if data, err = tfio.WriteLocals(vpcNames, isACLCollection); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/subcmds/outputFormat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const (
tfOutputFormat = "tf"
csvOutputFormat = "csv"
mdOutputFormat = "md"
apiOutputFormat = "json"
jsonOutputFormat = "json"
defaultOutputFormat = csvOutputFormat
)

var outputFormats = []string{tfOutputFormat, csvOutputFormat, mdOutputFormat, apiOutputFormat}
var outputFormats = []string{tfOutputFormat, csvOutputFormat, mdOutputFormat, jsonOutputFormat}

func updateOutputFormat(args *inArgs) error {
var err error
Expand All @@ -40,7 +40,7 @@ func inferFormatUsingFilename(filename string) (string, error) {
case strings.HasSuffix(filename, ".md"):
return mdOutputFormat, nil
case strings.HasSuffix(filename, ".json"):
return apiOutputFormat, nil
return jsonOutputFormat, nil
default:
return "", fmt.Errorf("bad output format")
}
Expand Down
46 changes: 27 additions & 19 deletions cmd/subcmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

const (
configFlag = "config"
specFlag = "spec"
outputFmtFlag = "format"
outputFileFlag = "output-file"
outputDirFlag = "output-dir"
Expand All @@ -24,44 +23,53 @@ const (
)

type inArgs struct {
configFile string
specFile string
outputFmt string
outputFile string
outputDir string
prefix string
singleacl bool
locals bool
configFile string
specFile string
outputFmt string
outputFile string
outputDir string
prefix string
firewallName string
singleacl bool
locals bool
}

func NewRootCommand() *cobra.Command {
args := &inArgs{}

// allow PersistentPreRunE
cobra.EnableTraverseRunHooks = true

rootCmd := &cobra.Command{
Use: "vpcgen",
Short: "Tool for automatic synthesis of VPC network configurations",
Long: `Tool for automatic synthesis of VPC network configurations, namely Network ACLs and Security Groups.`,
Short: "A tool for synthesizing and optimizing VPC network configurations",
Long: `A tool for synthesizing and optimizing VPC network configurations, namely Network ACLs and Security Groups.`,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
return validateFlags(args)
},
}

// flags
rootCmd.PersistentFlags().StringVarP(&args.configFile, configFlag, "c", "",
"JSON file containing a configuration object of existing resources")
rootCmd.PersistentFlags().StringVarP(&args.outputFmt, outputFmtFlag, "f", "", "Output format; "+mustBeOneOf(outputFormats))
rootCmd.PersistentFlags().StringVarP(&args.outputFile, outputFileFlag, "o", "", "Write all generated resources to the specified file.")
rootCmd.PersistentFlags().StringVarP(&args.outputDir, outputDirFlag, "d", "",
"Write generated resources to files in the specified directory, one file per VPC.")
rootCmd.PersistentFlags().StringVarP(&args.prefix, prefixFlag, "p", "", "The prefix of the files that will be created.")
rootCmd.PersistentFlags().BoolVarP(&args.locals, localsFlag, "l", false,
"whether to generate a locals.tf file (only possible when the output format is tf)")
rootCmd.PersistentFlags().SortFlags = false

// flags set for all commands
rootCmd.PersistentFlags().SortFlags = false
_ = rootCmd.MarkPersistentFlagRequired(configFlag)
rootCmd.MarkFlagsMutuallyExclusive(outputFileFlag, outputDirFlag)

// sub cmds
rootCmd.AddCommand(NewSynthCommand(args))
// Todo: add optimize command
rootCmd.AddCommand(NewOptimizeCommand(args))

// prevent Cobra from creating a default 'completion' command
rootCmd.CompletionOptions.DisableDefaultCmd = true

rootCmd.CompletionOptions.HiddenDefaultCmd = true
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) // disable help command. should use --help flag instead
// disable help command. should use --help flag instead
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})

return rootCmd
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/subcmds/synth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/np-guard/vpc-network-config-synthesis/pkg/utils"
)

const specFlag = "spec"

func NewSynthCommand(args *inArgs) *cobra.Command {
cmd := &cobra.Command{
Use: "synth",
Expand All @@ -21,9 +23,16 @@ func NewSynthCommand(args *inArgs) *cobra.Command {
--config and --spec parameters must be supplied.`,
}

// flags
cmd.PersistentFlags().StringVarP(&args.specFile, specFlag, "s", "", "JSON file containing spec file")
cmd.PersistentFlags().StringVarP(&args.outputDir, outputDirFlag, "d", "",
"Write generated resources to files in the specified directory, one file per VPC.")
cmd.PersistentFlags().StringVarP(&args.prefix, prefixFlag, "p", "", "The prefix of the files that will be created.")

// flags settings
_ = cmd.MarkPersistentFlagRequired(specFlag)

// sub cmds
cmd.AddCommand(NewSynthACLCommand(args))
cmd.AddCommand(NewSynthSGCommand(args))

Expand All @@ -41,5 +50,5 @@ func synthesis(cmd *cobra.Command, args *inArgs, newSynthesizer func(*ir.Spec, b
if err != nil {
return err
}
return writeOutput(args, collection, utils.MapKeys(spec.Defs.ConfigDefs.VPCs))
return writeOutput(args, collection, utils.MapKeys(spec.Defs.ConfigDefs.VPCs), true)
}
7 changes: 7 additions & 0 deletions cmd/subcmds/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ func unmarshal(args *inArgs) (*ir.Spec, error) {

return model, nil
}

func parseCollection(args *inArgs, isSG bool) (ir.Collection, error) {
if isSG {
return confio.ReadSGs(args.configFile)
}
return confio.ReadACLs(args.configFile)
}
Loading
Loading