Skip to content

Commit 22bdacf

Browse files
markfisherericbottard
authored andcommitted
1 parent e7ff1c3 commit 22bdacf

File tree

8 files changed

+50
-50
lines changed

8 files changed

+50
-50
lines changed

cmd/commands/function.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const (
3030
)
3131

3232
const (
33-
functionBuildFunctionNameIndex = iota
34-
functionBuildNumberOfArgs
33+
functionUpdateFunctionNameIndex = iota
34+
functionUpdateNumberOfArgs
3535
)
3636

3737
func Function() *cobra.Command {
@@ -123,24 +123,24 @@ func FunctionCreate(fcTool *core.Client, defaults FunctionCreateDefaults) *cobra
123123
return command
124124
}
125125

126-
func FunctionBuild(fcTool *core.Client) *cobra.Command {
126+
func FunctionUpdate(fcTool *core.Client) *cobra.Command {
127127

128-
buildFunctionOptions := core.BuildFunctionOptions{}
128+
updateFunctionOptions := core.UpdateFunctionOptions{}
129129

130130
command := &cobra.Command{
131-
Use: "build",
132-
Short: "Trigger a revision build for a function resource",
133-
Example: ` ` + env.Cli.Name + ` function build square`,
131+
Use: "update",
132+
Short: "Trigger a build to generate a new revision for a function resource",
133+
Example: ` ` + env.Cli.Name + ` function update square`,
134134
Args: ArgValidationConjunction(
135-
cobra.ExactArgs(functionBuildNumberOfArgs),
136-
AtPosition(functionBuildFunctionNameIndex, ValidName()),
135+
cobra.ExactArgs(functionUpdateNumberOfArgs),
136+
AtPosition(functionUpdateFunctionNameIndex, ValidName()),
137137
),
138138
RunE: func(cmd *cobra.Command, args []string) error {
139139

140-
fnName := args[functionBuildFunctionNameIndex]
140+
fnName := args[functionUpdateFunctionNameIndex]
141141

142-
buildFunctionOptions.Name = fnName
143-
err := (*fcTool).BuildFunction(buildFunctionOptions, cmd.OutOrStdout())
142+
updateFunctionOptions.Name = fnName
143+
err := (*fcTool).UpdateFunction(updateFunctionOptions, cmd.OutOrStdout())
144144
if err != nil {
145145
return err
146146
}
@@ -153,10 +153,10 @@ func FunctionBuild(fcTool *core.Client) *cobra.Command {
153153

154154
LabelArgs(command, "FUNCTION_NAME")
155155

156-
command.Flags().StringVarP(&buildFunctionOptions.Namespace, "namespace", "n", "", "the `namespace` of the function")
157-
command.Flags().StringVarP(&buildFunctionOptions.LocalPath, "local-path", "l", "", "path to local source to build the image from; only build-pack builds are supported at this time")
158-
command.Flags().BoolVarP(&buildFunctionOptions.Verbose, "verbose", "v", false, verboseUsage)
159-
command.Flags().BoolVarP(&buildFunctionOptions.Wait, "wait", "w", false, waitUsage)
156+
command.Flags().StringVarP(&updateFunctionOptions.Namespace, "namespace", "n", "", "the `namespace` of the function")
157+
command.Flags().StringVarP(&updateFunctionOptions.LocalPath, "local-path", "l", "", "path to local source to build the image from; only build-pack builds are supported at this time")
158+
command.Flags().BoolVarP(&updateFunctionOptions.Verbose, "verbose", "v", false, verboseUsage)
159+
command.Flags().BoolVarP(&updateFunctionOptions.Wait, "wait", "w", false, waitUsage)
160160

161161
return command
162162
}

cmd/commands/function_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,23 @@ status: {}
241241
---
242242
`
243243

244-
var _ = Describe("The riff function build command", func() {
244+
var _ = Describe("The riff function update command", func() {
245245
Context("when given wrong args or flags", func() {
246246
var (
247247
mockClient core.Client
248248
fc *cobra.Command
249249
)
250250
BeforeEach(func() {
251251
mockClient = nil
252-
fc = commands.FunctionBuild(&mockClient)
252+
fc = commands.FunctionUpdate(&mockClient)
253253
})
254254
It("should fail with no args", func() {
255255
fc.SetArgs([]string{})
256256
err := fc.Execute()
257257
Expect(err).To(MatchError("accepts 1 arg(s), received 0"))
258258
})
259259
It("should fail with invalid function name", func() {
260-
//fc = commands.FunctionBuild(&mockClient)
260+
//fc = commands.FunctionUpdate(&mockClient)
261261
fc.SetArgs([]string{"invålid"})
262262
err := fc.Execute()
263263
Expect(err).To(MatchError(ContainSubstring("must start and end with an alphanumeric character")))
@@ -274,7 +274,7 @@ var _ = Describe("The riff function build command", func() {
274274
client = new(mocks.Client)
275275
asMock = client.(*mocks.Client)
276276

277-
fc = commands.FunctionBuild(&client)
277+
fc = commands.FunctionUpdate(&client)
278278
})
279279
AfterEach(func() {
280280
asMock.AssertExpectations(GinkgoT())
@@ -283,19 +283,19 @@ var _ = Describe("The riff function build command", func() {
283283
It("should involve the core.Client", func() {
284284
fc.SetArgs([]string{"square", "--namespace", "ns"})
285285

286-
o := core.BuildFunctionOptions{}
286+
o := core.UpdateFunctionOptions{}
287287
o.Name = "square"
288288
o.Namespace = "ns"
289289

290-
asMock.On("BuildFunction", o, mock.Anything).Return(nil)
290+
asMock.On("UpdateFunction", o, mock.Anything).Return(nil)
291291
err := fc.Execute()
292292
Expect(err).NotTo(HaveOccurred())
293293
})
294294
It("should propagate core.Client errors", func() {
295295
fc.SetArgs([]string{"square", "--namespace", "ns"})
296296

297297
e := fmt.Errorf("some error")
298-
asMock.On("BuildFunction", mock.Anything, mock.Anything).Return(e)
298+
asMock.On("UpdateFunction", mock.Anything, mock.Anything).Return(e)
299299
err := fc.Execute()
300300
Expect(err).To(MatchError(e))
301301
})

cmd/commands/wiring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ See https://projectriff.io and https://github.com/knative/docs`,
102102
installKubeConfigSupport(function, &client, &kc)
103103
function.AddCommand(
104104
FunctionCreate(&client, FunctionCreateDefaults{LocalBuilder: localBuilder, DefaultRunImage: defaultRunImage}),
105-
FunctionBuild(&client),
105+
FunctionUpdate(&client),
106106
)
107107

108108
service := Service()

docs/riff_function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ Interact with function related resources
1717
### SEE ALSO
1818

1919
* [riff](riff.md) - Commands for creating and managing function resources
20-
* [riff function build](riff_function_build.md) - Trigger a revision build for a function resource
2120
* [riff function create](riff_function_create.md) - Create a new function resource
21+
* [riff function update](riff_function_update.md) - Trigger a build to generate a new revision for a function resource
2222

docs/riff_function_build.md renamed to docs/riff_function_update.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
## riff function build
1+
## riff function update
22

3-
Trigger a revision build for a function resource
3+
Trigger a build to generate a new revision for a function resource
44

55
### Synopsis
66

7-
Trigger a revision build for a function resource
7+
Trigger a build to generate a new revision for a function resource
88

99
```
10-
riff function build [flags]
10+
riff function update [flags]
1111
```
1212

1313
### Examples
1414

1515
```
16-
riff function build square
16+
riff function update square
1717
```
1818

1919
### Options
2020

2121
```
22-
-h, --help help for build
22+
-h, --help help for update
2323
-l, --local-path string path to local source to build the image from; only build-pack builds are supported at this time
2424
-n, --namespace namespace the namespace of the function
2525
-v, --verbose print details of command progress

pkg/core/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
type Client interface {
3333
CreateFunction(options CreateFunctionOptions, log io.Writer) (*serving.Service, error)
34-
BuildFunction(options BuildFunctionOptions, log io.Writer) error
34+
UpdateFunction(options UpdateFunctionOptions, log io.Writer) error
3535

3636
CreateSubscription(options CreateSubscriptionOptions) (*eventing.Subscription, error)
3737
DeleteSubscription(options DeleteSubscriptionOptions) error

pkg/core/function.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (selectorDisjunction) String() string {
484484
panic("implement me")
485485
}
486486

487-
type BuildFunctionOptions struct {
487+
type UpdateFunctionOptions struct {
488488
Namespace string
489489
Name string
490490
LocalPath string
@@ -500,7 +500,7 @@ func (c *client) getServiceSpecGeneration(namespace string, name string) (int64,
500500
return s.Spec.Generation, nil
501501
}
502502

503-
func (c *client) BuildFunction(options BuildFunctionOptions, log io.Writer) error {
503+
func (c *client) UpdateFunction(options UpdateFunctionOptions, log io.Writer) error {
504504
ns := c.explicitOrConfigNamespace(options.Namespace)
505505

506506
service, err := c.service(options.Namespace, options.Name)
@@ -525,7 +525,7 @@ func (c *client) BuildFunction(options BuildFunctionOptions, log io.Writer) erro
525525
c.bumpNonceAnnotation(service)
526526

527527
if build == nil {
528-
// function was build locally, attempt to reconstruct configuration
528+
// function was built locally, attempt to reconstruct configuration
529529
appDir := options.LocalPath
530530
buildImage := annotations[buildpackBuildImageAnnotation]
531531
runImage := annotations[buildpackRunImageAnnotation]
@@ -559,7 +559,7 @@ func (c *client) BuildFunction(options BuildFunctionOptions, log io.Writer) erro
559559
)
560560
for i := 0; i < 10; i++ {
561561
if i >= 10 {
562-
return fmt.Errorf("build unsuccesful for \"%s\", service resource was never updated", options.Name)
562+
return fmt.Errorf("update unsuccesful for \"%s\", service resource was never updated", options.Name)
563563
}
564564
time.Sleep(500 * time.Millisecond)
565565
nextGen, err = c.getServiceSpecGeneration(options.Namespace, options.Name)

pkg/core/mocks/Client.go

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)