Skip to content

Commit 724f17a

Browse files
committed
Merge branch 'main' into mcobbett-generated-project-builds-test-catalogs
2 parents 71e16ae + eb42dd6 commit 724f17a

File tree

3 files changed

+79
-11
lines changed

3 files changed

+79
-11
lines changed

pkg/cmd/runsSubmitLocal.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (cmd *RunsSubmitLocalCommand) executeSubmitLocal(
228228
)
229229

230230
if err == nil {
231-
reportOnExpandedImages(expander, console)
231+
reportOnExpandedImages(expander)
232232
}
233233
}
234234
}
@@ -239,7 +239,7 @@ func (cmd *RunsSubmitLocalCommand) executeSubmitLocal(
239239
return err
240240
}
241241

242-
func reportOnExpandedImages(expander images.ImageExpander, console utils.Console) error {
242+
func reportOnExpandedImages(expander images.ImageExpander) error {
243243

244244
// Write out a status string to the console about how many files were rendered.
245245
count := expander.GetExpandedImageFileCount()

pkg/launcher/remoteLauncher.go

+21-9
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,37 @@ func (launcher *RemoteLauncher) GetStreams() ([]string, error) {
114114

115115
var restApiVersion string
116116
var err error
117-
var cpsProperty *galasaapi.CpsProperty
118117

119118
restApiVersion, err = embedded.GetGalasactlRestApiVersion()
120119

121120
if err == nil {
122-
123-
cpsProperty, _, err = launcher.apiClient.ConfigurationPropertyStoreAPIApi.
124-
GetCpsNamespaceCascadeProperty(nil, "framework", "test", "streams").ClientApiVersion(restApiVersion).Execute()
121+
var properties []galasaapi.GalasaProperty
122+
properties, _, err = launcher.apiClient.ConfigurationPropertyStoreAPIApi.
123+
QueryCpsNamespaceProperties(nil, "framework").Prefix("test.stream").Suffix("repo").ClientApiVersion(restApiVersion).Execute()
125124
if err == nil {
126-
if cpsProperty == nil || cpsProperty.Value == nil {
127-
streams = make([]string, 0)
128-
} else {
129-
streams = strings.Split(*cpsProperty.Value, ",")
130-
}
125+
126+
streams, err = getStreamNamesFromProperties(properties)
131127
}
132128
}
133129
return streams, err
134130
}
135131

132+
// When passed an array of GalasaProperty objects, extract the stream names from them.
133+
func getStreamNamesFromProperties(properties []galasaapi.GalasaProperty) ([]string, error) {
134+
var err error
135+
var streams []string = make([]string,0)
136+
for _, property := range properties {
137+
propertyNamePtr := property.GetMetadata().Name
138+
139+
propertyName := *propertyNamePtr
140+
// This is something like "test.stream.zosk8s.repo"
141+
142+
streamName := propertyName[12 : len(propertyName)-5]
143+
streams = append(streams, streamName)
144+
}
145+
return streams, err
146+
}
147+
136148
func (launcher *RemoteLauncher) GetTestCatalog(stream string) (TestCatalog, error) {
137149

138150
var err error = nil

pkg/launcher/remoteLauncher_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright contributors to the Galasa project
3+
*
4+
* SPDX-License-Identifier: EPL-2.0
5+
*/
6+
package launcher
7+
8+
import (
9+
"testing"
10+
11+
"github.com/galasa-dev/cli/pkg/galasaapi"
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func TestProcessingGoodPropertiesExtractsStreamsOk(t *testing.T) {
16+
17+
var inputProperties []galasaapi.GalasaProperty = make([]galasaapi.GalasaProperty, 0)
18+
19+
name1 := "thames"
20+
name1full := "test.stream." + name1 + ".repo"
21+
name2 := "avon"
22+
name2full := "test.stream." + name2 + ".repo"
23+
24+
inputProperties = append(inputProperties, galasaapi.GalasaProperty{
25+
Metadata: &galasaapi.GalasaPropertyMetadata{
26+
Name: &name1full,
27+
},
28+
})
29+
30+
inputProperties = append(inputProperties, galasaapi.GalasaProperty{
31+
Metadata: &galasaapi.GalasaPropertyMetadata{
32+
Name: &name2full,
33+
},
34+
})
35+
36+
streams, err := getStreamNamesFromProperties(inputProperties)
37+
assert.Nil(t, err)
38+
assert.NotNil(t, streams)
39+
assert.Equal(t, 2, len(streams))
40+
41+
assert.Equal(t, streams[0], name1)
42+
assert.Equal(t, streams[1], name2)
43+
}
44+
45+
func TestProcessingEmptyPropertiesListExtractsZeroStreamsOk(t *testing.T) {
46+
47+
var inputProperties []galasaapi.GalasaProperty = make([]galasaapi.GalasaProperty, 0)
48+
49+
streams, err := getStreamNamesFromProperties(inputProperties)
50+
51+
assert.Nil(t, err)
52+
assert.NotNil(t, streams)
53+
assert.Equal(t, 0, len(streams))
54+
}
55+
56+

0 commit comments

Comments
 (0)