Skip to content

Commit

Permalink
polycubectl: remove hardcoded version logic (polycube-network#136)
Browse files Browse the repository at this point in the history
Some time ago we had two kind of services, so the cli has to be aware of that.
The last service to be updated is pcn-bridge, so now all services are aligned.

We don't expect to handle this case in the future, so remove this logic.

Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>
  • Loading branch information
mauriciovasquezbernal authored and richiMarchi committed Jun 4, 2019
1 parent dc00c3d commit da23b03
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 101 deletions.
6 changes: 1 addition & 5 deletions src/polycubectl/cliargs/cliargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,7 @@ func (cli *CLIArgs) getRequestMethod() string {
} else if cli.Command == AddCommand || cli.Command == "" {
return httprequest.PostStr
} else if cli.Command == SetCommand {
if config.GetConfig().Version == "1" {
return httprequest.PutStr
} else {
return httprequest.PatchStr
}
return httprequest.PatchStr
} else if cli.Command == ShowCommand {
return httprequest.GetStr
} else if cli.Command == DelCommand {
Expand Down
14 changes: 0 additions & 14 deletions src/polycubectl/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ type Config struct {
Debug bool `yaml:"debug"`
Expert bool `yaml:"expert"`
Url string `yaml:"url"`
Version string `yaml:"version"`
// get version to be used according to service name
HardCodedVersionEnabled bool
// enables Workaround for urls (e.g. set peer=veth1 PUT /peer/ "veth1")
SingleParameterWorkaround bool

Expand All @@ -58,8 +55,6 @@ func NewDefaultConfig() Config {
Debug: false,
Expert: true,
Url: "http://localhost:9000/polycube/v1/",
Version: "2",
HardCodedVersionEnabled: true,
SingleParameterWorkaround: true,
}

Expand All @@ -78,7 +73,6 @@ func saveConfig(config Config) error {
`# debug: shows http method/url and body of the response
# expert: enables the possibility to add new services
# url: is the base url to contact the rest server
# version: (1) uses PUT method, (2) uses PATCH method
# cacert: path to certification authority certificate to validate polycubed identity
# cert: path to certificate to present to polycubed for validate polycubectl identity
# key: path to private key for polycubectl
Expand Down Expand Up @@ -131,10 +125,6 @@ func LoadConfig() (error) {
return fmt.Errorf("error decoding config file: %s", err.Error())
}

if config.Version != "" && config.Version != "1" && config.Version != "2" {
return fmt.Errorf("%s if not a valid version, please check the config file. %s", config.Version)
}

if os.Getenv("POLYCUBECTL_URL") != "" {
config.Url = os.Getenv("POLYCUBECTL_URL")
}
Expand All @@ -153,10 +143,6 @@ func LoadConfig() (error) {
}
}

if os.Getenv("POLYCUBECTL_VERSION") != "" {
config.Version = os.Getenv("POLYCUBECTL_VERSION")
}

if os.Getenv("POLYCUBECTL_CACERT") != "" {
config.CACert = os.Getenv("POLYCUBECTL_CACERT")
}
Expand Down
75 changes: 0 additions & 75 deletions src/polycubectl/hardcodedversion.go

This file was deleted.

7 changes: 0 additions & 7 deletions src/polycubectl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ func main() {
os.Exit(1)
}

if config.GetConfig().HardCodedVersionEnabled {
v := GetHardCodedVersion(os.Args[1:])
if v != "" {
config.GetConfig().Version = v
}
}

LogCommand(os.Args)

cliArgs, err := cliargs.ParseCLIArgs(os.Args[1:])
Expand Down

0 comments on commit da23b03

Please sign in to comment.