Skip to content

Commit 630b8fa

Browse files
gradutateo
authored andcommitted
[OCTRL-209] Add cases for rest of conf commands on no-version
1 parent 4b8bced commit 630b8fa

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

coconut/cmd/configuration_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var configurationListCmd = &cobra.Command{
3434
Aliases: []string{"l", "ls"},
3535
Example: `coconut conf list
3636
coconut conf list <component>
37-
coconut conf list <component> -t <timestamp>`,
37+
coconut conf list <component> -t`,
3838
Short: "List all existing O² components in Consul",
3939
Long: `The configuration list command requests all components
4040
from O² Configuration as a list and displays it on the standard output`,

coconut/configuration/configuration.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ func Show(cfg *configuration.ConsulSource, cmd *cobra.Command, args []string, o
239239
return err, emptyData
240240
}
241241
}
242-
key = componentcfg.ConfigComponentsPath + component + "/" + entry + "/" + timestamp
242+
key = componentcfg.ConfigComponentsPath + component + "/" + entry
243+
if timestamp != "0" {
244+
//versioned entry
245+
key += "/" + timestamp
246+
}
243247
cfgPayload, err = cfg.Get(key)
244248
if err != nil {
245249
return err, connectionError

coconut/configuration/configurationutil.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* === This file is part of ALICE O² ===
33
*
4-
* Copyright 2019 CERN and copyright holders of ALICE O².
4+
* Copyright 2020 CERN and copyright holders of ALICE O².
55
* Author: George Raduta <george.raduta@cern.ch>
66
*
77
* This program is free software: you can redistribute it and/or modify
@@ -74,6 +74,10 @@ func getListOfComponentsAndOrWithTimestamps(keys []string, keyPrefix string, use
7474
componentsFullName := strings.TrimPrefix(key, keyPrefix)
7575
componentParts := strings.Split(componentsFullName, "/")
7676
componentTimestamp := componentParts[len(componentParts) - 1]
77+
78+
if len(componentParts) == 1 {
79+
componentTimestamp = "unversioned"
80+
}
7781
if useTimestamp {
7882
componentsFullName = strings.TrimSuffix(componentsFullName, "/" +componentTimestamp)
7983
} else {
@@ -110,6 +114,9 @@ func drawTableHistoryConfigs(headers []string, history []string, max int, o io.W
110114
if err != nil {
111115
prettyTimestamp = timestamp
112116
}
117+
if prettyTimestamp == "unversioned" {
118+
prettyTimestamp = red(prettyTimestamp)
119+
}
113120
configName := red(component) + "/" + blue(entry) + "@" + timestamp
114121
table.Append([]string{configName, prettyTimestamp})
115122
}

configuration/componentcfg/componentcfg.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ func GetComponentEntryTimestampFromConsul(key string)(string, string, string) {
8686
key = strings.TrimPrefix(key, "/'")
8787
key = strings.TrimSuffix(key, "/")
8888
elements := strings.Split(key, "/")
89-
return elements[0], elements[1], elements[2]
89+
if len(elements) == 3 {
90+
return elements[0], elements[1], elements[2]
91+
} else {
92+
return elements[0], elements[1], "unversioned"
93+
}
9094
}
9195

9296

0 commit comments

Comments
 (0)