Skip to content

Commit

Permalink
Bool flag using convention. Tweak usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
sixolet committed Aug 16, 2019
1 parent 2d17981 commit 4506014
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ kn service update NAME [flags]
-l, --label stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-).
--limits-cpu string The limits on the requested CPU (e.g., 1000m).
--limits-memory string The limits on the requested memory (e.g., 1024Mi).
--lock-to-digest When not updating the image field, make sure the image we're running doesn't change by locking it to the currently-running image digest. (default true)
--max-scale int Maximal number of replicas.
--min-scale int Minimal number of replicas.
-n, --namespace string List the requested object(s) in given namespace.
--no-lock-to-digest do not set the image to the latest revision's image digest. If you specify --image, the image will always be set to the provided value, regardless.
-p, --port int32 The port where application listens on.
--requests-cpu string The requested CPU (e.g., 250m).
--requests-memory string The requested memory (e.g., 64Mi).
Expand Down
9 changes: 4 additions & 5 deletions pkg/kn/commands/service/configuration_edit_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"knative.dev/client/pkg/kn/flags"
servinglib "knative.dev/client/pkg/serving"
util "knative.dev/client/pkg/util"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
Expand Down Expand Up @@ -107,11 +108,9 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) {
// AddUpdateFlags adds the flags specific to update.
func (p *ConfigurationEditFlags) AddUpdateFlags(command *cobra.Command) {
p.addSharedFlags(command)
command.Flags().BoolVar(&p.LockToDigest, "lock-to-digest", true,
"When not updating the image field, make sure the image we're running doesn't "+
"change by locking it to the currently-running image digest.")
// Don't add it to p.flags, it doesn't affect anything on its own.

flags.AddBothBoolFlags(command.Flags(), &p.LockToDigest, "lock-to-digest", "", true,
"set the image to the latest revision's image digest. If you specify --image, the image will always be set to the provided value, regardless.")
// Don't mark as changing the revision.
}

// AddCreateFlags adds the flags specific to create
Expand Down
7 changes: 4 additions & 3 deletions pkg/kn/commands/service/service_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ import (
"knative.dev/serving/pkg/apis/serving/v1alpha1"
)

var exampleImageByDigest string = "gcr.io/foo/bar@sha256:deadbeefdeadbeef"
var exampleRevisionName string = "foo-asdf"
var exampleRevisionName2 string = "foo-xyzzy"
var exampleImageByDigest = "gcr.io/foo/bar@sha256:deadbeefdeadbeef"
var exampleRevisionName = "foo-asdf"
var exampleRevisionName2 = "foo-xyzzy"

func fakeServiceUpdate(original *v1alpha1.Service, args []string, sync bool) (
action client_testing.Action,
Expand Down Expand Up @@ -357,6 +357,7 @@ func TestServiceUpdateEnv(t *testing.T) {

template, err = servinglib.RevisionTemplateOfService(updated)
assert.NilError(t, err)
// Test that we pinned to digest
assert.Equal(t, template.Spec.Containers[0].Image, exampleImageByDigest)
assert.Equal(t, template.Spec.Containers[0].Env[0], expectedEnvVar)
}
Expand Down

0 comments on commit 4506014

Please sign in to comment.