Format go code (#1407)

Signed-off-by: Knative Automation <automation@knative.team>

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
knative-automation 2022-11-04 11:11:04 +00:00 committed by GitHub
parent 738b3d323f
commit 5d67de768b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 36 deletions

View File

@ -714,8 +714,9 @@ func parseImage(v string) (name, digest string, err error) {
// Warnings are printed to the output when the evaluation of effective namespace
// may be confusing to the user.
// active = the curently active kube cluster namespace (or "default")
// current = the namespace in which the function is currently deployed (or "")
//
// active = the curently active kube cluster namespace (or "default")
// current = the namespace in which the function is currently deployed (or "")
func namespaceWarnings(cfg deployConfig, cmd *cobra.Command) {
// NOTE(lkingland): This function can largely be removed when Namespace is
// gathered from the Global Config struct, because this logic will implicitly

View File

@ -73,7 +73,9 @@ func (c Config) RegistryDefault() string {
// NewDefault returns a config populated by global defaults as defined by the
// config file located in .Path() (the global func settings path, which is
// usually ~/.config/func).
//
// usually ~/.config/func).
//
// The config path is not required to be present.
func NewDefault() (cfg Config, err error) {
cfg = New()
@ -107,10 +109,11 @@ func (c Config) Write(path string) (err error) {
// Dir is derived in the following order, from lowest
// to highest precedence.
// 1. The default path is the zero value, indicating "no config path available",
// 1. The default path is the zero value, indicating "no config path available",
// and users of this package should act accordingly.
// 2. ~/.config/func if it exists (can be expanded: user has a home dir)
// 3. The value of $XDG_CONFIG_PATH/func if the environment variable exists.
// 2. ~/.config/func if it exists (can be expanded: user has a home dir)
// 3. The value of $XDG_CONFIG_PATH/func if the environment variable exists.
//
// The path is created if it does not already exist.
func Dir() (path string) {
// Use home if available

View File

@ -29,19 +29,19 @@ var SocatImage = "quay.io/boson/alpine-socat:1.7.4.3-r1-non-root"
//
// Usage:
//
// dialer, err := k8s.NewInClusterDialer(ctx)
// if err != nil {
// return err
// }
// defer dialer.Close()
// dialer, err := k8s.NewInClusterDialer(ctx)
// if err != nil {
// return err
// }
// defer dialer.Close()
//
// transport := &http.Transport{
// DialContext: dialer.DialContext,
// }
// transport := &http.Transport{
// DialContext: dialer.DialContext,
// }
//
// var client = http.Client{
// Transport: transport,
// }
// var client = http.Client{
// Transport: transport,
// }
func NewInClusterDialer(ctx context.Context) (*contextDialer, error) {
c := &contextDialer{
detachChan: make(chan struct{}),

View File

@ -10,13 +10,14 @@ import (
// Bar - a simple, unobtrusive progress indicator
// Usage:
// bar := New()
// bar.SetTotal(3)
// defer bar.Done()
// bar.Increment("Step 1")
// bar.Increment("Step 2")
// bar.Increment("Step 3")
// bar.Complete("Done")
//
// bar := New()
// bar.SetTotal(3)
// defer bar.Done()
// bar.Increment("Step 1")
// bar.Increment("Step 2")
// bar.Increment("Step 3")
// bar.Complete("Done")
//
// Instantiation creates a progress bar consisiting of an optional spinner
// prefix followed by an indicator of the current step, the total steps, and a
@ -34,7 +35,8 @@ import (
// method but the single status update in the same manner as when verbosity is
// enabled.
// Format:
// [spinner] i/n t
//
// [spinner] i/n t
type Bar struct {
out io.Writer
index int // Current step index

View File

@ -121,9 +121,12 @@ type templateConfig = funcDefaults
// NewRepository creates a repository instance from any of: a path on disk, a
// remote or local URI, or from the embedded default repo if uri not provided.
// Name (optional), if provided takes precedence over name derived from repo at
// the given URI.
//
// the given URI.
//
// URI (optional), the path either locally or remote from which to load
// the repository files. If not provided, the internal default is assumed.
//
// the repository files. If not provided, the internal default is assumed.
func NewRepository(name, uri string) (r Repository, err error) {
r = Repository{
uri: uri,

View File

@ -49,7 +49,6 @@ type DialContextFn = func(ctx context.Context, network, addr string) (net.Conn,
//
// - Use SSH to execute the "docker system dial-stdio" command in the remote and forward its stdio.
//
//
// The tunnel method is used whenever possible.
// The "stdio" method is used as a fallback when tunneling is not possible:
// e.g. when remote uses Windows' named pipe.

View File

@ -25,11 +25,9 @@ func TestMain(t *testing.M) {
t.Run()
}
//
// Here is a trick to avoid calling docker or podman at e2e tests.
// Let's check for default registry credentials in one of the auth sources
// In case it is not present let's create it.
//
func patchOrCreateDockerConfigFile() error {
userHome, err := os.UserHomeDir()
if err != nil {

View File

@ -15,8 +15,8 @@ import (
)
// TestContextDirFunc tests the following use case:
// - As a Developer I want my function located in a specific directory on my project, hosted on my
// public git repository from the main branch, to get deployed on my cluster
// - As a Developer I want my function located in a specific directory on my project, hosted on my
// public git repository from the main branch, to get deployed on my cluster
func TestContextDirFunc(t *testing.T) {
var gitProjectName = "test-project"

View File

@ -61,7 +61,8 @@ func rm(t *testing.T, dir string) {
// closure that when executed (intended in a defer) removes the given dirctory
// and returns the caller to the initial working directory.
// usage:
// defer within(t, "somedir")()
//
// defer within(t, "somedir")()
func Within(t *testing.T, root string) func() {
t.Helper()
cwd := pwd(t)
@ -76,9 +77,11 @@ func Within(t *testing.T, root string) func() {
// Mktemp creates a temporary directory, CDs the current processes (test) to
// said directory, and returns the path to said directory.
// Usage:
// path, rm := Mktemp(t)
// defer rm()
// CWD is now 'path'
//
// path, rm := Mktemp(t)
// defer rm()
// CWD is now 'path'
//
// errors encountererd fail the current test.
func Mktemp(t *testing.T) (string, func()) {
t.Helper()