Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sixolet committed Aug 20, 2019
1 parent f32ddd3 commit fc03daf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions pkg/serving/config_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func UpdateConcurrencyTarget(template *servingv1alpha1.RevisionTemplateSpec, tar
// TODO(toVersus): Remove the following validation once serving library is updated to v0.8.0
// and just rely on ValidateAnnotations method.
if target < autoscaling.TargetMin {
return fmt.Errorf("Invalid 'concurrency-target' value: must be an integer greater than 0: %s",
return fmt.Errorf("invalid 'concurrency-target' value: must be an integer greater than 0: %s",
autoscaling.TargetAnnotationKey)
}

Expand All @@ -70,7 +70,7 @@ func UpdateConcurrencyLimit(template *servingv1alpha1.RevisionTemplateSpec, limi
// Validate input limit
ctx := context.Background()
if err := cc.Validate(ctx).ViaField("spec.containerConcurrency"); err != nil {
return fmt.Errorf("Invalid 'concurrency-limit' value: %s", err)
return fmt.Errorf("invalid 'concurrency-limit' value: %s", err)
}
template.Spec.ContainerConcurrency = cc
return nil
Expand Down Expand Up @@ -138,14 +138,15 @@ func UpdateImage(template *servingv1alpha1.RevisionTemplateSpec, image string) e
return nil
}

// FreezeImageToDigest sets the image on the template to the image digest of the base revision.
func FreezeImageToDigest(template *servingv1alpha1.RevisionTemplateSpec, baseRevision *servingv1alpha1.Revision) error {
currentContainer, err := ContainerOfRevisionTemplate(template)
baseContainer, err := ContainerOfRevisionSpec(&baseRevision.Spec)
if err != nil {
return err
}
if currentContainer.Image != baseContainer.Image {
return fmt.Errorf("Could not freeze image to digest since current revision contains unexpected image.")
return fmt.Errorf("could not freeze image to digest since current revision contains unexpected image.")
}
// If the current image isn't by-digest, set the user-image annotation to it
// so we remember what it was.
Expand Down
4 changes: 2 additions & 2 deletions pkg/serving/config_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestUpdateConcurrencyTarget(t *testing.T) {
checkAnnotationValue(t, template, autoscaling.TargetAnnotationKey, 10)
// Update with invalid value
err = UpdateConcurrencyTarget(template, -1)
assert.ErrorContains(t, err, "Invalid")
assert.ErrorContains(t, err, "invalid")
}

func TestUpdateConcurrencyLimit(t *testing.T) {
Expand All @@ -216,7 +216,7 @@ func TestUpdateConcurrencyLimit(t *testing.T) {
checkContainerConcurrency(t, template, 10)
// Update with invalid value
err = UpdateConcurrencyLimit(template, -1)
assert.ErrorContains(t, err, "Invalid")
assert.ErrorContains(t, err, "invalid")
}

func TestUpdateContainerImage(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/serving/v1alpha1/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ func (r *Recorder) GetConfiguration(name string, config *v1alpha1.Configuration,

}

func (cl *MockKnClient) GetBaseRevision(service *v1alpha1.Service) (*v1alpha1.Revision, error) {
return getBaseRevision(cl, service)
func (c *MockKnClient) GetBaseRevision(service *v1alpha1.Service) (*v1alpha1.Revision, error) {
return getBaseRevision(c, service)
}

// GetConfiguration returns a configuration looked up by name
Expand Down

0 comments on commit fc03daf

Please sign in to comment.