Skip to content

Commit 7942977

Browse files
mauriciovasquezbernalacloudiator
authored andcommitted
polycubectl: remove hardcoded version logic (#136)
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>
1 parent ead77a8 commit 7942977

4 files changed

Lines changed: 1 addition & 101 deletions

File tree

src/polycubectl/cliargs/cliargs.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,7 @@ func (cli *CLIArgs) getRequestMethod() string {
404404
} else if cli.Command == AddCommand || cli.Command == "" {
405405
return httprequest.PostStr
406406
} else if cli.Command == SetCommand {
407-
if config.GetConfig().Version == "1" {
408-
return httprequest.PutStr
409-
} else {
410-
return httprequest.PatchStr
411-
}
407+
return httprequest.PatchStr
412408
} else if cli.Command == ShowCommand {
413409
return httprequest.GetStr
414410
} else if cli.Command == DelCommand {

src/polycubectl/config/config.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ type Config struct {
3838
Debug bool `yaml:"debug"`
3939
Expert bool `yaml:"expert"`
4040
Url string `yaml:"url"`
41-
Version string `yaml:"version"`
42-
// get version to be used according to service name
43-
HardCodedVersionEnabled bool
4441
// enables Workaround for urls (e.g. set peer=veth1 PUT /peer/ "veth1")
4542
SingleParameterWorkaround bool
4643

@@ -58,8 +55,6 @@ func NewDefaultConfig() Config {
5855
Debug: false,
5956
Expert: true,
6057
Url: "http://localhost:9000/polycube/v1/",
61-
Version: "2",
62-
HardCodedVersionEnabled: true,
6358
SingleParameterWorkaround: true,
6459
}
6560

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

134-
if config.Version != "" && config.Version != "1" && config.Version != "2" {
135-
return fmt.Errorf("%s if not a valid version, please check the config file. %s", config.Version)
136-
}
137-
138128
if os.Getenv("POLYCUBECTL_URL") != "" {
139129
config.Url = os.Getenv("POLYCUBECTL_URL")
140130
}
@@ -153,10 +143,6 @@ func LoadConfig() (error) {
153143
}
154144
}
155145

156-
if os.Getenv("POLYCUBECTL_VERSION") != "" {
157-
config.Version = os.Getenv("POLYCUBECTL_VERSION")
158-
}
159-
160146
if os.Getenv("POLYCUBECTL_CACERT") != "" {
161147
config.CACert = os.Getenv("POLYCUBECTL_CACERT")
162148
}

src/polycubectl/hardcodedversion.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/polycubectl/main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ func main() {
4949
os.Exit(1)
5050
}
5151

52-
if config.GetConfig().HardCodedVersionEnabled {
53-
v := GetHardCodedVersion(os.Args[1:])
54-
if v != "" {
55-
config.GetConfig().Version = v
56-
}
57-
}
58-
5952
LogCommand(os.Args)
6053

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

0 commit comments

Comments
 (0)