Skip to content

Commit c4810dc

Browse files
authored
#1 - check command and metadata are useless (#2)
* #1 - check command and metadata are useless * #1 - check command and metadata are useless
1 parent 10dcade commit c4810dc

File tree

8 files changed

+7
-60
lines changed

8 files changed

+7
-60
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ resources:
3434
3535
### `check`: Produce a single dummy key
3636

37-
The resource uses the `version` identifier of the resource as a way to pass the data between jobs.
38-
Check returns a single `dummy` key that will be discarded and only used to satisfy the `check` behavior.
37+
This is a version-less resource so `check` behavior is no-op
3938

4039
### `in`: Report the given time.
4140

4241
Fetches the given key values and stores them in the `keyval.properties` file.
4342
The format is of a `.properties` file, e.g. `"<key>=<value>"`.
44-
Key values are also reported as the metadata.
4543

4644
#### Parameters
4745

@@ -60,7 +58,6 @@ Reads the given properties file and sets them for the next job.
6058
#### Parameters
6159
- file - the properties file to read the key values from
6260

63-
6461
## Examples
6562

6663
```YAML
@@ -78,8 +75,6 @@ jobs:
7875
7976
- name: build
8077
plan:
81-
- aggregate:
82-
- get: keyval
8378
- task: build
8479
file: tools/tasks/build/task.yml
8580
- put: keyval
@@ -96,7 +91,7 @@ jobs:
9691
file: tools/tasks/task.yml
9792
```
9893

99-
The build job gets an empty file in `keyval/keyval.properties`. It then writes all the key values it needs to pass along (e.g. artifact id) in the `keyvalout/keyval.properties` file.
94+
The build job writes all the key values it needs to pass along (e.g. artifact id) in the `keyvalout/keyval.properties` file.
10095
The test-deploy can read the data from the `keyval/keyval.properties` file and use them as it pleases.
10196

10297
## CI suggestions

check/check_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,20 @@ var _ = Describe("Check", func() {
5454
})
5555

5656
Context("when no version is given", func() {
57-
It("outputs an empty version", func() {
58-
Expect(response).To(HaveLen(1))
59-
Expect(response[0].Dummy).To(Equal("dummy"))
57+
It("outputs an empty version array", func() {
58+
Expect(response).To(HaveLen(0))
6059
})
6160
})
6261

6362
Context("when version is given", func() {
6463

6564
BeforeEach(func() {
6665
version = &models.EmptyVersion{
67-
Dummy: "dummy",
6866
}
6967
})
7068

71-
It("outputs an empty version", func() {
72-
Expect(response).To(HaveLen(1))
73-
Expect(response[0].Dummy).To(Equal("dummy"))
69+
It("outputs an empty version array", func() {
70+
Expect(response).To(HaveLen(0))
7471
})
7572
})
7673

check/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@ func main() {
1616
os.Exit(1)
1717
}
1818
versions := []models.EmptyVersion{}
19-
versions = append(versions, models.EmptyVersion{
20-
Dummy: "dummy",
21-
})
2219
json.NewEncoder(os.Stdout).Encode(versions)
2320
}

in/in_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ var _ = Describe("In", func() {
4747
Version: models.Version{
4848
"a": "1",
4949
"b": "2",
50-
"dummy": "dummy",
5150
},
5251
Source: models.Source{},
5352
}
@@ -72,16 +71,10 @@ var _ = Describe("In", func() {
7271
Expect(err).NotTo(HaveOccurred())
7372
})
7473

75-
It("reports the version and metadata to be the input version", func() {
74+
It("reports the version to be the input version", func() {
7675
Expect(len(response.Version)).To(Equal(2))
7776
Expect(response.Version["a"]).To(Equal("1"))
7877
Expect(response.Version["b"]).To(Equal("2"))
79-
80-
Expect(len(response.Metadata)).To(Equal(2))
81-
Expect(response.Metadata[0].Name).To(Equal("a"))
82-
Expect(response.Metadata[0].Value).To(Equal("1"))
83-
Expect(response.Metadata[1].Name).To(Equal("b"))
84-
Expect(response.Metadata[1].Value).To(Equal("2"))
8578
})
8679

8780
It("writes the requested data the destination", func() {
@@ -100,7 +93,6 @@ var _ = Describe("In", func() {
10093

10194
It("reports empty data", func() {
10295
Expect(len(response.Version)).To(Equal(0))
103-
Expect(len(response.Metadata)).To(Equal(0))
10496
var data = properties.MustLoadFile(filepath.Join(destination, "keyval.properties"),properties.UTF8).Map();
10597
Expect(len(data)).To(Equal(0))
10698
})

in/main.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ func main() {
3939
}
4040

4141
var inVersion = request.Version
42-
var metadata = models.Metadata{}
4342

4443
w := bufio.NewWriter(file)
4544

46-
delete(inVersion,"dummy")
47-
4845
var keys []string
4946
for k := range inVersion {
5047
keys = append(keys, k)
@@ -53,10 +50,6 @@ func main() {
5350

5451
for _, k := range keys {
5552
fmt.Fprintf(w, "%s=%s\n", k, inVersion[k])
56-
metadata = append(metadata, models.MetadataField{
57-
Name: k,
58-
Value: inVersion[k],
59-
})
6053
}
6154

6255
err = w.Flush()
@@ -67,7 +60,6 @@ func main() {
6760

6861
json.NewEncoder(os.Stdout).Encode(models.InResponse{
6962
Version: inVersion,
70-
Metadata: metadata,
7163
})
7264
}
7365

models/models.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package models
22

33
type EmptyVersion struct {
4-
Dummy string `json:"dummy"`
54
}
65

76
type Version map[string]string
@@ -13,7 +12,6 @@ type InRequest struct {
1312

1413
type InResponse struct {
1514
Version Version `json:"version"`
16-
Metadata Metadata `json:"metadata"`
1715
}
1816

1917
type OutParams struct {
@@ -27,7 +25,6 @@ type OutRequest struct {
2725

2826
type OutResponse struct {
2927
Version Version `json:"version"`
30-
Metadata Metadata `json:"metadata"`
3128
}
3229

3330
type CheckRequest struct {
@@ -39,9 +36,3 @@ type CheckResponse []EmptyVersion
3936

4037
type Source struct {}
4138

42-
type Metadata []MetadataField
43-
44-
type MetadataField struct {
45-
Name string `json:"name"`
46-
Value string `json:"value"`
47-
}

out/main.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,8 @@ func main() {
3333
}
3434
sort.Strings(keys)
3535

36-
var metadata = models.Metadata{}
37-
38-
for _, k := range keys {
39-
metadata = append(metadata, models.MetadataField{
40-
Name: k,
41-
Value: data[k],
42-
})
43-
}
44-
4536
json.NewEncoder(os.Stdout).Encode(models.OutResponse{
4637
Version: data,
47-
Metadata: metadata,
4838
})
4939
} else {
5040
println("no properties file specified")

out/out_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ var _ = Describe("Out", func() {
8686
Expect(len(response.Version)).To(Equal(2))
8787
Expect(response.Version["a"]).To(Equal("1"))
8888
Expect(response.Version["b"]).To(Equal("2"))
89-
90-
Expect(len(response.Metadata)).To(Equal(2))
91-
Expect(response.Metadata[0].Name).To(Equal("a"))
92-
Expect(response.Metadata[0].Value).To(Equal("1"))
93-
Expect(response.Metadata[1].Name).To(Equal("b"))
94-
Expect(response.Metadata[1].Value).To(Equal("2"))
9589
})
9690
})
9791

@@ -110,7 +104,6 @@ var _ = Describe("Out", func() {
110104

111105
It("reports empty data", func() {
112106
Expect(len(response.Version)).To(Equal(0))
113-
Expect(len(response.Metadata)).To(Equal(0))
114107
})
115108
})
116109

0 commit comments

Comments
 (0)