Skip to content

Commit 45f90e1

Browse files
committed
fix indent
1 parent 195fb21 commit 45f90e1

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

go/fn/examples/example_asmain_runner_test.go

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,31 +14,31 @@
1414
package example
1515

1616
import (
17-
"os"
17+
"os"
1818

19-
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
19+
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
2020
)
2121

2222
var _ fn.Runner = &SetLabels{}
2323

2424
type SetLabels struct {
25-
Labels map[string]string `json:"labels,omitempty"`
25+
Labels map[string]string `json:"labels,omitempty"`
2626
}
2727

2828
// Run is the main function logic.
2929
// `ctx` provides easy methods to add info, error or warning result to `ResourceList.Results`.
3030
// `items` is parsed from the STDIN "ResourceList.Items".
3131
// `functionConfig` is from the STDIN "ResourceList.FunctionConfig". The value has been assigned to the r.Labels
3232
//
33-
// the functionConfig is validated to have kind "SetLabels" and apiVersion "fn.kpt.dev/v1alpha1"
33+
// the functionConfig is validated to have kind "SetLabels" and apiVersion "fn.kpt.dev/v1alpha1"
3434
func (r *SetLabels) Run(_ *fn.Context, _ *fn.KubeObject, items fn.KubeObjects, results *fn.Results) bool {
35-
for _, o := range items {
36-
for k, newLabel := range r.Labels {
37-
o.SetLabel(k, newLabel)
38-
}
39-
}
40-
results.Infof("updated labels")
41-
return true
35+
for _, o := range items {
36+
for k, newLabel := range r.Labels {
37+
o.SetLabel(k, newLabel)
38+
}
39+
}
40+
results.Infof("updated labels")
41+
return true
4242
}
4343

4444
// This example uses a SetLabels object, which implements `Runner.Run` methods.
@@ -50,36 +50,35 @@ func (r *SetLabels) Run(_ *fn.Context, _ *fn.KubeObject, items fn.KubeObjects, r
5050
// - apiVersion: v1
5151
// kind: Service
5252
// metadata:
53-
// name: example
53+
// name: example
5454
//
5555
// functionConfig:
56-
//
57-
// apiVersion: fn.kpt.dev/v1alpha1
58-
// kind: SetLabels
59-
// metadata:
60-
// name: setlabel-fn-config
56+
// apiVersion: fn.kpt.dev/v1alpha1
57+
// kind: SetLabels
58+
// metadata:
59+
// name: setlabel-fn-config
6160
func Example_asMain() {
62-
file, _ := os.Open("./data/setlabels-resourcelist.yaml")
63-
defer file.Close()
64-
os.Stdin = file
61+
file, _ := os.Open("./data/setlabels-resourcelist.yaml")
62+
defer file.Close()
63+
os.Stdin = file
6564

66-
if err := fn.AsMain(&SetLabels{}); err != nil {
67-
os.Exit(1)
68-
}
69-
// Output:
70-
// apiVersion: config.kubernetes.io/v1
71-
// kind: ResourceList
72-
// items:
73-
// - apiVersion: v1
74-
// kind: Service
75-
// metadata:
76-
// name: example
77-
// functionConfig:
78-
// apiVersion: fn.kpt.dev/v1alpha1
79-
// kind: SetLabels
80-
// metadata:
81-
// name: setlabel-fn-config
82-
// results:
83-
// - message: updated labels
84-
// severity: info
65+
if err := fn.AsMain(&SetLabels{}); err != nil {
66+
os.Exit(1)
67+
}
68+
// Output:
69+
// apiVersion: config.kubernetes.io/v1
70+
// kind: ResourceList
71+
// items:
72+
// - apiVersion: v1
73+
// kind: Service
74+
// metadata:
75+
// name: example
76+
// functionConfig:
77+
// apiVersion: fn.kpt.dev/v1alpha1
78+
// kind: SetLabels
79+
// metadata:
80+
// name: setlabel-fn-config
81+
// results:
82+
// - message: updated labels
83+
// severity: info
8584
}

0 commit comments

Comments
 (0)