Skip to content

Commit

Permalink
Adopt @vagababov style for consistency. (#7812)
Browse files Browse the repository at this point in the history
  • Loading branch information
JRBANCEL authored May 3, 2020
1 parent 3db1a2e commit fcba769
Show file tree
Hide file tree
Showing 145 changed files with 502 additions and 502 deletions.
8 changes: 4 additions & 4 deletions cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ func main() {
msp := metrics.NewMemStatsAll()
msp.Start(ctx, 30*time.Second)
if err := view.Register(msp.DefaultViews()...); err != nil {
log.Fatalf("Error exporting go memstats view: %v", err)
log.Fatal("Error exporting go memstats view: ", err)
}

cfg, err := sharedmain.GetConfig(*masterURL, *kubeconfig)
if err != nil {
log.Fatal("Error building kubeconfig:", err)
log.Fatal("Error building kubeconfig: ", err)
}

log.Printf("Registering %d clients", len(injection.Default.GetClients()))
Expand All @@ -131,15 +131,15 @@ func main() {

var env config
if err := envconfig.Process("", &env); err != nil {
log.Fatalf("Failed to process env: %v", err)
log.Fatal("Failed to process env: ", err)
}

kubeClient := kubeclient.Get(ctx)

// We sometimes startup faster than we can reach kube-api. Poll on failure to prevent us terminating
if perr := wait.PollImmediate(time.Second, 60*time.Second, func() (bool, error) {
if err = version.CheckMinimumVersion(kubeClient.Discovery()); err != nil {
log.Printf("Failed to get k8s version %v", err)
log.Print("Failed to get k8s version ", err)
}
return err == nil, nil
}); perr != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/activator/request_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestUpdateRequestLogFromConfigMap(t *testing.T) {
handler, err := pkghttp.NewRequestLogHandler(baseHandler, buf, "",
requestLogTemplateInputGetter(revisionLister(t, true)), false /*enableProbeRequestLog*/)
if err != nil {
t.Fatalf("want: no error, got: %v", err)
t.Fatal("want: no error, got:", err)
}

tests := []struct {
Expand Down
8 changes: 4 additions & 4 deletions cmd/autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func main() {
msp := metrics.NewMemStatsAll()
msp.Start(ctx, 30*time.Second)
if err := view.Register(msp.DefaultViews()...); err != nil {
log.Fatalf("Error exporting go memstats view: %v", err)
log.Fatal("Error exporting go memstats view: ", err)
}

cfg, err := sharedmain.GetConfig(*masterURL, *kubeconfig)
if err != nil {
log.Fatal("Error building kubeconfig:", err)
log.Fatal("Error building kubeconfig: ", err)
}

log.Printf("Registering %d clients", len(injection.Default.GetClients()))
Expand All @@ -110,7 +110,7 @@ func main() {
// We sometimes startup faster than we can reach kube-api. Poll on failure to prevent us terminating
if perr := wait.PollImmediate(time.Second, 60*time.Second, func() (bool, error) {
if err = version.CheckMinimumVersion(kubeClient.Discovery()); err != nil {
log.Printf("Failed to get k8s version %v", err)
log.Print("Failed to get k8s version ", err)
}
return err == nil, nil
}); perr != nil {
Expand All @@ -120,7 +120,7 @@ func main() {
// Set up our logger.
loggingConfig, err := sharedmain.GetLoggingConfig(ctx)
if err != nil {
log.Fatal("Error loading/parsing logging configuration:", err)
log.Fatal("Error loading/parsing logging configuration: ", err)
}
logger, atomicLevel := logging.NewLoggerFromConfig(loggingConfig, component)
defer flush(logger)
Expand Down
4 changes: 2 additions & 2 deletions cmd/default-domain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func main() {
// If there is a catch-all domain configured, then bail out (successfully) here.
defaultDomain := domainConfig.LookupDomainForLabels(map[string]string{})
if defaultDomain != routecfg.DefaultDomain {
logger.Infof("Domain is configured as: %v", defaultDomain)
logger.Info("Domain is configured as: ", defaultDomain)
return
}

Expand Down Expand Up @@ -220,6 +220,6 @@ func main() {
logger.Fatalw("Error updating ConfigMap", zap.Error(err))
}

logger.Infof("Updated default domain to: %s", domain)
logger.Info("Updated default domain to: ", domain)
server.Shutdown(context.Background())
}
4 changes: 2 additions & 2 deletions cmd/queue/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func TestProbeFailFast(t *testing.T) {

ts := newProbeTestServer(func(w http.ResponseWriter) {
if preferScaledown, err := preferPodForScaledown(f.Name()); err != nil {
t.Fatalf("Failed to process downward API labels: %v", err)
t.Fatal("Failed to process downward API labels:", err)
} else if preferScaledown {
w.WriteHeader(http.StatusBadRequest)
}
Expand Down Expand Up @@ -542,7 +542,7 @@ func BenchmarkProxyHandler(b *testing.B) {
"ns", "testksvc", "testksvc",
"pod", reportingPeriod)
if err != nil {
b.Fatalf("Failed to create stats reporter: %v", err)
b.Fatal("Failed to create stats reporter:", err)
}
queue.NewStats(time.Now(), reqChan, reportTicker.C, promStatReporter.Report)
req := httptest.NewRequest(http.MethodPost, "http://example.com", nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/activator/handler/concurrency_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func TestStats(t *testing.T) {
// Verify we're not getting extra events.
select {
case x := <-s.statChan:
t.Fatalf("Extra events received: %v", x)
t.Fatal("Extra events received:", x)
case <-time.After(5 * time.Millisecond):
// Lookin' good.
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/activator/handler/context_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (h *contextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

func sendError(err error, w http.ResponseWriter) {
msg := fmt.Sprintf("Error getting active endpoint: %v", err)
msg := fmt.Sprint("Error getting active endpoint: ", err)
if k8serrors.IsNotFound(err) {
http.Error(w, msg, http.StatusNotFound)
return
Expand Down
4 changes: 2 additions & 2 deletions pkg/activator/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestActivationHandler(t *testing.T) {

gotBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("Error reading body: %v", err)
t.Fatal("Error reading body:", err)
}
if string(gotBody) != test.wantBody {
t.Errorf("Unexpected response body. Response body %q, want %q", gotBody, test.wantBody)
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestActivationHandlerTraceSpans(t *testing.T) {
}
cfg, err := tracingconfig.NewTracingConfigFromConfigMap(cm)
if err != nil {
t.Fatalf("Failed to generate config: %v", err)
t.Fatal("Failed to generate config:", err)
}
if err := oct.ApplyConfig(cfg); err != nil {
t.Errorf("Failed to apply tracer config: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/activator/handler/healthz_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type HealthHandler struct {
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if network.IsKubeletProbe(r) {
if err := h.HealthCheck(); err != nil {
h.Logger.Warnf("Healthcheck failed: %v", err)
h.Logger.Warn("Healthcheck failed: ", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
w.WriteHeader(http.StatusOK)
Expand Down
16 changes: 8 additions & 8 deletions pkg/activator/net/throttler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestThrottlerErrorNoRevision(t *testing.T) {
revisions := fakerevisioninformer.Get(ctx)
waitInformers, err := controller.RunInformers(ctx.Done(), revisions.Informer())
if err != nil {
t.Fatalf("Failed to start informers: %v", err)
t.Fatal("Failed to start informers:", err)
}
defer func() {
cancel()
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestThrottlerErrorOneTimesOut(t *testing.T) {
revisions := fakerevisioninformer.Get(ctx)
waitInformers, err := controller.RunInformers(ctx.Done(), revisions.Informer())
if err != nil {
t.Fatalf("Failed to start informers: %v", err)
t.Fatal("Failed to start informers:", err)
}
defer func() {
cancel()
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestThrottlerSuccesses(t *testing.T) {
waitInformers, err := controller.RunInformers(ctx.Done(), endpoints.Informer(),
revisions.Informer())
if err != nil {
t.Fatalf("Failed to start informers: %v", err)
t.Fatal("Failed to start informers:", err)
}
defer func() {
cancel()
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestThrottlerSuccesses(t *testing.T) {
revID := types.NamespacedName{Namespace: testNamespace, Name: testRevision}
rt, err := throttler.getOrCreateRevisionThrottler(revID)
if err != nil {
t.Fatalf("RevisionThrottler can't be found: %v", err)
t.Fatal("RevisionThrottler can't be found:", err)
}

// Make sure our informer event has fired.
Expand Down Expand Up @@ -589,7 +589,7 @@ func TestActivatorsIndexUpdate(t *testing.T) {

waitInformers, err := controller.RunInformers(ctx.Done(), endpoints.Informer(), revisions.Informer())
if err != nil {
t.Fatalf("Failed to start informers: %v", err)
t.Fatal("Failed to start informers:", err)
}

revID := types.NamespacedName{Namespace: testNamespace, Name: testRevision}
Expand Down Expand Up @@ -637,7 +637,7 @@ func TestActivatorsIndexUpdate(t *testing.T) {

rt, err := throttler.getOrCreateRevisionThrottler(revID)
if err != nil {
t.Fatalf("RevisionThrottler can't be found: %v", err)
t.Fatal("RevisionThrottler can't be found:", err)
}

// Verify capacity gets updated. This is the very last thing we update
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestMultipleActivators(t *testing.T) {

waitInformers, err := controller.RunInformers(ctx.Done(), endpoints.Informer(), revisions.Informer())
if err != nil {
t.Fatalf("Failed to start informers: %v", err)
t.Fatal("Failed to start informers:", err)
}

rev := revisionCC1(types.NamespacedName{Namespace: testNamespace, Name: testRevision}, networking.ProtocolHTTP1)
Expand Down Expand Up @@ -733,7 +733,7 @@ func TestMultipleActivators(t *testing.T) {

rt, err := throttler.getOrCreateRevisionThrottler(revID)
if err != nil {
t.Fatalf("RevisionThrottler can't be found: %v", err)
t.Fatal("RevisionThrottler can't be found:", err)
}

// Verify capacity gets updated. This is the very last thing we update
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/serving/metadata_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ func ValidateRevisionName(ctx context.Context, name, generateName string) *apis.
if generateName != "" {
if msgs := validation.NameIsDNS1035Label(generateName, true); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprintf("not a DNS 1035 label prefix: %v", msgs),
fmt.Sprint("not a DNS 1035 label prefix: ", msgs),
"metadata.generateName")
}
}
if name != "" {
if msgs := validation.NameIsDNS1035Label(name, false); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprintf("not a DNS 1035 label: %v", msgs),
fmt.Sprint("not a DNS 1035 label: ", msgs),
"metadata.name")
}
om := apis.ParentMeta(ctx)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/serving/v1/revision_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func ExitCodeReason(exitCode int32) string {
// RevisionContainerExitingMessage constructs the status message if a container
// fails to come up.
func RevisionContainerExitingMessage(message string) string {
return fmt.Sprintf("Container failed with: %s", message)
return fmt.Sprint("Container failed with: ", message)
}

// RevisionContainerMissingMessage constructs the status message if a given image
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/serving/v1/route_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func validateTrafficList(ctx context.Context, traffic []TrafficTarget) *apis.Fie
}
if msgs := validation.IsDNS1035Label(tt.Tag); len(msgs) > 0 {
errs = errs.Also(apis.ErrInvalidArrayValue(
fmt.Sprintf("not a DNS 1035 label: %v", msgs),
fmt.Sprint("not a DNS 1035 label: ", msgs),
"tag", i))
}
if idx, ok := trafficMap[tt.Tag]; ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/serving/v1alpha1/service_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (rt *ReleaseType) Validate(ctx context.Context) *apis.FieldError {
}
if msgs := validation.IsDNS1035Label(r); len(msgs) > 0 {
errs = errs.Also(apis.ErrInvalidArrayValue(
fmt.Sprintf("not a DNS 1035 label: %v", msgs),
fmt.Sprint("not a DNS 1035 label: ", msgs),
"revisions", i))
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoscaler/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestNewConfig(t *testing.T) {
got, err := NewConfigFromConfigMap(&corev1.ConfigMap{
Data: test.input,
})
t.Logf("Error = %v", err)
t.Log("Error =", err)
if (err != nil) != test.wantErr {
t.Errorf("NewConfig() = %v, want %v", err, test.wantErr)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoscaler/fake/fake_metric_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var StaticMetricClient = MetricClient{
func Endpoints(count int, svc string) {
epAddresses := make([]corev1.EndpointAddress, count)
for i := 1; i <= count; i++ {
ip := fmt.Sprintf("127.0.0.%v", i)
ip := fmt.Sprint("127.0.0.", i)
epAddresses[i-1] = corev1.EndpointAddress{IP: ip}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/autoscaler/metrics/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func TestMetricCollectorRecord(t *testing.T) {
coll.Record(metricKey, stat)
stable, panic, err := coll.StableAndPanicConcurrency(metricKey, now)
if err != nil {
t.Fatalf("StableAndPanicConcurrency: %v", err)
t.Fatal("StableAndPanicConcurrency:", err)
}
// Scale to the window sizes.
const (
Expand All @@ -380,7 +380,7 @@ func TestMetricCollectorRecord(t *testing.T) {
}
stable, panic, err = coll.StableAndPanicRPS(metricKey, now)
if err != nil {
t.Fatalf("StableAndPanicRPS: %v", err)
t.Fatal("StableAndPanicRPS:", err)
}
if math.Abs(stable-wantS) > tolerance || math.Abs(panic-wantP) > tolerance {
t.Errorf("StableAndPanicRPS() = %v, %v; want %v, %v", stable, panic, wantS, wantP)
Expand Down
4 changes: 2 additions & 2 deletions pkg/autoscaler/metrics/stats_scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func TestScrapeAllPodsYoungPods(t *testing.T) {
now := time.Now()
got, err := scraper.Scrape(defaultMetric.Spec.StableWindow)
if err != nil {
t.Fatalf("Unexpected error from scraper.Scrape(): %v", err)
t.Fatal("Unexpected error from scraper.Scrape():", err)
}

if got.Time.Before(now) {
Expand Down Expand Up @@ -413,7 +413,7 @@ func TestScrapeSomePodsOldPods(t *testing.T) {
now := time.Now()
got, err := scraper.Scrape(defaultMetric.Spec.StableWindow)
if err != nil {
t.Fatalf("Unexpected error from scraper.Scrape(): %v", err)
t.Fatal("Unexpected error from scraper.Scrape():", err)
}

if got.Time.Before(now) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/autoscaler/scaling/autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,11 @@ func newTestAutoscalerWithScalingMetric(t *testing.T, targetValue, targetBurstCa
}
ctx, err := smetrics.RevisionContext(fake.TestNamespace, fake.TestService, fake.TestConfig, fake.TestRevision)
if err != nil {
t.Fatalf("Error creating context: %v", err)
t.Fatal("Error creating context:", err)
}
a, err := New(fake.TestNamespace, fake.TestRevision, metrics, l, deciderSpec, ctx)
if err != nil {
t.Fatalf("Error creating test autoscaler: %v", err)
t.Fatal("Error creating test autoscaler:", err)
}
fake.Endpoints(1, fake.TestService)
return a
Expand Down Expand Up @@ -474,7 +474,7 @@ func TestStartInPanicMode(t *testing.T) {
fake.Endpoints(i, fake.TestService)
a, err := New(fake.TestNamespace, fake.TestRevision, metrics, l, deciderSpec, context.Background())
if err != nil {
t.Fatalf("Error creating test autoscaler: %v", err)
t.Fatal("Error creating test autoscaler:", err)
}
if !a.panicTime.IsZero() {
t.Errorf("Create at scale %d had panic mode on", i)
Expand All @@ -488,7 +488,7 @@ func TestStartInPanicMode(t *testing.T) {
fake.Endpoints(2, fake.TestService)
a, err := New(fake.TestNamespace, fake.TestRevision, metrics, l, deciderSpec, context.Background())
if err != nil {
t.Fatalf("Error creating test autoscaler: %v", err)
t.Fatal("Error creating test autoscaler:", err)
}
if a.panicTime.IsZero() {
t.Error("Create at scale 2 had panic mode off")
Expand Down
Loading

0 comments on commit fcba769

Please sign in to comment.