UNCLASSIFIED

Commit 789f7e7c authored by sean.melissari's avatar sean.melissari
Browse files

v0.15.4

parent d335024f
Pipeline #409793 failed with stages
in 13 minutes and 14 seconds
...@@ -438,8 +438,10 @@ type Winsize struct { ...@@ -438,8 +438,10 @@ type Winsize struct {
const ( const (
AT_FDCWD = -0x64 AT_FDCWD = -0x64
AT_SYMLINK_FOLLOW = 0x4 AT_EACCESS = 0x1
AT_SYMLINK_NOFOLLOW = 0x2 AT_SYMLINK_NOFOLLOW = 0x2
AT_SYMLINK_FOLLOW = 0x4
AT_REMOVEDIR = 0x8
) )
type PollFd struct { type PollFd struct {
......
...@@ -438,8 +438,10 @@ type Winsize struct { ...@@ -438,8 +438,10 @@ type Winsize struct {
const ( const (
AT_FDCWD = -0x64 AT_FDCWD = -0x64
AT_SYMLINK_FOLLOW = 0x4 AT_EACCESS = 0x1
AT_SYMLINK_NOFOLLOW = 0x2 AT_SYMLINK_NOFOLLOW = 0x2
AT_SYMLINK_FOLLOW = 0x4
AT_REMOVEDIR = 0x8
) )
type PollFd struct { type PollFd struct {
......
...@@ -439,8 +439,10 @@ type Winsize struct { ...@@ -439,8 +439,10 @@ type Winsize struct {
const ( const (
AT_FDCWD = -0x64 AT_FDCWD = -0x64
AT_SYMLINK_FOLLOW = 0x4 AT_EACCESS = 0x1
AT_SYMLINK_NOFOLLOW = 0x2 AT_SYMLINK_NOFOLLOW = 0x2
AT_SYMLINK_FOLLOW = 0x4
AT_REMOVEDIR = 0x8
) )
type PollFd struct { type PollFd struct {
......
...@@ -432,8 +432,10 @@ type Winsize struct { ...@@ -432,8 +432,10 @@ type Winsize struct {
const ( const (
AT_FDCWD = -0x64 AT_FDCWD = -0x64
AT_SYMLINK_FOLLOW = 0x4 AT_EACCESS = 0x1
AT_SYMLINK_NOFOLLOW = 0x2 AT_SYMLINK_NOFOLLOW = 0x2
AT_SYMLINK_FOLLOW = 0x4
AT_REMOVEDIR = 0x8
) )
type PollFd struct { type PollFd struct {
......
...@@ -432,8 +432,10 @@ type Winsize struct { ...@@ -432,8 +432,10 @@ type Winsize struct {
const ( const (
AT_FDCWD = -0x64 AT_FDCWD = -0x64
AT_SYMLINK_FOLLOW = 0x4 AT_EACCESS = 0x1
AT_SYMLINK_NOFOLLOW = 0x2 AT_SYMLINK_NOFOLLOW = 0x2
AT_SYMLINK_FOLLOW = 0x4
AT_REMOVEDIR = 0x8
) )
type PollFd struct { type PollFd struct {
......
...@@ -680,7 +680,7 @@ const ( ...@@ -680,7 +680,7 @@ const (
WTD_CHOICE_CERT = 5 WTD_CHOICE_CERT = 5
WTD_STATEACTION_IGNORE = 0x00000000 WTD_STATEACTION_IGNORE = 0x00000000
WTD_STATEACTION_VERIFY = 0x00000010 WTD_STATEACTION_VERIFY = 0x00000001
WTD_STATEACTION_CLOSE = 0x00000002 WTD_STATEACTION_CLOSE = 0x00000002
WTD_STATEACTION_AUTO_CACHE = 0x00000003 WTD_STATEACTION_AUTO_CACHE = 0x00000003
WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004 WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
......
...@@ -145,7 +145,6 @@ func (r *Reservation) DelayFrom(now time.Time) time.Duration { ...@@ -145,7 +145,6 @@ func (r *Reservation) DelayFrom(now time.Time) time.Duration {
// Cancel is shorthand for CancelAt(time.Now()). // Cancel is shorthand for CancelAt(time.Now()).
func (r *Reservation) Cancel() { func (r *Reservation) Cancel() {
r.CancelAt(time.Now()) r.CancelAt(time.Now())
return
} }
// CancelAt indicates that the reservation holder will not perform the reserved action // CancelAt indicates that the reservation holder will not perform the reserved action
...@@ -186,8 +185,6 @@ func (r *Reservation) CancelAt(now time.Time) { ...@@ -186,8 +185,6 @@ func (r *Reservation) CancelAt(now time.Time) {
r.lim.lastEvent = prevEvent r.lim.lastEvent = prevEvent
} }
} }
return
} }
// Reserve is shorthand for ReserveN(time.Now(), 1). // Reserve is shorthand for ReserveN(time.Now(), 1).
...@@ -367,20 +364,13 @@ func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time, ...@@ -367,20 +364,13 @@ func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time,
last = now last = now
} }
// Avoid making delta overflow below when last is very old.
maxElapsed := lim.limit.durationFromTokens(float64(lim.burst) - lim.tokens)
elapsed := now.Sub(last)
if elapsed > maxElapsed {
elapsed = maxElapsed
}
// Calculate the new number of tokens, due to time that passed. // Calculate the new number of tokens, due to time that passed.
elapsed := now.Sub(last)
delta := lim.limit.tokensFromDuration(elapsed) delta := lim.limit.tokensFromDuration(elapsed)
tokens := lim.tokens + delta tokens := lim.tokens + delta
if burst := float64(lim.burst); tokens > burst { if burst := float64(lim.burst); tokens > burst {
tokens = burst tokens = burst
} }
return now, last, tokens return now, last, tokens
} }
...@@ -388,15 +378,11 @@ func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time, ...@@ -388,15 +378,11 @@ func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time,
// of time it takes to accumulate them at a rate of limit tokens per second. // of time it takes to accumulate them at a rate of limit tokens per second.
func (limit Limit) durationFromTokens(tokens float64) time.Duration { func (limit Limit) durationFromTokens(tokens float64) time.Duration {
seconds := tokens / float64(limit) seconds := tokens / float64(limit)
return time.Nanosecond * time.Duration(1e9*seconds) return time.Duration(float64(time.Second) * seconds)
} }
// tokensFromDuration is a unit conversion function from a time duration to the number of tokens // tokensFromDuration is a unit conversion function from a time duration to the number of tokens
// which could be accumulated during that duration at a rate of limit tokens per second. // which could be accumulated during that duration at a rate of limit tokens per second.
func (limit Limit) tokensFromDuration(d time.Duration) float64 { func (limit Limit) tokensFromDuration(d time.Duration) float64 {
// Split the integer and fractional parts ourself to minimize rounding errors. return d.Seconds() * float64(limit)
// See golang.org/issues/34861.
sec := float64(d/time.Second) * float64(limit)
nsec := float64(d%time.Second) * float64(limit)
return sec + nsec/1e9
} }
...@@ -57,6 +57,11 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string ...@@ -57,6 +57,11 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
locked := make([]*chart.Dependency, len(reqs)) locked := make([]*chart.Dependency, len(reqs))
missing := []string{} missing := []string{}
for i, d := range reqs { for i, d := range reqs {
constraint, err := semver.NewConstraint(d.Version)
if err != nil {
return nil, errors.Wrapf(err, "dependency %q has an invalid version/constraint format", d.Name)
}
if d.Repository == "" { if d.Repository == "" {
// Local chart subfolder // Local chart subfolder
if _, err := GetLocalPath(filepath.Join("charts", d.Name), r.chartpath); err != nil { if _, err := GetLocalPath(filepath.Join("charts", d.Name), r.chartpath); err != nil {
...@@ -77,13 +82,22 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string ...@@ -77,13 +82,22 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
return nil, err return nil, err
} }
// The version of the chart locked will be the version of the chart
// currently listed in the file system within the chart.
ch, err := loader.LoadDir(chartpath) ch, err := loader.LoadDir(chartpath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
v, err := semver.NewVersion(ch.Metadata.Version)
if err != nil {
// Not a legit entry.
continue
}
if !constraint.Check(v) {
missing = append(missing, d.Name)
continue
}
locked[i] = &chart.Dependency{ locked[i] = &chart.Dependency{
Name: d.Name, Name: d.Name,
Repository: d.Repository, Repository: d.Repository,
...@@ -92,11 +106,6 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string ...@@ -92,11 +106,6 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
continue continue
} }
constraint, err := semver.NewConstraint(d.Version)
if err != nil {
return nil, errors.Wrapf(err, "dependency %q has an invalid version/constraint format", d.Name)
}
repoName := repoNames[d.Name] repoName := repoNames[d.Name]
// if the repository was not defined, but the dependency defines a repository url, bypass the cache // if the repository was not defined, but the dependency defines a repository url, bypass the cache
if repoName == "" && d.Repository != "" { if repoName == "" && d.Repository != "" {
......
...@@ -158,7 +158,6 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er ...@@ -158,7 +158,6 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
if err != nil { if err != nil {
return nil, errors.Errorf("invalid chart URL format: %s", ref) return nil, errors.Errorf("invalid chart URL format: %s", ref)
} }
c.Options = append(c.Options, getter.WithURL(ref))
rf, err := loadRepoConfig(c.RepositoryConfig) rf, err := loadRepoConfig(c.RepositoryConfig)
if err != nil { if err != nil {
...@@ -177,6 +176,8 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er ...@@ -177,6 +176,8 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
// If there is no special config, return the default HTTP client and // If there is no special config, return the default HTTP client and
// swallow the error. // swallow the error.
if err == ErrNoOwnerRepo { if err == ErrNoOwnerRepo {
// Make sure to add the ref URL as the URL for the getter
c.Options = append(c.Options, getter.WithURL(ref))
return u, nil return u, nil
} }
return u, err return u, err
...@@ -215,6 +216,10 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er ...@@ -215,6 +216,10 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
return u, err return u, err
} }
// Now that we have the chart repository information we can use that URL
// to set the URL for the getter.
c.Options = append(c.Options, getter.WithURL(rc.URL))
r, err := repo.NewChartRepository(rc, c.Getters) r, err := repo.NewChartRepository(rc, c.Getters)
if err != nil { if err != nil {
return u, err return u, err
......
...@@ -310,7 +310,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { ...@@ -310,7 +310,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
// Any failure to resolve/download a chart should fail: // Any failure to resolve/download a chart should fail:
// https://github.com/helm/helm/issues/1439 // https://github.com/helm/helm/issues/1439
churl, username, password, passcredentialsall, err := m.findChartURL(dep.Name, dep.Version, dep.Repository, repos) churl, username, password, insecureskiptlsverify, passcredentialsall, caFile, certFile, keyFile, err := m.findChartURL(dep.Name, dep.Version, dep.Repository, repos)
if err != nil { if err != nil {
saveError = errors.Wrapf(err, "could not find %s", churl) saveError = errors.Wrapf(err, "could not find %s", churl)
break break
...@@ -333,6 +333,8 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { ...@@ -333,6 +333,8 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
Options: []getter.Option{ Options: []getter.Option{
getter.WithBasicAuth(username, password), getter.WithBasicAuth(username, password),
getter.WithPassCredentialsAll(passcredentialsall), getter.WithPassCredentialsAll(passcredentialsall),
getter.WithInsecureSkipVerifyTLS(insecureskiptlsverify),
getter.WithTLSClientConfig(certFile, keyFile, caFile),
}, },
} }
...@@ -686,9 +688,9 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error { ...@@ -686,9 +688,9 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
// repoURL is the repository to search // repoURL is the repository to search
// //
// If it finds a URL that is "relative", it will prepend the repoURL. // If it finds a URL that is "relative", it will prepend the repoURL.
func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url, username, password string, passcredentialsall bool, err error) { func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url, username, password string, insecureskiptlsverify, passcredentialsall bool, caFile, certFile, keyFile string, err error) {
if strings.HasPrefix(repoURL, "oci://") { if strings.HasPrefix(repoURL, "oci://") {
return fmt.Sprintf("%s/%s:%s", repoURL, name, version), "", "", false, nil return fmt.Sprintf("%s/%s:%s", repoURL, name, version), "", "", false, false, "", "", "", nil
} }
for _, cr := range repos { for _, cr := range repos {
...@@ -711,15 +713,19 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]* ...@@ -711,15 +713,19 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*
username = cr.Config.Username username = cr.Config.Username
password = cr.Config.Password password = cr.Config.Password
passcredentialsall = cr.Config.PassCredentialsAll passcredentialsall = cr.Config.PassCredentialsAll
insecureskiptlsverify = cr.Config.InsecureSkipTLSverify
caFile = cr.Config.CAFile
certFile = cr.Config.CertFile
keyFile = cr.Config.KeyFile
return return
} }
} }
url, err = repo.FindChartInRepoURL(repoURL, name, version, "", "", "", m.Getters) url, err = repo.FindChartInRepoURL(repoURL, name, version, certFile, keyFile, caFile, m.Getters)
if err == nil { if err == nil {
return url, username, password, false, err return url, username, password, false, false, "", "", "", err
} }
err = errors.Errorf("chart %s not found in %s: %s", name, repoURL, err) err = errors.Errorf("chart %s not found in %s: %s", name, repoURL, err)
return url, username, password, false, err return url, username, password, false, false, "", "", "", err
} }
// findEntryByName finds an entry in the chart repository whose name matches the given name. // findEntryByName finds an entry in the chart repository whose name matches the given name.
......
...@@ -173,6 +173,16 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render ...@@ -173,6 +173,16 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render
return val, nil return val, nil
} }
// Override sprig fail function for linting and wrapping message
funcMap["fail"] = func(msg string) (string, error) {
if e.LintMode {
// Don't fail when linting
log.Printf("[INFO] Fail: %s", msg)
return "", nil
}
return "", errors.New(warnWrap(msg))
}
// If we are not linting and have a cluster connection, provide a Kubernetes-backed // If we are not linting and have a cluster connection, provide a Kubernetes-backed
// implementation. // implementation.
if !e.LintMode && e.config != nil { if !e.LintMode && e.config != nil {
......
...@@ -21,6 +21,8 @@ import ( ...@@ -21,6 +21,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"os"
"path/filepath"
"strings" "strings"
"sync" "sync"
"time" "time"
...@@ -55,6 +57,10 @@ var ErrNoObjectsVisited = errors.New("no objects visited") ...@@ -55,6 +57,10 @@ var ErrNoObjectsVisited = errors.New("no objects visited")
var metadataAccessor = meta.NewAccessor() var metadataAccessor = meta.NewAccessor()
// ManagedFieldsManager is the name of the manager of Kubernetes managedFields
// first introduced in Kubernetes 1.18
var ManagedFieldsManager string
// Client represents a client capable of communicating with the Kubernetes API. // Client represents a client capable of communicating with the Kubernetes API.
type Client struct { type Client struct {
Factory Factory Factory Factory
...@@ -100,7 +106,7 @@ func (c *Client) getKubeClient() (*kubernetes.Clientset, error) { ...@@ -100,7 +106,7 @@ func (c *Client) getKubeClient() (*kubernetes.Clientset, error) {
return c.kubeClient, err return c.kubeClient, err
} }
// IsReachable tests connectivity to the cluster // IsReachable tests connectivity to the cluster.
func (c *Client) IsReachable() error { func (c *Client) IsReachable() error {
client, err := c.getKubeClient() client, err := c.getKubeClient()
if err == genericclioptions.ErrEmptyConfig { if err == genericclioptions.ErrEmptyConfig {
...@@ -126,7 +132,7 @@ func (c *Client) Create(resources ResourceList) (*Result, error) { ...@@ -126,7 +132,7 @@ func (c *Client) Create(resources ResourceList) (*Result, error) {
return &Result{Created: resources}, nil return &Result{Created: resources}, nil
} }
// Wait up to the given timeout for the specified resources to be ready // Wait waits up to the given timeout for the specified resources to be ready.
func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { func (c *Client) Wait(resources ResourceList, timeout time.Duration) error {
cs, err := c.getKubeClient() cs, err := c.getKubeClient()
if err != nil { if err != nil {
...@@ -206,7 +212,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err ...@@ -206,7 +212,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
return err return err
} }
helper := resource.NewHelper(info.Client, info.Mapping) helper := resource.NewHelper(info.Client, info.Mapping).WithFieldManager(getManagedFieldsManager())
if _, err := helper.Get(info.Namespace, info.Name); err != nil { if _, err := helper.Get(info.Namespace, info.Name); err != nil {
if !apierrors.IsNotFound(err) { if !apierrors.IsNotFound(err) {
return errors.Wrap(err, "could not get information about the resource") return errors.Wrap(err, "could not get information about the resource")
...@@ -324,7 +330,7 @@ func (c *Client) watchTimeout(t time.Duration) func(*resource.Info) error { ...@@ -324,7 +330,7 @@ func (c *Client) watchTimeout(t time.Duration) func(*resource.Info) error {
// WatchUntilReady watches the resources given and waits until it is ready. // WatchUntilReady watches the resources given and waits until it is ready.
// //
// This function is mainly for hook implementations. It watches for a resource to // This method is mainly for hook implementations. It watches for a resource to
// hit a particular milestone. The milestone depends on the Kind. // hit a particular milestone. The milestone depends on the Kind.
// //
// For most kinds, it checks to see if the resource is marked as Added or Modified // For most kinds, it checks to see if the resource is marked as Added or Modified
...@@ -359,6 +365,26 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error { ...@@ -359,6 +365,26 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
return nil return nil
} }
// getManagedFieldsManager returns the manager string. If one was set it will be returned.
// Otherwise, one is calculated based on the name of the binary.
func getManagedFieldsManager() string {
// When a manager is explicitly set use it
if ManagedFieldsManager != "" {
return ManagedFieldsManager
}
// When no manager is set and no calling application can be found it is unknown
if len(os.Args[0]) == 0 {
return "unknown"
}
// When there is an application that can be determined and no set manager
// use the base name. This is one of the ways Kubernetes libs handle figuring
// names out.
return filepath.Base(os.Args[0])
}
func batchPerform(infos ResourceList, fn func(*resource.Info) error, errs chan<- error) { func batchPerform(infos ResourceList, fn func(*resource.Info) error, errs chan<- error) {
var kind string var kind string
var wg sync.WaitGroup var wg sync.WaitGroup
...@@ -377,7 +403,7 @@ func batchPerform(infos ResourceList, fn func(*resource.Info) error, errs chan<- ...@@ -377,7 +403,7 @@ func batchPerform(infos ResourceList, fn func(*resource.Info) error, errs chan<-
} }
func createResource(info *resource.Info) error { func createResource(info *resource.Info) error {
obj, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object) obj, err := resource.NewHelper(info.Client, info.Mapping).WithFieldManager(getManagedFieldsManager()).Create(info.Namespace, true, info.Object)
if err != nil { if err != nil {
return err return err
} }
...@@ -387,7 +413,7 @@ func createResource(info *resource.Info) error { ...@@ -387,7 +413,7 @@ func createResource(info *resource.Info) error {
func deleteResource(info *resource.Info) error { func deleteResource(info *resource.Info) error {
policy := metav1.DeletePropagationBackground policy := metav1.DeletePropagationBackground
opts := &metav1.DeleteOptions{PropagationPolicy: &policy} opts := &metav1.DeleteOptions{PropagationPolicy: &policy}
_, err := resource.NewHelper(info.Client, info.Mapping).DeleteWithOptions(info.Namespace, info.Name, opts) _, err := resource.NewHelper(info.Client, info.Mapping).WithFieldManager(getManagedFieldsManager()).DeleteWithOptions(info.Namespace, info.Name, opts)
return err return err
} }
...@@ -402,7 +428,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P ...@@ -402,7 +428,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
} }
// Fetch the current object for the three way merge // Fetch the current object for the three way merge
helper := resource.NewHelper(target.Client, target.Mapping) helper := resource.NewHelper(target.Client, target.Mapping).WithFieldManager(getManagedFieldsManager())
currentObj, err := helper.Get(target.Namespace, target.Name) currentObj, err := helper.Get(target.Namespace, target.Name)
if err != nil && !apierrors.IsNotFound(err) { if err != nil && !apierrors.IsNotFound(err) {
return nil, types.StrategicMergePatchType, errors.Wrapf(err, "unable to get data for current object %s/%s", target.Namespace, target.Name) return nil, types.StrategicMergePatchType, errors.Wrapf(err, "unable to get data for current object %s/%s", target.Namespace, target.Name)
...@@ -444,7 +470,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P ...@@ -444,7 +470,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, force bool) error { func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, force bool) error {
var ( var (
obj runtime.Object obj runtime.Object
helper = resource.NewHelper(target.Client, target.Mapping) helper = resource.NewHelper(target.Client, target.Mapping).WithFieldManager(getManagedFieldsManager())
kind = target.Mapping.GroupVersionKind.Kind kind = target.Mapping.GroupVersionKind.Kind
) )
......
...@@ -30,14 +30,19 @@ type Interface interface { ...@@ -30,14 +30,19 @@ type Interface interface {
// Create creates one or more resources. // Create creates one or more resources.
Create(resources ResourceList) (*Result, error) Create(resources ResourceList) (*Result, error)
// Wait waits up to the given timeout for the specified resources to be ready.
Wait(resources ResourceList, timeout time.Duration) error Wait(resources ResourceList, timeout time.Duration) error
// WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs.
WaitWithJobs(resources ResourceList, timeout time.Duration) error WaitWithJobs(resources ResourceList, timeout time.Duration) error
// Delete destroys one or more resources. // Delete destroys one or more resources.
Delete(resources ResourceList) (*Result, []error) Delete(resources ResourceList) (*Result, []error)
// Watch the resource in reader until it is "ready". This method // WatchUntilReady watches the resources given and waits until it is ready.
//
// This method is mainly for hook implementations. It watches for a resource to
// hit a particular milestone. The milestone depends on the Kind.
// //
// For Jobs, "ready" means the Job ran to completion (exited without error). // For Jobs, "ready" means the Job ran to completion (exited without error).
// For Pods, "ready" means the Pod phase is marked "succeeded". // For Pods, "ready" means the Pod phase is marked "succeeded".
...@@ -49,9 +54,9 @@ type Interface interface { ...@@ -49,9 +54,9 @@ type Interface interface {
// if it doesn't exist. // if it doesn't exist.
Update(original, target ResourceList, force bool) (*Result, error) Update(original, target ResourceList, force bool) (*Result, error)
// Build creates a resource list from a Reader // Build creates a resource list from a Reader.
// //
// reader must contain a YAML stream (one or more YAML documents separated // Reader must contain a YAML stream (one or more YAML documents separated
// by "\n---\n") // by "\n---\n")
// //
// Validates against OpenAPI schema if validate is true. // Validates against OpenAPI schema if validate is true.
...@@ -61,7 +66,7 @@ type Interface interface { ...@@ -61,7 +66,7 @@ type Interface interface {
// and returns said phase (PodSucceeded or PodFailed qualify). // and returns said phase (PodSucceeded or PodFailed qualify).
WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error)
// isReachable checks whether the client is able to connect to the cluster // IsReachable checks whether the client is able to connect to the cluster.
IsReachable() error IsReachable() error
} }
......
...@@ -286,7 +286,8 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, ...@@ -286,7 +286,8 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName,
// ResolveReferenceURL resolves refURL relative to baseURL. // ResolveReferenceURL resolves refURL relative to baseURL.
// If refURL is absolute, it simply returns refURL. // If refURL is absolute, it simply returns refURL.
func ResolveReferenceURL(baseURL, refURL string) (string, error) { func ResolveReferenceURL(baseURL, refURL string) (string, error) {
parsedBaseURL, err := url.Parse(baseURL) // We need a trailing slash for ResolveReference to work, but make sure there isn't already one
parsedBaseURL, err := url.Parse(strings.TrimSuffix(baseURL, "/") + "/")
if err != nil { if err != nil {
return "", errors.Wrapf(err, "failed to parse %s as URL", baseURL) return "", errors.Wrapf(err, "failed to parse %s as URL", baseURL)
} }
...@@ -296,8 +297,6 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { ...@@ -296,8 +297,6 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) {
return "", errors.Wrapf(err, "failed to parse %s as URL", refURL) return "", errors.Wrapf(err, "failed to parse %s as URL", refURL)
} }
// We need a trailing slash for ResolveReference to work, but make sure there isn't already one
parsedBaseURL.Path = strings.TrimSuffix(parsedBaseURL.Path, "/") + "/"
return parsedBaseURL.ResolveReference(parsedRefURL).String(), nil return parsedBaseURL.ResolveReference(parsedRefURL).String(), nil
} }
......
...@@ -310,6 +310,10 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { ...@@ -310,6 +310,10 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) {
return nil, err return nil, err
} }
if len(records) == 0 {
return nil, ErrReleaseNotFound
}
var releases []*rspb.Release var releases []*rspb.Release
for _, record := range records { for _, record := range records {
release, err := decodeRelease(record.Body) release, err := decodeRelease(record.Body)
......
...@@ -78,8 +78,6 @@ type Connection interface { ...@@ -78,8 +78,6 @@ type Connection interface {
// SetIdleTimeout sets the amount of time the connection may remain idle before // SetIdleTimeout sets the amount of time the connection may remain idle before
// it is automatically closed. // it is automatically closed.
SetIdleTimeout(timeout time.Duration) SetIdleTimeout(timeout time.Duration)
// RemoveStreams can be used to remove a set of streams from the Connection.
RemoveStreams(streams ...Stream)
} }
// Stream represents a bidirectional communications channel that is part of an // Stream represents a bidirectional communications channel that is part of an
......
...@@ -31,7 +31,7 @@ import ( ...@@ -31,7 +31,7 @@ import (
// streams. // streams.
type connection struct { type connection struct {
conn *spdystream.Connection conn *spdystream.Connection
streams map[uint32]httpstream.Stream streams []httpstream.Stream
streamLock sync.Mutex streamLock sync.Mutex
newStreamHandler httpstream.NewStreamHandler newStreamHandler httpstream.NewStreamHandler
ping func() (time.Duration, error) ping func() (time.Duration, error)
...@@ -85,12 +85,7 @@ func NewServerConnectionWithPings(conn net.Conn, newStreamHandler httpstream.New ...@@ -85,12 +85,7 @@ func NewServerConnectionWithPings(conn net.Conn, newStreamHandler httpstream.New
// will be invoked when the server receives a newly created stream from the // will be invoked when the server receives a newly created stream from the
// client. // client.
func newConnection(conn *spdystream.Connection, newStreamHandler httpstream.NewStreamHandler, pingPeriod time.Duration, pingFn func() (time.Duration, error)) httpstream.Connection { func newConnection(conn *spdystream.Connection, newStreamHandler httpstream.NewStreamHandler, pingPeriod time.Duration, pingFn func() (time.Duration, error)) httpstream.Connection {
c := &connection{ c := &connection{conn: conn, newStreamHandler: newStreamHandler, ping: pingFn}
conn: conn,
newStreamHandler: newStreamHandler,
ping: pingFn,
streams: make(map[uint32]httpstream.Stream),
}
go conn.Serve(c.newSpdyStream) go conn.Serve(c.newSpdyStream)
if pingPeriod > 0 && pingFn != nil { if pingPeriod > 0 && pingFn != nil {
go c.sendPings(pingPeriod) go c.sendPings(pingPeriod)
...@@ -110,7 +105,7 @@ func (c *connection) Close() error { ...@@ -110,7 +105,7 @@ func (c *connection) Close() error {
// calling Reset instead of Close ensures that all streams are fully torn down // calling Reset instead of Close ensures that all streams are fully torn down
s.Reset() s.Reset()
} }
c.streams = make(map[uint32]httpstream.Stream, 0) c.streams = make([]httpstream.Stream, 0)
c.streamLock.Unlock() c.streamLock.Unlock()
// now that all streams are fully torn down, it's safe to call close on the underlying connection, // now that all streams are fully torn down, it's safe to call close on the underlying connection,
...@@ -119,15 +114,6 @@ func (c *connection) Close() error { ...@@ -119,15 +114,6 @@ func (c *connection) Close() error {
return c.conn.Close() return c.conn.Close()
} }
// RemoveStreams can be used to removes a set of streams from the Connection.
func (c *connection) RemoveStreams(streams ...httpstream.Stream) {
c.streamLock.Lock()
for _, stream := range streams {
delete(c.streams, stream.Identifier())
}
c.streamLock.Unlock()
}
// CreateStream creates a new stream with the specified headers and registers // CreateStream creates a new stream with the specified headers and registers
// it with the connection. // it with the connection.
func (c *connection) CreateStream(headers http.Header) (httpstream.Stream, error) { func (c *connection) CreateStream(headers http.Header) (httpstream.Stream, error) {
...@@ -147,7 +133,7 @@ func (c *connection) CreateStream(headers http.Header) (httpstream.Stream, error ...@@ -147,7 +133,7 @@ func (c *connection) CreateStream(headers http.Header) (httpstream.Stream, error
// it owns. // it owns.
func (c *connection) registerStream(s httpstream.Stream) { func (c *connection) registerStream(s httpstream.Stream) {
c.streamLock.Lock() c.streamLock.Lock()
c.streams[s.Identifier()] = s c.streams = append(c.streams, s)
c.streamLock.Unlock() c.streamLock.Unlock()
} }
......
...@@ -216,13 +216,13 @@ var internalPackages = []string{"client-go/tools/cache/"} ...@@ -216,13 +216,13 @@ var internalPackages = []string{"client-go/tools/cache/"}
// objects and subsequent deltas. // objects and subsequent deltas.
// Run will exit when stopCh is closed. // Run will exit when stopCh is closed.
func (r *Reflector) Run(stopCh <-chan struct{}) { func (r *Reflector) Run(stopCh <-chan struct{}) {
klog.V(2).Infof("Starting reflector %s (%s) from %s", r.expectedTypeName, r.resyncPeriod, r.name) klog.V(3).Infof("Starting reflector %s (%s) from %s", r.expectedTypeName, r.resyncPeriod, r.name)
wait.BackoffUntil(func() { wait.BackoffUntil(func() {
if err := r.ListAndWatch(stopCh); err != nil { if err := r.ListAndWatch(stopCh); err != nil {
r.watchErrorHandler(r, err) r.watchErrorHandler(r, err)
} }
}, r.backoffManager, true, stopCh) }, r.backoffManager, true, stopCh)
klog.V(2).Infof("Stopping reflector %s (%s) from %s", r.expectedTypeName, r.resyncPeriod, r.name) klog.V(3).Infof("Stopping reflector %s (%s) from %s", r.expectedTypeName, r.resyncPeriod, r.name)
} }
var ( var (
......
...@@ -69,9 +69,6 @@ github.com/acomagu/bufpipe ...@@ -69,9 +69,6 @@ github.com/acomagu/bufpipe
github.com/asaskevich/govalidator github.com/asaskevich/govalidator
# github.com/beorn7/perks v1.0.1 # github.com/beorn7/perks v1.0.1
github.com/beorn7/perks/quantile github.com/beorn7/perks/quantile
# github.com/blang/semver/v4 v4.0.0
## explicit
github.com/blang/semver/v4
# github.com/cespare/xxhash/v2 v2.1.1 # github.com/cespare/xxhash/v2 v2.1.1
github.com/cespare/xxhash/v2 github.com/cespare/xxhash/v2
# github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 # github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59
...@@ -213,7 +210,7 @@ github.com/fluxcd/pkg/untar ...@@ -213,7 +210,7 @@ github.com/fluxcd/pkg/untar
# github.com/fluxcd/pkg/version v0.1.0 # github.com/fluxcd/pkg/version v0.1.0
## explicit ## explicit
github.com/fluxcd/pkg/version github.com/fluxcd/pkg/version
# github.com/fluxcd/source-controller/api v0.15.3 => ./api # github.com/fluxcd/source-controller/api v0.15.4 => ./api
## explicit ## explicit
github.com/fluxcd/source-controller/api/v1beta1 github.com/fluxcd/source-controller/api/v1beta1
# github.com/fsnotify/fsnotify v1.4.9 # github.com/fsnotify/fsnotify v1.4.9
...@@ -457,7 +454,7 @@ github.com/onsi/ginkgo/reporters/stenographer ...@@ -457,7 +454,7 @@ github.com/onsi/ginkgo/reporters/stenographer
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
github.com/onsi/ginkgo/types github.com/onsi/ginkgo/types
# github.com/onsi/gomega v1.13.0 # github.com/onsi/gomega v1.14.0
## explicit ## explicit
github.com/onsi/gomega github.com/onsi/gomega
github.com/onsi/gomega/format github.com/onsi/gomega/format
...@@ -487,6 +484,7 @@ github.com/pkg/errors ...@@ -487,6 +484,7 @@ github.com/pkg/errors
github.com/pmezard/go-difflib/difflib github.com/pmezard/go-difflib/difflib
# github.com/prometheus/client_golang v1.11.0 # github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus
github.com/prometheus/client_golang/prometheus/collectors
github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/client_golang/prometheus/promhttp github.com/prometheus/client_golang/prometheus/promhttp
# github.com/prometheus/client_model v0.2.0 # github.com/prometheus/client_model v0.2.0
...@@ -552,7 +550,7 @@ go.starlark.net/syntax ...@@ -552,7 +550,7 @@ go.starlark.net/syntax
go.uber.org/atomic go.uber.org/atomic
# go.uber.org/multierr v1.6.0 # go.uber.org/multierr v1.6.0
go.uber.org/multierr go.uber.org/multierr
# go.uber.org/zap v1.17.0 # go.uber.org/zap v1.18.1
go.uber.org/zap go.uber.org/zap
go.uber.org/zap/buffer go.uber.org/zap/buffer
go.uber.org/zap/internal/bufferpool go.uber.org/zap/internal/bufferpool
...@@ -608,7 +606,7 @@ golang.org/x/oauth2/jwt ...@@ -608,7 +606,7 @@ golang.org/x/oauth2/jwt
## explicit ## explicit
golang.org/x/sync/errgroup golang.org/x/sync/errgroup
golang.org/x/sync/semaphore golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 # golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/execabs golang.org/x/sys/execabs
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader
...@@ -639,7 +637,7 @@ golang.org/x/text/transform ...@@ -639,7 +637,7 @@ golang.org/x/text/transform
golang.org/x/text/unicode/bidi golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm golang.org/x/text/unicode/norm
golang.org/x/text/width golang.org/x/text/width
# golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba # golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
golang.org/x/time/rate golang.org/x/time/rate
# gomodules.xyz/jsonpatch/v2 v2.2.0 # gomodules.xyz/jsonpatch/v2 v2.2.0
gomodules.xyz/jsonpatch/v2 gomodules.xyz/jsonpatch/v2
...@@ -714,7 +712,7 @@ gotest.tools/assert/cmp ...@@ -714,7 +712,7 @@ gotest.tools/assert/cmp
gotest.tools/internal/difflib gotest.tools/internal/difflib
gotest.tools/internal/format gotest.tools/internal/format
gotest.tools/internal/source gotest.tools/internal/source
# helm.sh/helm/v3 v3.6.1 # helm.sh/helm/v3 v3.6.3
## explicit ## explicit
helm.sh/helm/v3/internal/experimental/registry helm.sh/helm/v3/internal/experimental/registry
helm.sh/helm/v3/internal/fileutil helm.sh/helm/v3/internal/fileutil
...@@ -751,7 +749,7 @@ helm.sh/helm/v3/pkg/repo ...@@ -751,7 +749,7 @@ helm.sh/helm/v3/pkg/repo
helm.sh/helm/v3/pkg/storage helm.sh/helm/v3/pkg/storage
helm.sh/helm/v3/pkg/storage/driver helm.sh/helm/v3/pkg/storage/driver
helm.sh/helm/v3/pkg/time helm.sh/helm/v3/pkg/time
# k8s.io/api v0.21.1 # k8s.io/api v0.21.3
## explicit ## explicit
k8s.io/api/admission/v1 k8s.io/api/admission/v1
k8s.io/api/admission/v1beta1 k8s.io/api/admission/v1beta1
...@@ -799,7 +797,7 @@ k8s.io/api/scheduling/v1beta1 ...@@ -799,7 +797,7 @@ k8s.io/api/scheduling/v1beta1
k8s.io/api/storage/v1 k8s.io/api/storage/v1
k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1alpha1
k8s.io/api/storage/v1beta1 k8s.io/api/storage/v1beta1
# k8s.io/apiextensions-apiserver v0.21.1 # k8s.io/apiextensions-apiserver v0.21.3
k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/apis/apiextensions
k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1
...@@ -807,7 +805,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset ...@@ -807,7 +805,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset
k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme
k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1
k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1
# k8s.io/apimachinery v0.21.1 # k8s.io/apimachinery v0.21.3
## explicit ## explicit
k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/equality
k8s.io/apimachinery/pkg/api/errors k8s.io/apimachinery/pkg/api/errors
...@@ -864,13 +862,13 @@ k8s.io/apimachinery/pkg/watch ...@@ -864,13 +862,13 @@ k8s.io/apimachinery/pkg/watch
k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/json
k8s.io/apimachinery/third_party/forked/golang/netutil k8s.io/apimachinery/third_party/forked/golang/netutil
k8s.io/apimachinery/third_party/forked/golang/reflect k8s.io/apimachinery/third_party/forked/golang/reflect
# k8s.io/apiserver v0.21.1 # k8s.io/apiserver v0.21.3
k8s.io/apiserver/pkg/endpoints/deprecation k8s.io/apiserver/pkg/endpoints/deprecation
# k8s.io/cli-runtime v0.21.0 # k8s.io/cli-runtime v0.21.0
k8s.io/cli-runtime/pkg/genericclioptions k8s.io/cli-runtime/pkg/genericclioptions
k8s.io/cli-runtime/pkg/printers k8s.io/cli-runtime/pkg/printers
k8s.io/cli-runtime/pkg/resource k8s.io/cli-runtime/pkg/resource
# k8s.io/client-go v0.21.1 # k8s.io/client-go v0.21.3
## explicit ## explicit
k8s.io/client-go/applyconfigurations/admissionregistration/v1 k8s.io/client-go/applyconfigurations/admissionregistration/v1
k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1 k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1
...@@ -1006,7 +1004,7 @@ k8s.io/client-go/util/jsonpath ...@@ -1006,7 +1004,7 @@ k8s.io/client-go/util/jsonpath
k8s.io/client-go/util/keyutil k8s.io/client-go/util/keyutil
k8s.io/client-go/util/retry k8s.io/client-go/util/retry
k8s.io/client-go/util/workqueue k8s.io/client-go/util/workqueue
# k8s.io/component-base v0.21.1 # k8s.io/component-base v0.21.3
k8s.io/component-base/config k8s.io/component-base/config
k8s.io/component-base/config/v1alpha1 k8s.io/component-base/config/v1alpha1
k8s.io/component-base/version k8s.io/component-base/version
...@@ -1024,13 +1022,13 @@ k8s.io/kubectl/pkg/util/openapi/validation ...@@ -1024,13 +1022,13 @@ k8s.io/kubectl/pkg/util/openapi/validation
k8s.io/kubectl/pkg/util/templates k8s.io/kubectl/pkg/util/templates
k8s.io/kubectl/pkg/util/term k8s.io/kubectl/pkg/util/term
k8s.io/kubectl/pkg/validation k8s.io/kubectl/pkg/validation
# k8s.io/utils v0.0.0-20210527160623-6fdb442a123b # k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
k8s.io/utils/buffer k8s.io/utils/buffer
k8s.io/utils/exec k8s.io/utils/exec
k8s.io/utils/integer k8s.io/utils/integer
k8s.io/utils/pointer k8s.io/utils/pointer
k8s.io/utils/trace k8s.io/utils/trace
# sigs.k8s.io/controller-runtime v0.9.0 # sigs.k8s.io/controller-runtime v0.9.5
## explicit ## explicit
sigs.k8s.io/controller-runtime sigs.k8s.io/controller-runtime
sigs.k8s.io/controller-runtime/pkg/builder sigs.k8s.io/controller-runtime/pkg/builder
...@@ -1053,6 +1051,7 @@ sigs.k8s.io/controller-runtime/pkg/handler ...@@ -1053,6 +1051,7 @@ sigs.k8s.io/controller-runtime/pkg/handler
sigs.k8s.io/controller-runtime/pkg/healthz sigs.k8s.io/controller-runtime/pkg/healthz
sigs.k8s.io/controller-runtime/pkg/internal/controller sigs.k8s.io/controller-runtime/pkg/internal/controller
sigs.k8s.io/controller-runtime/pkg/internal/controller/metrics sigs.k8s.io/controller-runtime/pkg/internal/controller/metrics
sigs.k8s.io/controller-runtime/pkg/internal/flock
sigs.k8s.io/controller-runtime/pkg/internal/log sigs.k8s.io/controller-runtime/pkg/internal/log
sigs.k8s.io/controller-runtime/pkg/internal/objectutil sigs.k8s.io/controller-runtime/pkg/internal/objectutil
sigs.k8s.io/controller-runtime/pkg/internal/recorder sigs.k8s.io/controller-runtime/pkg/internal/recorder
...@@ -1155,7 +1154,7 @@ sigs.k8s.io/kustomize/kyaml/yaml/merge2 ...@@ -1155,7 +1154,7 @@ sigs.k8s.io/kustomize/kyaml/yaml/merge2
sigs.k8s.io/kustomize/kyaml/yaml/merge3 sigs.k8s.io/kustomize/kyaml/yaml/merge3
sigs.k8s.io/kustomize/kyaml/yaml/schema sigs.k8s.io/kustomize/kyaml/yaml/schema
sigs.k8s.io/kustomize/kyaml/yaml/walk sigs.k8s.io/kustomize/kyaml/yaml/walk
# sigs.k8s.io/structured-merge-diff/v4 v4.1.0 # sigs.k8s.io/structured-merge-diff/v4 v4.1.2
sigs.k8s.io/structured-merge-diff/v4/fieldpath sigs.k8s.io/structured-merge-diff/v4/fieldpath
sigs.k8s.io/structured-merge-diff/v4/schema sigs.k8s.io/structured-merge-diff/v4/schema
sigs.k8s.io/structured-merge-diff/v4/typed sigs.k8s.io/structured-merge-diff/v4/typed
......
run:
deadline: 5m
linters-settings:
lll:
line-length: 170
dupl:
threshold: 400
issues:
# don't skip warning about doc comments
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- linters: [errcheck]
text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
linters: linters:
disable-all: true disable-all: true
enable: enable:
- misspell - asciicheck
- structcheck - bodyclose
- golint
- govet
- deadcode - deadcode
- depguard
- dogsled
- errcheck - errcheck
- varcheck - exportloopref
- unparam - goconst
- ineffassign - gocritic
- nakedret
- gocyclo - gocyclo
- dupl - godot
- gofmt
- goimports - goimports
- golint - goprintffuncname
# disabled: - gosec
# - goconst is overly aggressive - gosimple
# - lll generally just complains about flag help & error strings that are human-readable - govet
- ifshort
- importas
- ineffassign
- misspell
- nakedret
- nilerr
- nolintlint
- prealloc
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- varcheck
- whitespace
linters-settings:
ifshort:
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 50
importas:
no-unaliased: true
alias:
# Kubernetes
- pkg: k8s.io/api/core/v1
alias: corev1
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
- pkg: k8s.io/apimachinery/pkg/util/errors
alias: kerrors
# Controller Runtime
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
staticcheck:
go: "1.16"
stylecheck:
go: "1.16"
issues:
max-same-issues: 0
max-issues-per-linter: 0
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant
# changes in PRs and avoid nitpicking.
exclude-use-default: false
# List of regexps of issue texts to exclude, empty list by default.
exclude:
# The following are being worked on to remove their exclusion. This list should be reduced or go away all together over time.
# If it is decided they will not be addressed they should be moved above this comment.
- Subprocess launch(ed with variable|ing should be audited)
- (G204|G104|G307)
- "ST1000: at least one file in a package should have a package comment"
exclude-rules:
- linters:
- gosec
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
- linters:
- revive
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"
- linters:
- errcheck
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# With Go 1.16, the new embed directive can be used with an un-named import,
# revive (previously, golint) only allows these to be imported in a main.go, which wouldn't work for us.
# This directive allows the embed package to be imported with an underscore everywhere.
- linters:
- revive
source: _ "embed"
# Exclude some packages or code to require comments, for example test code, or fake clients.
- linters:
- revive
text: exported (method|function|type|const) (.+) should have comment or be unexported
source: (func|type).*Fake.*
- linters:
- revive
text: exported (method|function|type|const) (.+) should have comment or be unexported
path: fake_\.go
# Disable unparam "always receives" which might not be really
# useful when building libraries.
- linters:
- unparam
text: always receives
# Dot imports for gomega or ginkgo are allowed
# within test files.
- path: _test\.go
text: should not use dot imports
- path: _test\.go
text: cyclomatic complexity
- path: _test\.go
text: "G107: Potential HTTP request made with variable url"
# Append should be able to assign to a different var/slice.
- linters:
- gocritic
text: "appendAssign: append result not assigned to the same slice"
- linters:
- gocritic
text: "singleCaseSwitch: should rewrite switch statement to if statement"
run:
timeout: 10m
skip-files:
- "zz_generated.*\\.go$"
- ".*conversion.*\\.go$"
allow-parallel-runners: true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment