fix cron triggers
parent
9b498196f9
commit
abb9cec3cf
697
.golangci.yml
697
.golangci.yml
|
|
@ -16,16 +16,18 @@ run:
|
||||||
tests: true
|
tests: true
|
||||||
|
|
||||||
# list of build tags, all linters use it. Default is empty list.
|
# list of build tags, all linters use it. Default is empty list.
|
||||||
# build-tags:
|
build-tags:
|
||||||
# - mytag
|
- mytag
|
||||||
|
|
||||||
# which dirs to skip: issues from them won't be reported;
|
# which dirs to skip: issues from them won't be reported;
|
||||||
# can use regexp here: generated.*, regexp is applied on full path;
|
# can use regexp here: generated.*, regexp is applied on full path;
|
||||||
# default value is empty list, but default dirs are skipped independently
|
# default value is empty list, but default dirs are skipped independently
|
||||||
# from this option's value (see skip-dirs-use-default).
|
# from this option's value (see skip-dirs-use-default).
|
||||||
# skip-dirs:
|
# "/" will be replaced by current OS file path separator to properly work
|
||||||
# - src/external_libs
|
# on Windows.
|
||||||
# - autogenerated_by_my_lib
|
skip-dirs:
|
||||||
|
- src/external_libs
|
||||||
|
- autogenerated_by_my_lib
|
||||||
|
|
||||||
# default is true. Enables skipping of directories:
|
# default is true. Enables skipping of directories:
|
||||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||||
|
|
@ -35,9 +37,12 @@ run:
|
||||||
# won't be reported. Default value is empty list, but there is
|
# won't be reported. Default value is empty list, but there is
|
||||||
# no need to include all autogenerated files, we confidently recognize
|
# no need to include all autogenerated files, we confidently recognize
|
||||||
# autogenerated files. If it's not please let us know.
|
# autogenerated files. If it's not please let us know.
|
||||||
# skip-files:
|
# "/" will be replaced by current OS file path separator to properly work
|
||||||
# - ".*\\.my\\.go$"
|
# on Windows.
|
||||||
# - lib/bad.go
|
skip-files:
|
||||||
|
- ".*\\.my\\.go$"
|
||||||
|
- lib/bad.go
|
||||||
|
|
||||||
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
||||||
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
||||||
# automatic updating of go.mod described above. Instead, it fails when any changes
|
# automatic updating of go.mod described above. Instead, it fails when any changes
|
||||||
|
|
@ -46,11 +51,16 @@ run:
|
||||||
# If invoked with -mod=vendor, the go command assumes that the vendor
|
# If invoked with -mod=vendor, the go command assumes that the vendor
|
||||||
# directory holds the correct copies of dependencies and ignores
|
# directory holds the correct copies of dependencies and ignores
|
||||||
# the dependency descriptions in go.mod.
|
# the dependency descriptions in go.mod.
|
||||||
# modules-download-mode: readonly|release|vendor
|
# modules-download-mode: readonly|vendor|mod
|
||||||
|
|
||||||
|
# Allow multiple parallel golangci-lint instances running.
|
||||||
|
# If false (default) - golangci-lint acquires file lock on start.
|
||||||
|
allow-parallel-runners: false
|
||||||
|
|
||||||
# output configuration options
|
# output configuration options
|
||||||
output:
|
output:
|
||||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
|
||||||
|
# default is "colored-line-number"
|
||||||
format: colored-line-number
|
format: colored-line-number
|
||||||
|
|
||||||
# print lines of code with issue, default is true
|
# print lines of code with issue, default is true
|
||||||
|
|
@ -59,12 +69,37 @@ output:
|
||||||
# print linter name in the end of issue text, default is true
|
# print linter name in the end of issue text, default is true
|
||||||
print-linter-name: true
|
print-linter-name: true
|
||||||
|
|
||||||
|
# make issues output unique by line, default is true
|
||||||
|
uniq-by-line: true
|
||||||
|
|
||||||
|
# add a prefix to the output file references; default is no prefix
|
||||||
|
path-prefix: ""
|
||||||
|
|
||||||
|
# sorts results by: filepath, line and column
|
||||||
|
sort-results: false
|
||||||
|
|
||||||
# all available settings of specific linters
|
# all available settings of specific linters
|
||||||
linters-settings:
|
linters-settings:
|
||||||
|
cyclop:
|
||||||
|
# the maximal code complexity to report
|
||||||
|
max-complexity: 20
|
||||||
|
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
|
||||||
|
package-average: 0.0
|
||||||
|
# should ignore tests (default false)
|
||||||
|
skip-tests: false
|
||||||
|
|
||||||
|
dogsled:
|
||||||
|
# checks assignments with too many blank identifiers; default is 2
|
||||||
|
max-blank-identifiers: 2
|
||||||
|
|
||||||
|
dupl:
|
||||||
|
# tokens count to trigger issue, 150 by default
|
||||||
|
threshold: 100
|
||||||
|
|
||||||
errcheck:
|
errcheck:
|
||||||
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
|
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
|
||||||
# default is false: such cases aren't reported by default.
|
# default is false: such cases aren't reported by default.
|
||||||
check-type-assertions: true
|
check-type-assertions: false
|
||||||
|
|
||||||
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
|
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
|
||||||
# default is false: such cases aren't reported by default.
|
# default is false: such cases aren't reported by default.
|
||||||
|
|
@ -73,107 +108,69 @@ linters-settings:
|
||||||
# [deprecated] comma-separated list of pairs of the form pkg:regex
|
# [deprecated] comma-separated list of pairs of the form pkg:regex
|
||||||
# the regex is used to ignore names within pkg. (default "fmt:.*").
|
# the regex is used to ignore names within pkg. (default "fmt:.*").
|
||||||
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
|
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
|
||||||
# ignore: fmt:.*,io/ioutil:^Read.*
|
ignore: fmt:.*,io/ioutil:^Read.*
|
||||||
|
|
||||||
# path to a file containing a list of functions to exclude from checking
|
# path to a file containing a list of functions to exclude from checking
|
||||||
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
||||||
# exclude: /path/to/file.txt
|
# exclude: /path/to/file.txt
|
||||||
|
|
||||||
|
errorlint:
|
||||||
|
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
|
||||||
|
errorf: true
|
||||||
|
# Check for plain type assertions and type switches
|
||||||
|
asserts: true
|
||||||
|
# Check for plain error comparisons
|
||||||
|
comparison: true
|
||||||
|
|
||||||
|
exhaustive:
|
||||||
|
# check switch statements in generated files also
|
||||||
|
check-generated: false
|
||||||
|
# indicates that switch statements are to be considered exhaustive if a
|
||||||
|
# 'default' case is present, even if all enum members aren't listed in the
|
||||||
|
# switch
|
||||||
|
default-signifies-exhaustive: false
|
||||||
|
|
||||||
|
exhaustivestruct:
|
||||||
|
# Struct Patterns is list of expressions to match struct packages and names
|
||||||
|
# The struct packages have the form example.com/package.ExampleStruct
|
||||||
|
# The matching patterns can use matching syntax from https://pkg.go.dev/path#Match
|
||||||
|
# If this list is empty, all structs are tested.
|
||||||
|
struct-patterns:
|
||||||
|
- "*.Test"
|
||||||
|
- "example.com/package.ExampleStruct"
|
||||||
|
|
||||||
|
forbidigo:
|
||||||
|
# Forbid the following identifiers (identifiers are written using regexp):
|
||||||
|
forbid:
|
||||||
|
- ^print.*$
|
||||||
|
- 'fmt\.Print.*'
|
||||||
|
# Exclude godoc examples from forbidigo checks. Default is true.
|
||||||
|
exclude_godoc_examples: false
|
||||||
|
|
||||||
funlen:
|
funlen:
|
||||||
lines: 100
|
lines: 100
|
||||||
statements: 40
|
statements: 40
|
||||||
|
|
||||||
govet:
|
gci:
|
||||||
# report about shadowed variables
|
|
||||||
check-shadowing: true
|
|
||||||
|
|
||||||
# settings per analyzer
|
|
||||||
settings:
|
|
||||||
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
|
||||||
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
|
||||||
|
|
||||||
# enable or disable analyzers by name
|
|
||||||
enable:
|
|
||||||
- atomicalign
|
|
||||||
enable-all: false
|
|
||||||
disable:
|
|
||||||
# - shadow
|
|
||||||
disable-all: false
|
|
||||||
golint:
|
|
||||||
# minimal confidence for issues, default is 0.8
|
|
||||||
min-confidence: 0.8
|
|
||||||
gofmt:
|
|
||||||
# simplify code: gofmt with `-s` option, true by default
|
|
||||||
simplify: true
|
|
||||||
goimports:
|
|
||||||
# put imports beginning with prefix after 3rd-party packages;
|
# put imports beginning with prefix after 3rd-party packages;
|
||||||
# it's a comma-separated list of prefixes
|
# only support one prefix
|
||||||
|
# if not set, use goimports.local-prefixes
|
||||||
local-prefixes: github.com/org/project
|
local-prefixes: github.com/org/project
|
||||||
gocyclo:
|
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
|
||||||
min-complexity: 20
|
|
||||||
gocognit:
|
gocognit:
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
min-complexity: 20
|
min-complexity: 10
|
||||||
maligned:
|
|
||||||
# print struct with more effective memory layout or not, false by default
|
nestif:
|
||||||
suggest-new: true
|
# minimal complexity of if statements to report, 5 by default
|
||||||
dupl:
|
min-complexity: 4
|
||||||
# tokens count to trigger issue, 150 by default
|
|
||||||
threshold: 100
|
|
||||||
goconst:
|
goconst:
|
||||||
# minimal length of string constant, 3 by default
|
# minimal length of string constant, 3 by default
|
||||||
min-len: 3
|
min-len: 3
|
||||||
# minimal occurrences count to trigger, 3 by default
|
# minimal occurrences count to trigger, 3 by default
|
||||||
min-occurrences: 3
|
min-occurrences: 3
|
||||||
depguard:
|
|
||||||
list-type: blacklist
|
|
||||||
include-go-root: false
|
|
||||||
packages:
|
|
||||||
- github.com/sirupsen/logrus
|
|
||||||
packages-with-error-messages:
|
|
||||||
# specify an error message to output when a blacklisted package is used
|
|
||||||
github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
|
||||||
misspell:
|
|
||||||
# Correct spellings using locale preferences for US or UK.
|
|
||||||
# Default is to use a neutral variety of English.
|
|
||||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
|
||||||
locale: US
|
|
||||||
ignore-words:
|
|
||||||
- someword
|
|
||||||
lll:
|
|
||||||
# max line length, lines longer will be reported. Default is 120.
|
|
||||||
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
|
||||||
line-length: 120
|
|
||||||
# tab width in spaces. Default to 1.
|
|
||||||
tab-width: 1
|
|
||||||
unused:
|
|
||||||
# treat code as a program (not a library) and report unused exported identifiers; default is false.
|
|
||||||
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
|
|
||||||
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
|
|
||||||
# with golangci-lint call it on a directory with the changed file.
|
|
||||||
check-exported: false
|
|
||||||
unparam:
|
|
||||||
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
|
|
||||||
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
|
|
||||||
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
|
|
||||||
# with golangci-lint call it on a directory with the changed file.
|
|
||||||
check-exported: false
|
|
||||||
nakedret:
|
|
||||||
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
|
||||||
max-func-lines: 30
|
|
||||||
prealloc:
|
|
||||||
# XXX: we don't recommend using this linter before doing performance profiling.
|
|
||||||
# For most programs usage of prealloc will be a premature optimization.
|
|
||||||
|
|
||||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
|
||||||
# True by default.
|
|
||||||
simple: true
|
|
||||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
|
||||||
for-loops: false # Report preallocation suggestions on for loops, false by default
|
|
||||||
gocritic:
|
gocritic:
|
||||||
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
||||||
# See https://go-critic.github.io/overview#checks-overview
|
# See https://go-critic.github.io/overview#checks-overview
|
||||||
|
|
@ -190,12 +187,62 @@ linters-settings:
|
||||||
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
||||||
enabled-tags:
|
enabled-tags:
|
||||||
- performance
|
- performance
|
||||||
|
disabled-tags:
|
||||||
|
- experimental
|
||||||
|
|
||||||
settings: # settings passed to gocritic
|
# Settings passed to gocritic.
|
||||||
|
# The settings key is the name of a supported gocritic checker.
|
||||||
|
# The list of supported checkers can be find in https://go-critic.github.io/overview.
|
||||||
|
settings:
|
||||||
captLocal: # must be valid enabled check name
|
captLocal: # must be valid enabled check name
|
||||||
|
# whether to restrict checker to params only (default true)
|
||||||
paramsOnly: true
|
paramsOnly: true
|
||||||
|
elseif:
|
||||||
|
# whether to skip balanced if-else pairs (default true)
|
||||||
|
skipBalanced: true
|
||||||
|
hugeParam:
|
||||||
|
# size in bytes that makes the warning trigger (default 80)
|
||||||
|
sizeThreshold: 80
|
||||||
|
# nestingReduce:
|
||||||
|
# # min number of statements inside a branch to trigger a warning (default 5)
|
||||||
|
# bodyWidth: 5
|
||||||
|
rangeExprCopy:
|
||||||
|
# size in bytes that makes the warning trigger (default 512)
|
||||||
|
sizeThreshold: 512
|
||||||
|
# whether to check test functions (default true)
|
||||||
|
skipTestFuncs: true
|
||||||
rangeValCopy:
|
rangeValCopy:
|
||||||
|
# size in bytes that makes the warning trigger (default 128)
|
||||||
sizeThreshold: 32
|
sizeThreshold: 32
|
||||||
|
# whether to check test functions (default true)
|
||||||
|
skipTestFuncs: true
|
||||||
|
# ruleguard:
|
||||||
|
# path to a gorules file for the ruleguard checker
|
||||||
|
# rules: ""
|
||||||
|
# truncateCmp:
|
||||||
|
# # whether to skip int/uint/uintptr types (default true)
|
||||||
|
# skipArchDependent: true
|
||||||
|
underef:
|
||||||
|
# whether to skip (*x).method() calls where x is a pointer receiver (default true)
|
||||||
|
skipRecvDeref: true
|
||||||
|
# unnamedResult:
|
||||||
|
# # whether to check exported functions
|
||||||
|
# checkExported: true
|
||||||
|
|
||||||
|
gocyclo:
|
||||||
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
|
min-complexity: 20
|
||||||
|
|
||||||
|
godot:
|
||||||
|
# comments to be checked: `declarations`, `toplevel`, or `all`
|
||||||
|
scope: declarations
|
||||||
|
# list of regexps for excluding particular comment lines from check
|
||||||
|
exclude:
|
||||||
|
# example: exclude comments which contain numbers
|
||||||
|
# - '[0-9]+'
|
||||||
|
# check that each sentence starts with a capital letter
|
||||||
|
capital: false
|
||||||
|
|
||||||
godox:
|
godox:
|
||||||
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
||||||
# might be left in the code accidentally and should be resolved before merging
|
# might be left in the code accidentally and should be resolved before merging
|
||||||
|
|
@ -203,40 +250,432 @@ linters-settings:
|
||||||
- NOTE
|
- NOTE
|
||||||
- OPTIMIZE # marks code that should be optimized before merging
|
- OPTIMIZE # marks code that should be optimized before merging
|
||||||
- HACK # marks hack-arounds that should be removed before merging
|
- HACK # marks hack-arounds that should be removed before merging
|
||||||
dogsled:
|
|
||||||
# checks assignments with too many blank identifiers; default is 2
|
gofmt:
|
||||||
max-blank-identifiers: 2
|
# simplify code: gofmt with `-s` option, true by default
|
||||||
|
simplify: true
|
||||||
|
|
||||||
|
gofumpt:
|
||||||
|
# Choose whether or not to use the extra rules that are disabled
|
||||||
|
# by default
|
||||||
|
extra-rules: false
|
||||||
|
|
||||||
|
# goheader:
|
||||||
|
# values:
|
||||||
|
# const:
|
||||||
|
# define here const type values in format k:v, for example:
|
||||||
|
# COMPANY: MY COMPANY
|
||||||
|
# regexp:
|
||||||
|
# define here regexp type values, for example
|
||||||
|
# AUTHOR: .*@mycompany\.com
|
||||||
|
# template:# |-
|
||||||
|
# put here copyright header template for source code files, for example:
|
||||||
|
# Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time.
|
||||||
|
#
|
||||||
|
# {{ AUTHOR }} {{ COMPANY }} {{ YEAR }}
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
# template-path:
|
||||||
|
# also as alternative of directive 'template' you may put the path to file with the template source
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
# put imports beginning with prefix after 3rd-party packages;
|
||||||
|
# it's a comma-separated list of prefixes
|
||||||
|
local-prefixes: github.com/org/project
|
||||||
|
|
||||||
|
golint:
|
||||||
|
# minimal confidence for issues, default is 0.8
|
||||||
|
min-confidence: 0.8
|
||||||
|
|
||||||
|
gomnd:
|
||||||
|
settings:
|
||||||
|
mnd:
|
||||||
|
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
|
||||||
|
checks:
|
||||||
|
- argument
|
||||||
|
- case
|
||||||
|
- condition
|
||||||
|
- operation
|
||||||
|
- return
|
||||||
|
- assign
|
||||||
|
# ignored-numbers: 1000
|
||||||
|
# ignored-files: magic_.*.go
|
||||||
|
# ignored-functions: math.*
|
||||||
|
|
||||||
|
gomoddirectives:
|
||||||
|
# Allow local `replace` directives. Default is false.
|
||||||
|
replace-local: false
|
||||||
|
# List of allowed `replace` directives. Default is empty.
|
||||||
|
replace-allow-list:
|
||||||
|
- launchpad.net/gocheck
|
||||||
|
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
|
||||||
|
retract-allow-no-explanation: false
|
||||||
|
# Forbid the use of the `exclude` directives. Default is false.
|
||||||
|
exclude-forbidden: false
|
||||||
|
|
||||||
|
gomodguard:
|
||||||
|
# allowed:
|
||||||
|
# modules: # List of allowed modules
|
||||||
|
# - gopkg.in/yaml.v2
|
||||||
|
# domains:# List of allowed module domains
|
||||||
|
# - golang.org
|
||||||
|
# blocked:
|
||||||
|
# modules: # List of blocked modules
|
||||||
|
# - github.com/uudashr/go-module: # Blocked module
|
||||||
|
# recommendations: # Recommended modules that should be used instead (Optional)
|
||||||
|
# - golang.org/x/mod
|
||||||
|
# reason: "`mod` is the official go.mod parser library." # Reason why the recommended module should be used (Optional)
|
||||||
|
# versions:# List of blocked module version constraints
|
||||||
|
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
|
||||||
|
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
|
||||||
|
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
|
||||||
|
local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
|
||||||
|
|
||||||
|
gosec:
|
||||||
|
# To select a subset of rules to run.
|
||||||
|
# Available rules: https://github.com/securego/gosec#available-rules
|
||||||
|
includes:
|
||||||
|
- G401
|
||||||
|
- G306
|
||||||
|
- G101
|
||||||
|
# To specify a set of rules to explicitly exclude.
|
||||||
|
# Available rules: https://github.com/securego/gosec#available-rules
|
||||||
|
excludes:
|
||||||
|
- G204
|
||||||
|
# To specify the configuration of rules.
|
||||||
|
# The configuration of rules is not fully documented by gosec:
|
||||||
|
# https://github.com/securego/gosec#configuration
|
||||||
|
# https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102
|
||||||
|
config:
|
||||||
|
G306: "0600"
|
||||||
|
G101:
|
||||||
|
pattern: "(?i)example"
|
||||||
|
ignore_entropy: false
|
||||||
|
entropy_threshold: "80.0"
|
||||||
|
per_char_threshold: "3.0"
|
||||||
|
truncate: "32"
|
||||||
|
|
||||||
|
gosimple:
|
||||||
|
# Select the Go version to target. The default is '1.13'.
|
||||||
|
go: "1.15"
|
||||||
|
# https://staticcheck.io/docs/options#checks
|
||||||
|
checks: ["all"]
|
||||||
|
|
||||||
|
govet:
|
||||||
|
# report about shadowed variables
|
||||||
|
check-shadowing: true
|
||||||
|
|
||||||
|
# settings per analyzer
|
||||||
|
settings:
|
||||||
|
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
||||||
|
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||||
|
|
||||||
|
# enable or disable analyzers by name
|
||||||
|
# run `go tool vet help` to see all analyzers
|
||||||
|
# enable:
|
||||||
|
# - atomicalign
|
||||||
|
# enable-all: true
|
||||||
|
# disable:
|
||||||
|
# - shadow
|
||||||
|
# disable-all: false
|
||||||
|
|
||||||
|
depguard:
|
||||||
|
list-type: blacklist
|
||||||
|
include-go-root: false
|
||||||
|
packages:
|
||||||
|
- github.com/sirupsen/logrus
|
||||||
|
packages-with-error-message:
|
||||||
|
# specify an error message to output when a blacklisted package is used
|
||||||
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
|
|
||||||
|
ifshort:
|
||||||
|
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
|
||||||
|
# Has higher priority than max-decl-chars.
|
||||||
|
max-decl-lines: 1
|
||||||
|
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
|
||||||
|
max-decl-chars: 30
|
||||||
|
|
||||||
|
importas:
|
||||||
|
# if set to `true`, force to use alias.
|
||||||
|
no-unaliased: true
|
||||||
|
# List of aliases
|
||||||
|
alias:
|
||||||
|
# using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
|
||||||
|
- pkg: knative.dev/serving/pkg/apis/serving/v1
|
||||||
|
alias: servingv1
|
||||||
|
# using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
|
||||||
|
- pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
|
||||||
|
alias: autoscalingv1alpha1
|
||||||
|
# You can specify the package path by regular expression,
|
||||||
|
# and alias by regular expression expansion syntax like below.
|
||||||
|
# see https://github.com/julz/importas#use-regular-expression for details
|
||||||
|
- pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
|
||||||
|
alias: $1$2
|
||||||
|
|
||||||
|
lll:
|
||||||
|
# max line length, lines longer will be reported. Default is 120.
|
||||||
|
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
||||||
|
line-length: 120
|
||||||
|
# tab width in spaces. Default to 1.
|
||||||
|
tab-width: 1
|
||||||
|
|
||||||
|
makezero:
|
||||||
|
# Allow only slices initialized with a length of zero. Default is false.
|
||||||
|
always: false
|
||||||
|
|
||||||
|
maligned:
|
||||||
|
# print struct with more effective memory layout or not, false by default
|
||||||
|
suggest-new: true
|
||||||
|
|
||||||
|
misspell:
|
||||||
|
# Correct spellings using locale preferences for US or UK.
|
||||||
|
# Default is to use a neutral variety of English.
|
||||||
|
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||||
|
locale: US
|
||||||
|
ignore-words:
|
||||||
|
- someword
|
||||||
|
|
||||||
|
nakedret:
|
||||||
|
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
||||||
|
max-func-lines: 30
|
||||||
|
|
||||||
|
prealloc:
|
||||||
|
# XXX: we don't recommend using this linter before doing performance profiling.
|
||||||
|
# For most programs usage of prealloc will be a premature optimization.
|
||||||
|
|
||||||
|
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||||
|
# True by default.
|
||||||
|
simple: true
|
||||||
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
|
for-loops: false # Report preallocation suggestions on for loops, false by default
|
||||||
|
|
||||||
|
promlinter:
|
||||||
|
# Promlinter cannot infer all metrics name in static analysis.
|
||||||
|
# Enable strict mode will also include the errors caused by failing to parse the args.
|
||||||
|
strict: false
|
||||||
|
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
|
||||||
|
disabled-linters:
|
||||||
|
# - "Help"
|
||||||
|
# - "MetricUnits"
|
||||||
|
# - "Counter"
|
||||||
|
# - "HistogramSummaryReserved"
|
||||||
|
# - "MetricTypeInName"
|
||||||
|
# - "ReservedChars"
|
||||||
|
# - "CamelCase"
|
||||||
|
# - "lintUnitAbbreviations"
|
||||||
|
|
||||||
|
predeclared:
|
||||||
|
# comma-separated list of predeclared identifiers to not report on
|
||||||
|
ignore: ""
|
||||||
|
# include method names and field names (i.e., qualified names) in checks
|
||||||
|
q: false
|
||||||
|
|
||||||
|
nolintlint:
|
||||||
|
# Enable to ensure that nolint directives are all used. Default is true.
|
||||||
|
allow-unused: false
|
||||||
|
# Disable to ensure that nolint directives don't have a leading space. Default is true.
|
||||||
|
allow-leading-space: true
|
||||||
|
# Exclude following linters from requiring an explanation. Default is [].
|
||||||
|
allow-no-explanation: []
|
||||||
|
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
|
||||||
|
require-explanation: true
|
||||||
|
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
|
||||||
|
require-specific: true
|
||||||
|
|
||||||
|
rowserrcheck:
|
||||||
|
packages:
|
||||||
|
- github.com/jmoiron/sqlx
|
||||||
|
|
||||||
|
revive:
|
||||||
|
# see https://github.com/mgechev/revive#available-rules for details.
|
||||||
|
ignore-generated-header: true
|
||||||
|
severity: warning
|
||||||
|
rules:
|
||||||
|
- name: indent-error-flow
|
||||||
|
severity: warning
|
||||||
|
- name: add-constant
|
||||||
|
severity: warning
|
||||||
|
arguments:
|
||||||
|
- maxLitCount: "3"
|
||||||
|
allowStrs: '""'
|
||||||
|
allowInts: "0,1,2"
|
||||||
|
allowFloats: "0.0,0.,1.0,1.,2.0,2."
|
||||||
|
|
||||||
|
staticcheck:
|
||||||
|
# Select the Go version to target. The default is '1.13'.
|
||||||
|
go: "1.15"
|
||||||
|
# https://staticcheck.io/docs/options#checks
|
||||||
|
checks: ["all"]
|
||||||
|
|
||||||
|
stylecheck:
|
||||||
|
# Select the Go version to target. The default is '1.13'.
|
||||||
|
go: "1.15"
|
||||||
|
# https://staticcheck.io/docs/options#checks
|
||||||
|
checks:
|
||||||
|
["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"]
|
||||||
|
# https://staticcheck.io/docs/options#dot_import_whitelist
|
||||||
|
dot-import-whitelist:
|
||||||
|
- fmt
|
||||||
|
# https://staticcheck.io/docs/options#initialisms
|
||||||
|
initialisms:
|
||||||
|
[
|
||||||
|
"ACL",
|
||||||
|
"API",
|
||||||
|
"ASCII",
|
||||||
|
"CPU",
|
||||||
|
"CSS",
|
||||||
|
"DNS",
|
||||||
|
"EOF",
|
||||||
|
"GUID",
|
||||||
|
"HTML",
|
||||||
|
"HTTP",
|
||||||
|
"HTTPS",
|
||||||
|
"ID",
|
||||||
|
"IP",
|
||||||
|
"JSON",
|
||||||
|
"QPS",
|
||||||
|
"RAM",
|
||||||
|
"RPC",
|
||||||
|
"SLA",
|
||||||
|
"SMTP",
|
||||||
|
"SQL",
|
||||||
|
"SSH",
|
||||||
|
"TCP",
|
||||||
|
"TLS",
|
||||||
|
"TTL",
|
||||||
|
"UDP",
|
||||||
|
"UI",
|
||||||
|
"GID",
|
||||||
|
"UID",
|
||||||
|
"UUID",
|
||||||
|
"URI",
|
||||||
|
"URL",
|
||||||
|
"UTF8",
|
||||||
|
"VM",
|
||||||
|
"XML",
|
||||||
|
"XMPP",
|
||||||
|
"XSRF",
|
||||||
|
"XSS",
|
||||||
|
]
|
||||||
|
# https://staticcheck.io/docs/options#http_status_code_whitelist
|
||||||
|
http-status-code-whitelist: ["200", "400", "404", "500"]
|
||||||
|
|
||||||
|
tagliatelle:
|
||||||
|
# check the struck tag name case
|
||||||
|
case:
|
||||||
|
# use the struct field name to check the name of the struct tag
|
||||||
|
use-field-name: true
|
||||||
|
rules:
|
||||||
|
# any struct tag type can be used.
|
||||||
|
# support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
|
||||||
|
json: camel
|
||||||
|
yaml: camel
|
||||||
|
xml: camel
|
||||||
|
bson: camel
|
||||||
|
avro: snake
|
||||||
|
mapstructure: kebab
|
||||||
|
|
||||||
|
testpackage:
|
||||||
|
# regexp pattern to skip files
|
||||||
|
skip-regexp: (export|internal)_test\.go
|
||||||
|
|
||||||
|
thelper:
|
||||||
|
# The following configurations enable all checks. It can be omitted because all checks are enabled by default.
|
||||||
|
# You can enable only required checks deleting unnecessary checks.
|
||||||
|
test:
|
||||||
|
first: true
|
||||||
|
name: true
|
||||||
|
begin: true
|
||||||
|
benchmark:
|
||||||
|
first: true
|
||||||
|
name: true
|
||||||
|
begin: true
|
||||||
|
tb:
|
||||||
|
first: true
|
||||||
|
name: true
|
||||||
|
begin: true
|
||||||
|
|
||||||
|
unparam:
|
||||||
|
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
|
||||||
|
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
|
||||||
|
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
|
||||||
|
# with golangci-lint call it on a directory with the changed file.
|
||||||
|
check-exported: false
|
||||||
|
|
||||||
|
unused:
|
||||||
|
# Select the Go version to target. The default is '1.13'.
|
||||||
|
go: "1.15"
|
||||||
|
|
||||||
whitespace:
|
whitespace:
|
||||||
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
||||||
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
||||||
|
|
||||||
|
wrapcheck:
|
||||||
|
# An array of strings that specify substrings of signatures to ignore.
|
||||||
|
# If this set, it will override the default set of ignored signatures.
|
||||||
|
# See https://github.com/tomarrell/wrapcheck#configuration for more information.
|
||||||
|
ignoreSigs:
|
||||||
|
- .Errorf(
|
||||||
|
- errors.New(
|
||||||
|
- errors.Unwrap(
|
||||||
|
- .Wrap(
|
||||||
|
- .Wrapf(
|
||||||
|
- .WithMessage(
|
||||||
|
|
||||||
wsl:
|
wsl:
|
||||||
# If true append is only allowed to be cuddled if appending value is
|
# See https://github.com/bombsimon/wsl/blob/master/doc/configuration.md for
|
||||||
# matching variables, fields or types on line above. Default is true.
|
# documentation of available settings. These are the defaults for
|
||||||
strict-append: true
|
# `golangci-lint`.
|
||||||
# Allow calls and assignments to be cuddled as long as the lines have any
|
allow-assign-and-anything: false
|
||||||
# matching variables, fields or types. Default is true.
|
|
||||||
allow-assign-and-call: true
|
allow-assign-and-call: true
|
||||||
# Allow multiline assignments to be cuddled. Default is true.
|
|
||||||
allow-multiline-assign: true
|
|
||||||
# Allow declarations (var) to be cuddled.
|
|
||||||
allow-cuddle-declarations: false
|
allow-cuddle-declarations: false
|
||||||
# Allow trailing comments in ending of blocks
|
allow-multiline-assign: true
|
||||||
|
allow-separated-leading-comment: false
|
||||||
allow-trailing-comment: false
|
allow-trailing-comment: false
|
||||||
# Force newlines in end of case at this limit (0 = never).
|
|
||||||
force-case-trailing-whitespace: 0
|
force-case-trailing-whitespace: 0
|
||||||
|
force-err-cuddling: false
|
||||||
|
force-short-decl-cuddling: false
|
||||||
|
strict-append: true
|
||||||
|
|
||||||
|
# The custom section can be used to define linter plugins to be loaded at runtime.
|
||||||
|
# See README doc for more info.
|
||||||
|
# custom:
|
||||||
|
# # Each custom linter should have a unique name.
|
||||||
|
# example:
|
||||||
|
# # The path to the plugin *.so. Can be absolute or local. Required for each custom linter
|
||||||
|
# path: /path/to/example.so
|
||||||
|
# # The description of the linter. Optional, just for documentation purposes.
|
||||||
|
# description: This is an example usage of a plugin linter.
|
||||||
|
# # Intended to point to the repo location of the linter. Optional, just for documentation purposes.
|
||||||
|
# original-url: github.com/golangci/example-linter
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
|
# disable-all: true
|
||||||
enable:
|
enable:
|
||||||
- megacheck
|
- megacheck
|
||||||
- govet
|
- govet
|
||||||
- funlen
|
- funlen
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- maligned
|
# - fieldalignment
|
||||||
- prealloc
|
- prealloc
|
||||||
|
- typecheck
|
||||||
|
# enable-all: true
|
||||||
disable:
|
disable:
|
||||||
- gosec
|
- gosec
|
||||||
disable-all: false
|
# - maligned
|
||||||
|
# - prealloc
|
||||||
presets:
|
presets:
|
||||||
- bugs
|
- bugs
|
||||||
- unused
|
- unused
|
||||||
|
|
@ -286,6 +725,14 @@ issues:
|
||||||
# Default value for this option is true.
|
# Default value for this option is true.
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
|
|
||||||
|
# The default value is false. If set to true exclude and exclude-rules
|
||||||
|
# regular expressions become case sensitive.
|
||||||
|
exclude-case-sensitive: false
|
||||||
|
|
||||||
|
# The list of ids of default excludes to include or disable. By default it's empty.
|
||||||
|
include:
|
||||||
|
- EXC0002 # disable excluding of issues about comments from golint
|
||||||
|
|
||||||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
|
|
||||||
|
|
@ -299,7 +746,37 @@ issues:
|
||||||
# of integration: much better don't allow issues in new code.
|
# of integration: much better don't allow issues in new code.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
new: false
|
new: false
|
||||||
|
|
||||||
# Show only new issues created after git revision `REV`
|
# Show only new issues created after git revision `REV`
|
||||||
# new-from-rev: REV
|
# new-from-rev: REV
|
||||||
|
|
||||||
# Show only new issues created in git patch with set file path.
|
# Show only new issues created in git patch with set file path.
|
||||||
# new-from-patch: path/to/patch/file
|
# new-from-patch: path/to/patch/file
|
||||||
|
|
||||||
|
# Fix found issues (if it's supported by the linter)
|
||||||
|
fix: true
|
||||||
|
|
||||||
|
severity:
|
||||||
|
# Default value is empty string.
|
||||||
|
# Set the default severity for issues. If severity rules are defined and the issues
|
||||||
|
# do not match or no severity is provided to the rule this will be the default
|
||||||
|
# severity applied. Severities should match the supported severity names of the
|
||||||
|
# selected out format.
|
||||||
|
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
|
||||||
|
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
|
||||||
|
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
|
||||||
|
default-severity: error
|
||||||
|
|
||||||
|
# The default value is false.
|
||||||
|
# If set to true severity-rules regular expressions become case sensitive.
|
||||||
|
case-sensitive: false
|
||||||
|
|
||||||
|
# Default value is empty list.
|
||||||
|
# When a list of severity rules are provided, severity information will be added to lint
|
||||||
|
# issues. Severity rules have the same filtering capability as exclude rules except you
|
||||||
|
# are allowed to specify one matcher per severity rule.
|
||||||
|
# Only affects out formats that support setting severity information.
|
||||||
|
rules:
|
||||||
|
- linters:
|
||||||
|
- dupl
|
||||||
|
severity: info
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# The base image for building the k9s binary
|
# The base image for building the k9s binary
|
||||||
|
|
||||||
FROM golang:1.16.2-alpine3.13 AS build
|
FROM golang:1.16.5-alpine3.14.0 AS build
|
||||||
|
|
||||||
WORKDIR /k9s
|
WORKDIR /k9s
|
||||||
COPY go.mod go.sum main.go Makefile ./
|
COPY go.mod go.sum main.go Makefile ./
|
||||||
|
|
@ -12,8 +12,8 @@ RUN apk --no-cache add make git gcc libc-dev curl && make build
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Build the final Docker image
|
# Build the final Docker image
|
||||||
|
|
||||||
FROM alpine:3.13.2
|
FROM alpine:3.14.0
|
||||||
ARG KUBECTL_VERSION="v1.20.5"
|
ARG KUBECTL_VERSION="v1.21.2"
|
||||||
|
|
||||||
COPY --from=build /k9s/execs/k9s /bin/k9s
|
COPY --from=build /k9s/execs/k9s /bin/k9s
|
||||||
RUN apk add --update ca-certificates \
|
RUN apk add --update ca-certificates \
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func init() {
|
||||||
initK8sFlags()
|
initK8sFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute root command
|
// Execute root command.
|
||||||
func Execute() {
|
func Execute() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
log.Panic().Err(err)
|
log.Panic().Err(err)
|
||||||
|
|
|
||||||
15
go.mod
15
go.mod
|
|
@ -15,7 +15,6 @@ require (
|
||||||
github.com/derailed/popeye v0.9.0
|
github.com/derailed/popeye v0.9.0
|
||||||
github.com/derailed/tview v0.6.1
|
github.com/derailed/tview v0.6.1
|
||||||
github.com/drone/envsubst v1.0.2 // indirect
|
github.com/drone/envsubst v1.0.2 // indirect
|
||||||
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
|
|
||||||
github.com/fatih/color v1.10.0
|
github.com/fatih/color v1.10.0
|
||||||
github.com/fsnotify/fsnotify v1.4.9
|
github.com/fsnotify/fsnotify v1.4.9
|
||||||
github.com/fvbommel/sortorder v1.0.2
|
github.com/fvbommel/sortorder v1.0.2
|
||||||
|
|
@ -35,13 +34,13 @@ require (
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
golang.org/x/text v0.3.6
|
golang.org/x/text v0.3.6
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
helm.sh/helm/v3 v3.5.3
|
helm.sh/helm/v3 v3.6.1
|
||||||
k8s.io/api v0.20.5
|
k8s.io/api v0.21.2
|
||||||
k8s.io/apimachinery v0.20.5
|
k8s.io/apimachinery v0.21.2
|
||||||
k8s.io/cli-runtime v0.20.5
|
k8s.io/cli-runtime v0.21.2
|
||||||
k8s.io/client-go v0.20.5
|
k8s.io/client-go v0.21.2
|
||||||
k8s.io/klog/v2 v2.8.0
|
k8s.io/klog/v2 v2.8.0
|
||||||
k8s.io/kubectl v0.20.5
|
k8s.io/kubectl v0.21.2
|
||||||
k8s.io/metrics v0.20.5
|
k8s.io/metrics v0.21.2
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GVR represents a kubernetes resource schema as a string.
|
// GVR represents a kubernetes resource schema as a string.
|
||||||
// Format is group/version/resources:subresource
|
// Format is group/version/resources:subresource.
|
||||||
type GVR struct {
|
type GVR struct {
|
||||||
raw, g, v, r, sr string
|
raw, g, v, r, sr string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ func ToPercentage(v1, v2 int64) int {
|
||||||
return int(math.Floor((float64(v1) / float64(v2)) * 100))
|
return int(math.Floor((float64(v1) / float64(v2)) * 100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToPercentageStr computes percentage, but if v2 is 0, it will return NAValue instead of 0
|
// ToPercentageStr computes percentage, but if v2 is 0, it will return NAValue instead of 0.
|
||||||
func ToPercentageStr(v1, v2 int64) string {
|
func ToPercentageStr(v1, v2 int64) string {
|
||||||
if v2 == 0 {
|
if v2 == 0 {
|
||||||
return NA
|
return NA
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
mv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
|
||||||
v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -45,7 +44,7 @@ func TestToMB(t *testing.T) {
|
||||||
|
|
||||||
func TestPodsMetrics(t *testing.T) {
|
func TestPodsMetrics(t *testing.T) {
|
||||||
uu := map[string]struct {
|
uu := map[string]struct {
|
||||||
metrics *mv1beta1.PodMetricsList
|
metrics *v1beta1.PodMetricsList
|
||||||
eSize int
|
eSize int
|
||||||
e client.PodsMetrics
|
e client.PodsMetrics
|
||||||
}{
|
}{
|
||||||
|
|
@ -110,7 +109,7 @@ func BenchmarkPodsMetrics(b *testing.B) {
|
||||||
func TestNodesMetrics(t *testing.T) {
|
func TestNodesMetrics(t *testing.T) {
|
||||||
uu := map[string]struct {
|
uu := map[string]struct {
|
||||||
nodes *v1.NodeList
|
nodes *v1.NodeList
|
||||||
metrics *mv1beta1.NodeMetricsList
|
metrics *v1beta1.NodeMetricsList
|
||||||
eSize int
|
eSize int
|
||||||
e client.NodesMetrics
|
e client.NodesMetrics
|
||||||
}{
|
}{
|
||||||
|
|
@ -212,7 +211,7 @@ func BenchmarkNodesMetrics(b *testing.B) {
|
||||||
func TestClusterLoad(t *testing.T) {
|
func TestClusterLoad(t *testing.T) {
|
||||||
uu := map[string]struct {
|
uu := map[string]struct {
|
||||||
nodes *v1.NodeList
|
nodes *v1.NodeList
|
||||||
metrics *mv1beta1.NodeMetricsList
|
metrics *v1beta1.NodeMetricsList
|
||||||
eSize int
|
eSize int
|
||||||
e client.ClusterMetrics
|
e client.ClusterMetrics
|
||||||
}{
|
}{
|
||||||
|
|
@ -279,8 +278,8 @@ func BenchmarkClusterLoad(b *testing.B) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics := mv1beta1.NodeMetricsList{
|
metrics := v1beta1.NodeMetricsList{
|
||||||
Items: []mv1beta1.NodeMetrics{
|
Items: []v1beta1.NodeMetrics{
|
||||||
*makeMxNode("n1", "50m", "1Mi"),
|
*makeMxNode("n1", "50m", "1Mi"),
|
||||||
*makeMxNode("n2", "50m", "1Mi"),
|
*makeMxNode("n2", "50m", "1Mi"),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NA Not available
|
// NA Not available.
|
||||||
NA = "n/a"
|
NA = "n/a"
|
||||||
|
|
||||||
// NamespaceAll designates the fictional all namespace.
|
// NamespaceAll designates the fictional all namespace.
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ func (a *Aliases) ShortNames() ShortNames {
|
||||||
|
|
||||||
m := make(ShortNames, len(a.Alias))
|
m := make(ShortNames, len(a.Alias))
|
||||||
for alias, gvr := range a.Alias {
|
for alias, gvr := range a.Alias {
|
||||||
if _, ok := m[gvr]; ok {
|
if v, ok := m[gvr]; ok {
|
||||||
m[gvr] = append(m[gvr], alias)
|
m[gvr] = append(v, alias)
|
||||||
} else {
|
} else {
|
||||||
m[gvr] = []string{alias}
|
m[gvr] = []string{alias}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type (
|
||||||
Containers map[string]BenchConfig `yam':"containers"`
|
Containers map[string]BenchConfig `yam':"containers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auth basic auth creds
|
// Auth basic auth creds.
|
||||||
Auth struct {
|
Auth struct {
|
||||||
User string `yaml:"user"`
|
User string `yaml:"user"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
|
|
@ -71,7 +71,7 @@ func newBenchmark() Benchmark {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty checks if the benchmark is set
|
// Empty checks if the benchmark is set.
|
||||||
func (b Benchmark) Empty() bool {
|
func (b Benchmark) Empty() bool {
|
||||||
return b.C == 0 && b.N == 0
|
return b.C == 0 && b.N == 0
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ func (s *Bench) Reload(path string) error {
|
||||||
return s.load(path)
|
return s.load(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load K9s benchmark configs from file
|
// Load K9s benchmark configs from file.
|
||||||
func (s *Bench) load(path string) error {
|
func (s *Bench) load(path string) error {
|
||||||
f, err := ioutil.ReadFile(path)
|
f, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ func (c *Config) ActiveView() string {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetActiveView set the currently cluster active view
|
// SetActiveView set the currently cluster active view.
|
||||||
func (c *Config) SetActiveView(view string) {
|
func (c *Config) SetActiveView(view string) {
|
||||||
cl := c.K9s.ActiveCluster()
|
cl := c.K9s.ActiveCluster()
|
||||||
if cl != nil {
|
if cl != nil {
|
||||||
|
|
@ -210,7 +210,7 @@ func (c *Config) SetConnection(conn client.Connection) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load K9s configuration from file
|
// Load K9s configuration from file.
|
||||||
func (c *Config) Load(path string) error {
|
func (c *Config) Load(path string) error {
|
||||||
f, err := ioutil.ReadFile(path)
|
f, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ const (
|
||||||
DefaultSinceSeconds = 60 // all logs
|
DefaultSinceSeconds = 60 // all logs
|
||||||
)
|
)
|
||||||
|
|
||||||
// Logger tracks logger options
|
// Logger tracks logger options.
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
TailCount int64 `yaml:"tail"`
|
TailCount int64 `yaml:"tail"`
|
||||||
BufferSize int `yaml:"buffer"`
|
BufferSize int `yaml:"buffer"`
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func NewNamespace() *Namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate a namespace is setup correctly
|
// Validate a namespace is setup correctly.
|
||||||
func (n *Namespace) Validate(c client.Connection, ks KubeSettings) {
|
func (n *Namespace) Validate(c client.Connection, ks KubeSettings) {
|
||||||
nns, err := c.ValidNamespaces()
|
nns, err := c.ValidNamespaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ type Plugins struct {
|
||||||
Plugin map[string]Plugin `yaml:"plugin"`
|
Plugin map[string]Plugin `yaml:"plugin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin describes a K9s plugin
|
// Plugin describes a K9s plugin.
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
Scopes []string `yaml:"scopes"`
|
Scopes []string `yaml:"scopes"`
|
||||||
Args []string `yaml:"args"`
|
Args []string `yaml:"args"`
|
||||||
|
|
|
||||||
|
|
@ -436,7 +436,7 @@ func (s *Styles) Reset() {
|
||||||
s.K9s = newStyle()
|
s.K9s = newStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSkin loads the default skin
|
// DefaultSkin loads the default skin.
|
||||||
func (s *Styles) DefaultSkin() {
|
func (s *Styles) DefaultSkin() {
|
||||||
s.K9s = newStyle()
|
s.K9s = newStyle()
|
||||||
}
|
}
|
||||||
|
|
@ -522,7 +522,7 @@ func (s *Styles) Views() Views {
|
||||||
return s.K9s.Views
|
return s.K9s.Views
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load K9s configuration from file
|
// Load K9s configuration from file.
|
||||||
func (s *Styles) Load(path string) error {
|
func (s *Styles) Load(path string) error {
|
||||||
f, err := ioutil.ReadFile(path)
|
f, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -532,7 +532,7 @@ func (s *Styles) Load(path string) error {
|
||||||
if err := yaml.Unmarshal(f, s); err != nil {
|
if err := yaml.Unmarshal(f, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//s.fireStylesChanged()
|
// s.fireStylesChanged()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func NewThreshold() Threshold {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate a namespace is setup correctly
|
// Validate a namespace is setup correctly.
|
||||||
func (t Threshold) Validate(c client.Connection, ks KubeSettings) {
|
func (t Threshold) Validate(c client.Connection, ks KubeSettings) {
|
||||||
for _, k := range []string{"cpu", "memory"} {
|
for _, k := range []string{"cpu", "memory"} {
|
||||||
v, ok := t[k]
|
v, ok := t[k]
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ func (v *CustomView) AddListener(gvr string, l ViewConfigListener) {
|
||||||
// RemoveListener unregister a listener.
|
// RemoveListener unregister a listener.
|
||||||
func (v *CustomView) RemoveListener(gvr string) {
|
func (v *CustomView) RemoveListener(gvr string) {
|
||||||
delete(v.listeners, gvr)
|
delete(v.listeners, gvr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *CustomView) fireConfigChanged() {
|
func (v *CustomView) fireConfigChanged() {
|
||||||
|
|
|
||||||
|
|
@ -51,15 +51,19 @@ var _ dao.Factory = testFactory{}
|
||||||
func (f testFactory) Client() client.Connection {
|
func (f testFactory) Client() client.Connection {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func (c *Container) List(ctx context.Context, _ string) ([]runtime.Object, error
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TailLogs tails a given container logs
|
// TailLogs tails a given container logs.
|
||||||
func (c *Container) TailLogs(ctx context.Context, logChan LogChan, opts *LogOptions) error {
|
func (c *Container) TailLogs(ctx context.Context, logChan LogChan, opts *LogOptions) error {
|
||||||
po := Pod{}
|
po := Pod{}
|
||||||
po.Init(c.Factory, client.NewGVR("v1/pods"))
|
po.Init(c.Factory, client.NewGVR("v1/pods"))
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ var _ dao.Factory = testFactory{}
|
||||||
func (f podFactory) Client() client.Connection {
|
func (f podFactory) Client() client.Connection {
|
||||||
return makeConn()
|
return makeConn()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f podFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
func (f podFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := yaml.Unmarshal([]byte(poYaml()), &m); err != nil {
|
if err := yaml.Unmarshal([]byte(poYaml()), &m); err != nil {
|
||||||
|
|
@ -79,6 +80,7 @@ func (f podFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runti
|
||||||
}
|
}
|
||||||
return &unstructured.Unstructured{Object: m}, nil
|
return &unstructured.Unstructured{Object: m}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f podFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
func (f podFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
batchv1 "k8s.io/api/batch/v1"
|
batchv1 "k8s.io/api/batch/v1"
|
||||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
|
@ -47,12 +46,12 @@ func (c *CronJob) Run(path string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("expecting CronJob resource")
|
return errors.New("expecting CronJob resource")
|
||||||
}
|
}
|
||||||
var jobName = cj.Name
|
jobName := cj.Name
|
||||||
if len(cj.Name) >= maxJobNameSize {
|
if len(cj.Name) >= maxJobNameSize {
|
||||||
jobName = cj.Name[0:maxJobNameSize]
|
jobName = cj.Name[0:maxJobNameSize]
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +94,7 @@ func (c *CronJob) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, erro
|
||||||
|
|
||||||
refs := make(Refs, 0, len(oo))
|
refs := make(Refs, 0, len(oo))
|
||||||
for _, o := range oo {
|
for _, o := range oo {
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("expecting CronJob resource")
|
return nil, errors.New("expecting CronJob resource")
|
||||||
|
|
@ -127,7 +126,7 @@ func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("expecting CronJob resource")
|
return errors.New("expecting CronJob resource")
|
||||||
|
|
@ -144,7 +143,7 @@ func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
||||||
true := true
|
true := true
|
||||||
cj.Spec.Suspend = &true
|
cj.Spec.Suspend = &true
|
||||||
}
|
}
|
||||||
_, err = dial.BatchV1beta1().CronJobs(ns).Update(ctx, &cj, metav1.UpdateOptions{})
|
_, err = dial.BatchV1().CronJobs(ns).Update(ctx, &cj, metav1.UpdateOptions{})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +158,7 @@ func (c *CronJob) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, e
|
||||||
|
|
||||||
refs := make(Refs, 0, len(oo))
|
refs := make(Refs, 0, len(oo))
|
||||||
for _, o := range oo {
|
for _, o := range oo {
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("expecting CronJob resource")
|
return nil, errors.New("expecting CronJob resource")
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal"
|
"github.com/derailed/k9s/internal"
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ func (l *LogItems) Render(showTime bool, ll [][]byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpDebug for debugging
|
// DumpDebug for debugging.
|
||||||
func (l *LogItems) DumpDebug(m string) {
|
func (l *LogItems) DumpDebug(m string) {
|
||||||
fmt.Println(m + strings.Repeat("-", 50))
|
fmt.Println(m + strings.Repeat("-", 50))
|
||||||
for i, line := range l.items {
|
for i, line := range l.items {
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ func (n *Node) Get(ctx context.Context, path string) (runtime.Object, error) {
|
||||||
|
|
||||||
// List returns a collection of node resources.
|
// List returns a collection of node resources.
|
||||||
func (n *Node) List(ctx context.Context, ns string) ([]runtime.Object, error) {
|
func (n *Node) List(ctx context.Context, ns string) ([]runtime.Object, error) {
|
||||||
|
|
||||||
oo, err := n.Resource.List(ctx, ns)
|
oo, err := n.Resource.List(ctx, ns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return oo, err
|
return oo, err
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func (f *OpenFaas) Describe(path string) (string, error) {
|
||||||
return string(bytes), nil
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOZO!! Meow! openfaas fn prints to stdout have to dup ;(
|
// BOZO!! Meow! openfaas fn prints to stdout have to dup ;(.
|
||||||
func deleteFunctionToken(gateway string, functionName string, tlsInsecure bool, token string, namespace string) error {
|
func deleteFunctionToken(gateway string, functionName string, tlsInsecure bool, token string, namespace string) error {
|
||||||
defaultCommandTimeout := 60 * time.Second
|
defaultCommandTimeout := 60 * time.Second
|
||||||
|
|
||||||
|
|
@ -158,7 +158,7 @@ func deleteFunctionToken(gateway string, functionName string, tlsInsecure bool,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("DELETE", deleteEndpoint, reader)
|
req, err := http.NewRequestWithContext(context.Background(), "DELETE", deleteEndpoint, reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ type Element struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTemplateJsonPatch builds a json patch string to update PodSpec images
|
// GetTemplateJsonPatch builds a json patch string to update PodSpec images.
|
||||||
func GetTemplateJsonPatch(imageSpecs ImageSpecs) ([]byte, error) {
|
func GetTemplateJsonPatch(imageSpecs ImageSpecs) ([]byte, error) {
|
||||||
jsonPatch := JsonPatch{
|
jsonPatch := JsonPatch{
|
||||||
Spec: Spec{
|
Spec: Spec{
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ func (p *Pod) Logs(path string, opts *v1.PodLogOptions) (*restclient.Request, er
|
||||||
return dial.CoreV1().Pods(ns).GetLogs(n, opts), nil
|
return dial.CoreV1().Pods(ns).GetLogs(n, opts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Containers returns all container names on pod
|
// Containers returns all container names on pod.
|
||||||
func (p *Pod) Containers(path string, includeInit bool) ([]string, error) {
|
func (p *Pod) Containers(path string, includeInit bool) ([]string, error) {
|
||||||
pod, err := p.GetInstance(path)
|
pod, err := p.GetInstance(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -176,7 +176,7 @@ func (p *Pod) GetInstance(fqn string) (*v1.Pod, error) {
|
||||||
return &pod, nil
|
return &pod, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TailLogs tails a given container logs
|
// TailLogs tails a given container logs.
|
||||||
func (p *Pod) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error {
|
func (p *Pod) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error {
|
||||||
log.Debug().Msgf("TAIL-LOGS for %q:%q", opts.Path, opts.Container)
|
log.Debug().Msgf("TAIL-LOGS for %q:%q", opts.Path, opts.Container)
|
||||||
fac, ok := ctx.Value(internal.KeyFactory).(*watch.Factory)
|
fac, ok := ctx.Value(internal.KeyFactory).(*watch.Factory)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ func TestGetDefaultLogContainer(t *testing.T) {
|
||||||
"container_found": {
|
"container_found": {
|
||||||
po: &v1.Pod{
|
po: &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Annotations: map[string]string{"kubectl.kubernetes.io/default-logs-container": "container1"}},
|
Annotations: map[string]string{"kubectl.kubernetes.io/default-logs-container": "container1"},
|
||||||
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
Containers: []v1.Container{{Name: "container1"}},
|
Containers: []v1.Container{{Name: "container1"}},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ var _ types.Factory = (*popFactory)(nil)
|
||||||
func newPopeyeFactory(f Factory) *popFactory {
|
func newPopeyeFactory(f Factory) *popFactory {
|
||||||
return &popFactory{Factory: f}
|
return &popFactory{Factory: f}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *popFactory) Client() types.Connection {
|
func (p *popFactory) Client() types.Connection {
|
||||||
return &popeyeConnection{Connection: p.Factory.Client()}
|
return &popeyeConnection{Connection: p.Factory.Client()}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func (p *PortForward) List(ctx context.Context, _ string) ([]runtime.Object, err
|
||||||
|
|
||||||
var podNameRX = regexp.MustCompile(`\A(.+)\-(\w{10})\-(\w{5})\z`)
|
var podNameRX = regexp.MustCompile(`\A(.+)\-(\w{10})\-(\w{5})\z`)
|
||||||
|
|
||||||
// PodToKey converts a pod path to a generic bench config key
|
// PodToKey converts a pod path to a generic bench config key.
|
||||||
func PodToKey(path string) string {
|
func PodToKey(path string) string {
|
||||||
tokens := strings.Split(path, ":")
|
tokens := strings.Split(path, ":")
|
||||||
ns, po := client.Namespaced(tokens[0])
|
ns, po := client.Namespaced(tokens[0])
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ func (p *PortForwarder) Container() string {
|
||||||
return p.container
|
return p.container
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop terminates a port forward
|
// Stop terminates a port forward.
|
||||||
func (p *PortForwarder) Stop() {
|
func (p *PortForwarder) Stop() {
|
||||||
log.Debug().Msgf("<<< Stopping PortForward %q %v", p.path, p.ports)
|
log.Debug().Msgf("<<< Stopping PortForward %q %v", p.path, p.ports)
|
||||||
p.active = false
|
p.active = false
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"k8s.io/client-go/restmapper"
|
"k8s.io/client-go/restmapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RestMapping holds k8s resource mapping
|
// RestMapping holds k8s resource mapping.
|
||||||
var RestMapping = &RestMapper{}
|
var RestMapping = &RestMapper{}
|
||||||
|
|
||||||
// RestMapper map resource to REST mapping ie kind, group, version.
|
// RestMapper map resource to REST mapping ie kind, group, version.
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ func (r *ReplicaSet) Rollback(fqn string) error {
|
||||||
|
|
||||||
rb, err := polymorphichelpers.RollbackerFor(schema.GroupKind{
|
rb, err := polymorphichelpers.RollbackerFor(schema.GroupKind{
|
||||||
Group: apiGroup,
|
Group: apiGroup,
|
||||||
Kind: kind},
|
Kind: kind,
|
||||||
|
},
|
||||||
dial,
|
dial,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// BufferKind indicates a buffer type
|
// BufferKind indicates a buffer type.
|
||||||
BufferKind int8
|
BufferKind int8
|
||||||
|
|
||||||
// BuffWatcher represents a command buffer listener.
|
// BuffWatcher represents a command buffer listener.
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ func (d *Describe) fireResourceFailed(err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearFilter clear out the filter
|
// ClearFilter clear out the filter.
|
||||||
func (d *Describe) ClearFilter() {
|
func (d *Describe) ClearFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,6 +141,7 @@ func (d *Describe) updater(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Describe) refresh(ctx context.Context) error {
|
func (d *Describe) refresh(ctx context.Context) error {
|
||||||
if !atomic.CompareAndSwapInt32(&d.inUpdate, 0, 1) {
|
if !atomic.CompareAndSwapInt32(&d.inUpdate, 0, 1) {
|
||||||
log.Debug().Msgf("Dropping update...")
|
log.Debug().Msgf("Dropping update...")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MaxHistory tracks max command history
|
// MaxHistory tracks max command history.
|
||||||
const MaxHistory = 20
|
const MaxHistory = 20
|
||||||
|
|
||||||
// History represents a command history.
|
// History represents a command history.
|
||||||
|
|
|
||||||
|
|
@ -249,10 +249,12 @@ func (t *testView) LogChanged(ll [][]byte) {
|
||||||
t.data = ll
|
t.data = ll
|
||||||
t.dataCalled++
|
t.dataCalled++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testView) LogCleared() {
|
func (t *testView) LogCleared() {
|
||||||
t.clearCalled++
|
t.clearCalled++
|
||||||
t.data = nil
|
t.data = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testView) LogFailed(err error) {
|
func (t *testView) LogFailed(err error) {
|
||||||
fmt.Println("LogErr", err)
|
fmt.Println("LogErr", err)
|
||||||
t.errCalled++
|
t.errCalled++
|
||||||
|
|
@ -267,15 +269,19 @@ var _ dao.Factory = testFactory{}
|
||||||
func (f testFactory) Client() client.Connection {
|
func (f testFactory) Client() client.Connection {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func (m MenuHint) String() string {
|
||||||
// MenuHints represents a collection of hints.
|
// MenuHints represents a collection of hints.
|
||||||
type MenuHints []MenuHint
|
type MenuHints []MenuHint
|
||||||
|
|
||||||
// Len returns the hints length
|
// Len returns the hints length.
|
||||||
func (h MenuHints) Len() int {
|
func (h MenuHints) Len() int {
|
||||||
return len(h)
|
return len(h)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Registry tracks resources metadata.
|
// Registry tracks resources metadata.
|
||||||
// BOZO!! Break up deps and merge into single registrar
|
// BOZO!! Break up deps and merge into single registrar.
|
||||||
var Registry = map[string]ResourceMeta{
|
var Registry = map[string]ResourceMeta{
|
||||||
// Custom...
|
// Custom...
|
||||||
"references": {
|
"references": {
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,7 @@ type stackL struct {
|
||||||
func (s *stackL) StackPushed(model.Component) {
|
func (s *stackL) StackPushed(model.Component) {
|
||||||
s.count++
|
s.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stackL) StackPopped(c, top model.Component) {
|
func (s *stackL) StackPopped(c, top model.Component) {
|
||||||
s.count--
|
s.count--
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal"
|
"github.com/derailed/k9s/internal"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
"github.com/derailed/k9s/internal/dao"
|
"github.com/derailed/k9s/internal/dao"
|
||||||
"github.com/derailed/k9s/internal/render"
|
"github.com/derailed/k9s/internal/render"
|
||||||
|
|
@ -181,21 +180,25 @@ var _ dao.Factory = testFactory{}
|
||||||
func (f testFactory) Client() client.Connection {
|
func (f testFactory) Client() client.Connection {
|
||||||
return client.NewTestAPIClient()
|
return client.NewTestAPIClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
func (f testFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
||||||
if len(f.rows) > 0 {
|
if len(f.rows) > 0 {
|
||||||
return f.rows[0], nil
|
return f.rows[0], nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
func (f testFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
||||||
if len(f.rows) > 0 {
|
if len(f.rows) > 0 {
|
||||||
return f.rows, nil
|
return f.rows, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
func (f testFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
func (f testFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -224,6 +227,7 @@ func (a *accessor) Get(ctx context.Context, path string) (runtime.Object, error)
|
||||||
func (a *accessor) Init(_ dao.Factory, gvr client.GVR) {
|
func (a *accessor) Init(_ dao.Factory, gvr client.GVR) {
|
||||||
a.gvr = gvr
|
a.gvr = gvr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accessor) GVR() string {
|
func (a *accessor) GVR() string {
|
||||||
return a.gvr.String()
|
return a.gvr.String()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ type tableListener struct {
|
||||||
func (l *tableListener) TableDataChanged(render.TableData) {
|
func (l *tableListener) TableDataChanged(render.TableData) {
|
||||||
l.count++
|
l.count++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *tableListener) TableLoadFailed(error) {
|
func (l *tableListener) TableLoadFailed(error) {
|
||||||
l.errs++
|
l.errs++
|
||||||
}
|
}
|
||||||
|
|
@ -88,21 +89,25 @@ var _ dao.Factory = tableFactory{}
|
||||||
func (f tableFactory) Client() client.Connection {
|
func (f tableFactory) Client() client.Connection {
|
||||||
return client.NewTestAPIClient()
|
return client.NewTestAPIClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f tableFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
func (f tableFactory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error) {
|
||||||
if len(f.rows) > 0 {
|
if len(f.rows) > 0 {
|
||||||
return f.rows[0], nil
|
return f.rows[0], nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f tableFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
func (f tableFactory) List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error) {
|
||||||
if len(f.rows) > 0 {
|
if len(f.rows) > 0 {
|
||||||
return f.rows, nil
|
return f.rows, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f tableFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
func (f tableFactory) ForResource(ns, gvr string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f tableFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
func (f tableFactory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ type Commander interface {
|
||||||
InCmdMode() bool
|
InCmdMode() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component represents a ui component
|
// Component represents a ui component.
|
||||||
type Component interface {
|
type Component interface {
|
||||||
Primitive
|
Primitive
|
||||||
Igniter
|
Igniter
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func (y *YAML) Peek() []string {
|
||||||
return y.lines
|
return y.lines
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh updates model data
|
// Refresh updates model data.
|
||||||
func (y *YAML) Refresh(ctx context.Context) error {
|
func (y *YAML) Refresh(ctx context.Context) error {
|
||||||
return y.refresh(ctx)
|
return y.refresh(ctx)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// BOZO!! Revisit bench and when we should timeout
|
// BOZO!! Revisit bench and when we should timeout.
|
||||||
benchTimeout = 2 * time.Minute
|
benchTimeout = 2 * time.Minute
|
||||||
benchFmat = "%s_%s_%d.txt"
|
benchFmat = "%s_%s_%d.txt"
|
||||||
k9sUA = "k9s/"
|
k9sUA = "k9s/"
|
||||||
|
|
@ -104,7 +104,7 @@ func (b *Benchmark) Canceled() bool {
|
||||||
return b.canceled
|
return b.canceled
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts a benchmark,
|
// Run starts a benchmark,.
|
||||||
func (b *Benchmark) Run(cluster string, done func()) {
|
func (b *Benchmark) Run(cluster string, done func()) {
|
||||||
log.Debug().Msgf("Running benchmark on cluster %s", cluster)
|
log.Debug().Msgf("Running benchmark on cluster %s", cluster)
|
||||||
buff := new(bytes.Buffer)
|
buff := new(bytes.Buffer)
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,13 @@ func TestAliasColorer(t *testing.T) {
|
||||||
"addAll": {
|
"addAll": {
|
||||||
ns: client.AllNamespaces,
|
ns: client.AllNamespaces,
|
||||||
re: render.RowEvent{Kind: render.EventAdd, Row: r},
|
re: render.RowEvent{Kind: render.EventAdd, Row: r},
|
||||||
e: tcell.ColorBlue},
|
e: tcell.ColorBlue,
|
||||||
|
},
|
||||||
"deleteAll": {
|
"deleteAll": {
|
||||||
ns: client.AllNamespaces,
|
ns: client.AllNamespaces,
|
||||||
re: render.RowEvent{Kind: render.EventDelete, Row: r},
|
re: render.RowEvent{Kind: render.EventDelete, Row: r},
|
||||||
e: tcell.ColorGray},
|
e: tcell.ColorGray,
|
||||||
|
},
|
||||||
"updateAll": {
|
"updateAll": {
|
||||||
ns: client.AllNamespaces,
|
ns: client.AllNamespaces,
|
||||||
re: render.RowEvent{Kind: render.EventUpdate, Row: r},
|
re: render.RowEvent{Kind: render.EventUpdate, Row: r},
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func (b Benchmark) Render(o interface{}, ns string, r *Row) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (Benchmark) diagnose(ns string, ff Fields) error {
|
func (Benchmark) diagnose(ns string, ff Fields) error {
|
||||||
statusCol := 3
|
statusCol := 3
|
||||||
if !client.IsAllNamespaces(ns) {
|
if !client.IsAllNamespaces(ns) {
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ func (c Container) Render(o interface{}, name string, r *Row) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (Container) diagnose(state, ready string) error {
|
func (Container) diagnose(state, ready string) error {
|
||||||
if state == "Completed" {
|
if state == "Completed" {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ func BenchmarkContainerRender(b *testing.B) {
|
||||||
func toQty(s string) resource.Quantity {
|
func toQty(s string) resource.Quantity {
|
||||||
q, _ := resource.ParseQuantity(s)
|
q, _ := resource.ParseQuantity(s)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeContainerMetrics() *mv1beta1.ContainerMetrics {
|
func makeContainerMetrics() *mv1beta1.ContainerMetrics {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
batchv1 "k8s.io/api/batch/v1"
|
batchv1 "k8s.io/api/batch/v1"
|
||||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
@ -45,7 +44,7 @@ func (c CronJob) Render(o interface{}, ns string, r *Row) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Expected CronJob, but got %T", o)
|
return fmt.Errorf("Expected CronJob, but got %T", o)
|
||||||
}
|
}
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err := runtime.DefaultUnstructuredConverter.FromUnstructured(raw.Object, &cj)
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(raw.Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func (d DaemonSet) Render(o interface{}, ns string, r *Row) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (DaemonSet) diagnose(d, r int32) error {
|
func (DaemonSet) diagnose(d, r int32) error {
|
||||||
if d != r {
|
if d != r {
|
||||||
return fmt.Errorf("desiring %d replicas but %d ready", d, r)
|
return fmt.Errorf("desiring %d replicas but %d ready", d, r)
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ func (e Event) Render(o interface{}, ns string, r *Row) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (Event) diagnose(kind string) error {
|
func (Event) diagnose(kind string) error {
|
||||||
if kind != "Normal" {
|
if kind != "Normal" {
|
||||||
return errors.New("failed event")
|
return errors.New("failed event")
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ type Generic struct {
|
||||||
ageIndex int
|
ageIndex int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (Generic) Happy(ns string, r Row) bool {
|
func (Generic) Happy(ns string, r Row) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
const ageCol = "AGE"
|
const ageCol = "AGE"
|
||||||
|
|
||||||
// HeaderColumn represent a table header
|
// HeaderColumn represent a table header.
|
||||||
type HeaderColumn struct {
|
type HeaderColumn struct {
|
||||||
Name string
|
Name string
|
||||||
Align int
|
Align int
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func AsThousands(n int64) string {
|
||||||
return p.Sprintf("%d", n)
|
return p.Sprintf("%d", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func Happy(ns string, h Header, r Row) bool {
|
func Happy(ns string, h Header, r Row) bool {
|
||||||
if len(r.Fields) == 0 {
|
if len(r.Fields) == 0 {
|
||||||
return true
|
return true
|
||||||
|
|
@ -300,7 +300,7 @@ func Pad(s string, width int) string {
|
||||||
return s + strings.Repeat(" ", width-len(s))
|
return s + strings.Repeat(" ", width-len(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts labels string to map
|
// Converts labels string to map.
|
||||||
func labelize(labels string) map[string]string {
|
func labelize(labels string) map[string]string {
|
||||||
ll := strings.Split(labels, ",")
|
ll := strings.Split(labels, ",")
|
||||||
data := make(map[string]string, len(ll))
|
data := make(map[string]string, len(ll))
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,6 @@ func status(conds []v1.NodeCondition, exempt bool, res []string) {
|
||||||
}
|
}
|
||||||
res[index] = neg + string(condition.Type)
|
res[index] = neg + string(condition.Type)
|
||||||
index++
|
index++
|
||||||
|
|
||||||
}
|
}
|
||||||
if len(res) == 0 {
|
if len(res) == 0 {
|
||||||
res[index] = "Unknown"
|
res[index] = "Unknown"
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func (o OpenFaas) Render(i interface{}, ns string, r *Row) error {
|
||||||
if fn.Function.Labels != nil {
|
if fn.Function.Labels != nil {
|
||||||
labels = mapToStr(*fn.Function.Labels)
|
labels = mapToStr(*fn.Function.Labels)
|
||||||
}
|
}
|
||||||
var status = fnStatusReady
|
status := fnStatusReady
|
||||||
if fn.Function.AvailableReplicas == 0 {
|
if fn.Function.AvailableReplicas == 0 {
|
||||||
status = fnStatusNotReady
|
status = fnStatusNotReady
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
|
|
||||||
"github.com/derailed/popeye/pkg/config"
|
"github.com/derailed/popeye/pkg/config"
|
||||||
"github.com/derailed/tview"
|
"github.com/derailed/tview"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
|
@ -89,7 +88,7 @@ type (
|
||||||
// Sections represents a collection of sections.
|
// Sections represents a collection of sections.
|
||||||
Sections []Section
|
Sections []Section
|
||||||
|
|
||||||
// Section represents a sanitizer pass
|
// Section represents a sanitizer pass.
|
||||||
Section struct {
|
Section struct {
|
||||||
Title string `json:"sanitizer" yaml:"sanitizer"`
|
Title string `json:"sanitizer" yaml:"sanitizer"`
|
||||||
GVR string `yaml:"gvr" json:"gvr"`
|
GVR string `yaml:"gvr" json:"gvr"`
|
||||||
|
|
@ -187,7 +186,7 @@ func (i Issues) MaxSeverity() config.Level {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountSeverity counts severity level instances
|
// CountSeverity counts severity level instances.
|
||||||
func (i Issues) CountSeverity(l config.Level) int {
|
func (i Issues) CountSeverity(l config.Level) int {
|
||||||
var count int
|
var count int
|
||||||
for _, is := range i {
|
for _, is := range i {
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ func (r RowEvents) Delete(id string) RowEvents {
|
||||||
return append(r[0:victim], r[victim+1:]...)
|
return append(r[0:victim], r[victim+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear delete all row events
|
// Clear delete all row events.
|
||||||
func (r RowEvents) Clear() RowEvents {
|
func (r RowEvents) Clear() RowEvents {
|
||||||
return RowEvents{}
|
return RowEvents{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
// Subject renders a rbac to screen.
|
// Subject renders a rbac to screen.
|
||||||
type Subject struct{}
|
type Subject struct{}
|
||||||
|
|
||||||
// Happy returns true if resource is happy, false otherwise
|
// Happy returns true if resource is happy, false otherwise.
|
||||||
func (Subject) Happy(_ string, _ Row) bool {
|
func (Subject) Happy(_ string, _ Row) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func (t *TableData) IndexOfHeader(h string) int {
|
||||||
return t.Header.IndexOf(h, false)
|
return t.Header.IndexOf(h, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Labelize prints out specific label columns
|
// Labelize prints out specific label columns.
|
||||||
func (t *TableData) Labelize(labels []string) TableData {
|
func (t *TableData) Labelize(labels []string) TableData {
|
||||||
labelCol := t.Header.IndexOf("LABELS", true)
|
labelCol := t.Header.IndexOf("LABELS", true)
|
||||||
cols := []int{0, 1}
|
cols := []int{0, 1}
|
||||||
|
|
@ -54,7 +54,7 @@ func (t *TableData) Clear() {
|
||||||
t.Header, t.RowEvents = Header{}, RowEvents{}
|
t.Header, t.RowEvents = Header{}, RowEvents{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone returns a copy of the table
|
// Clone returns a copy of the table.
|
||||||
func (t *TableData) Clone() TableData {
|
func (t *TableData) Clone() TableData {
|
||||||
return TableData{
|
return TableData{
|
||||||
Header: t.Header.Clone(),
|
Header: t.Header.Clone(),
|
||||||
|
|
|
||||||
|
|
@ -392,5 +392,4 @@ func TestTableDataDelete(t *testing.T) {
|
||||||
assert.Equal(t, u.e, table.RowEvents)
|
assert.Equal(t, u.e, table.RowEvents)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const (
|
||||||
// UnknownValue represents an unknown.
|
// UnknownValue represents an unknown.
|
||||||
UnknownValue = "<unknown>"
|
UnknownValue = "<unknown>"
|
||||||
|
|
||||||
// UnsetValue represent an unset value
|
// UnsetValue represent an unset value.
|
||||||
UnsetValue = ""
|
UnsetValue = ""
|
||||||
|
|
||||||
// ZeroValue represents a zero value.
|
// ZeroValue represents a zero value.
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func (c *Component) InputHandler() func(event *tcell.EventKey, setFocus func(p t
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDial returns true if chart is a dial
|
// IsDial returns true if chart is a dial.
|
||||||
func (c *Component) IsDial() bool {
|
func (c *Component) IsDial() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func (d DotMatrix) Print(n int) Matrix {
|
||||||
return To3x3Char(n)
|
return To3x3Char(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// To3x3Char returns 3x3 number matrix
|
// To3x3Char returns 3x3 number matrix.
|
||||||
func To3x3Char(numb int) Matrix {
|
func To3x3Char(numb int) Matrix {
|
||||||
switch numb {
|
switch numb {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ func (g *Gauge) SetResolution(n int) {
|
||||||
g.resolution = n
|
g.resolution = n
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDial returns true if chart is a dial
|
// IsDial returns true if chart is a dial.
|
||||||
func (g *Gauge) IsDial() bool {
|
func (g *Gauge) IsDial() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ func (a *App) Flash() *model.Flash {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Helpers...
|
// Helpers...
|
||||||
|
|
||||||
// AsKey converts rune to keyboard key.,
|
// AsKey converts rune to keyboard key.,.
|
||||||
func AsKey(evt *tcell.EventKey) tcell.Key {
|
func AsKey(evt *tcell.EventKey) tcell.Key {
|
||||||
if evt.Key() != tcell.KeyRune {
|
if evt.Key() != tcell.KeyRune {
|
||||||
return evt.Key()
|
return evt.Key()
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,13 @@ func (c *Crumbs) StackPushed(comp model.Component) {
|
||||||
c.refresh(c.stack.Flatten())
|
c.refresh(c.stack.Flatten())
|
||||||
}
|
}
|
||||||
|
|
||||||
// StackPopped indicates an item was deleted
|
// StackPopped indicates an item was deleted.
|
||||||
func (c *Crumbs) StackPopped(_, _ model.Component) {
|
func (c *Crumbs) StackPopped(_, _ model.Component) {
|
||||||
c.stack.Pop()
|
c.stack.Pop()
|
||||||
c.refresh(c.stack.Flatten())
|
c.refresh(c.stack.Flatten())
|
||||||
}
|
}
|
||||||
|
|
||||||
// StackTop indicates the top of the stack
|
// StackTop indicates the top of the stack.
|
||||||
func (c *Crumbs) StackTop(top model.Component) {}
|
func (c *Crumbs) StackTop(top model.Component) {}
|
||||||
|
|
||||||
// Refresh updates view with new crumbs.
|
// Refresh updates view with new crumbs.
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ func (s *StatusIndicator) ClusterInfoChanged(prev, cur model.ClusterMeta) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPermanent sets permanent title to be reset to after updates
|
// SetPermanent sets permanent title to be reset to after updates.
|
||||||
func (s *StatusIndicator) SetPermanent(info string) {
|
func (s *StatusIndicator) SetPermanent(info string) {
|
||||||
s.permanent = info
|
s.permanent = info
|
||||||
s.SetText(info)
|
s.SetText(info)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func initKeys() {
|
||||||
initShiftNumKeys()
|
initShiftNumKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines numeric keys for container actions
|
// Defines numeric keys for container actions.
|
||||||
const (
|
const (
|
||||||
Key0 tcell.Key = iota + 48
|
Key0 tcell.Key = iota + 48
|
||||||
Key1
|
Key1
|
||||||
|
|
@ -31,7 +31,7 @@ const (
|
||||||
Key9
|
Key9
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines numeric keys for container actions
|
// Defines numeric keys for container actions.
|
||||||
const (
|
const (
|
||||||
KeyShift0 tcell.Key = 41
|
KeyShift0 tcell.Key = 41
|
||||||
KeyShift1 tcell.Key = 33
|
KeyShift1 tcell.Key = 33
|
||||||
|
|
@ -45,7 +45,7 @@ const (
|
||||||
KeyShift9 tcell.Key = 40
|
KeyShift9 tcell.Key = 40
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines char keystrokes
|
// Defines char keystrokes.
|
||||||
const (
|
const (
|
||||||
KeyA tcell.Key = iota + 97
|
KeyA tcell.Key = iota + 97
|
||||||
KeyB
|
KeyB
|
||||||
|
|
@ -79,7 +79,7 @@ const (
|
||||||
KeySpace = 32
|
KeySpace = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
// Define Shift Keys
|
// Define Shift Keys.
|
||||||
const (
|
const (
|
||||||
KeyShiftA tcell.Key = iota + 65
|
KeyShiftA tcell.Key = iota + 65
|
||||||
KeyShiftB
|
KeyShiftB
|
||||||
|
|
|
||||||
|
|
@ -54,5 +54,4 @@ func TestLogoStatus(t *testing.T) {
|
||||||
assert.Equal(t, u.e, v.Status().GetText(false))
|
assert.Equal(t, u.e, v.Status().GetText(false))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,6 @@ func (m *Menu) layout(table []model.MenuHints, mm []int, out [][]string) {
|
||||||
out[r][c] = keyConv(m.formatMenu(table[r][c], mm[c]))
|
out[r][c] = keyConv(m.formatMenu(table[r][c], mm[c]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Menu) formatMenu(h model.MenuHint, size int) string {
|
func (m *Menu) formatMenu(h model.MenuHint, size int) string {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type Suggester interface {
|
||||||
ClearSuggestions()
|
ClearSuggestions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// PromptModel represents a prompt buffer
|
// PromptModel represents a prompt buffer.
|
||||||
type PromptModel interface {
|
type PromptModel interface {
|
||||||
// SetText sets the model text.
|
// SetText sets the model text.
|
||||||
SetText(string)
|
SetText(string)
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func (s *SelectTable) DeleteMark(k string) {
|
||||||
delete(s.marks, k)
|
delete(s.marks, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToggleMark toggles marked row
|
// ToggleMark toggles marked row.
|
||||||
func (s *SelectTable) ToggleMark() {
|
func (s *SelectTable) ToggleMark() {
|
||||||
sel := s.GetSelectedItem()
|
sel := s.GetSelectedItem()
|
||||||
if sel == "" {
|
if sel == "" {
|
||||||
|
|
@ -148,7 +148,7 @@ func (s *SelectTable) ToggleMark() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpanMark toggles marked row
|
// SpanMark toggles marked row.
|
||||||
func (s *SelectTable) SpanMark() {
|
func (s *SelectTable) SpanMark() {
|
||||||
selIndex, prev := s.GetSelectedRowIndex(), -1
|
selIndex, prev := s.GetSelectedRowIndex(), -1
|
||||||
if selIndex <= 0 {
|
if selIndex <= 0 {
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ func (t *Table) filtered(data render.TableData) render.TableData {
|
||||||
filtered, err := rxFilter(q, IsInverseSelector(q), filtered)
|
filtered, err := rxFilter(q, IsInverseSelector(q), filtered)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(errors.New("Invalid filter expression")).Msg("Regexp")
|
log.Error().Err(errors.New("Invalid filter expression")).Msg("Regexp")
|
||||||
//t.cmdBuff.ClearText(true)
|
// t.cmdBuff.ClearText(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filtered
|
return filtered
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// LabelRx identifies a label query
|
// LabelRx identifies a label query.
|
||||||
LabelRx = regexp.MustCompile(`\A\-l`)
|
LabelRx = regexp.MustCompile(`\A\-l`)
|
||||||
|
|
||||||
inverseRx = regexp.MustCompile(`\A\!`)
|
inverseRx = regexp.MustCompile(`\A\!`)
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,15 @@ func (t *mockModel) Watch(context.Context) error { return nil }
|
||||||
func (t *mockModel) Get(ctx context.Context, path string) (runtime.Object, error) {
|
func (t *mockModel) Get(ctx context.Context, path string) (runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) Delete(ctx context.Context, path string, c, f bool) error {
|
func (t *mockModel) Delete(ctx context.Context, path string, c, f bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) Describe(context.Context, string) (string, error) {
|
func (t *mockModel) Describe(context.Context, string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) ToYAML(ctx context.Context, path string) (string, error) {
|
func (t *mockModel) ToYAML(ctx context.Context, path string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func NewTree() *Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the view
|
// Init initializes the view.
|
||||||
func (t *Tree) Init(ctx context.Context) error {
|
func (t *Tree) Init(ctx context.Context) error {
|
||||||
t.BindKeys()
|
t.BindKeys()
|
||||||
t.SetBorder(true)
|
t.SetBorder(true)
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,10 @@ func (k ks) NamespaceNames(nn []v1.Namespace) []string {
|
||||||
|
|
||||||
type mockModel struct{}
|
type mockModel struct{}
|
||||||
|
|
||||||
var _ ui.Tabular = (*mockModel)(nil)
|
var (
|
||||||
var _ ui.Suggester = (*mockModel)(nil)
|
_ ui.Tabular = (*mockModel)(nil)
|
||||||
|
_ ui.Suggester = (*mockModel)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (t *mockModel) CurrentSuggestion() (string, bool) { return "", false }
|
func (t *mockModel) CurrentSuggestion() (string, bool) { return "", false }
|
||||||
func (t *mockModel) NextSuggestion() (string, bool) { return "", false }
|
func (t *mockModel) NextSuggestion() (string, bool) { return "", false }
|
||||||
|
|
@ -119,15 +121,17 @@ func (t *mockModel) RemoveListener(model.TableListener) {}
|
||||||
func (t *mockModel) Watch(context.Context) error { return nil }
|
func (t *mockModel) Watch(context.Context) error { return nil }
|
||||||
func (t *mockModel) Refresh(context.Context) error { return nil }
|
func (t *mockModel) Refresh(context.Context) error { return nil }
|
||||||
func (t *mockModel) Get(context.Context, string) (runtime.Object, error) {
|
func (t *mockModel) Get(context.Context, string) (runtime.Object, error) {
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) Delete(context.Context, string, bool, bool) error {
|
func (t *mockModel) Delete(context.Context, string, bool, bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) Describe(context.Context, string) (string, error) {
|
func (t *mockModel) Describe(context.Context, string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mockModel) ToYAML(ctx context.Context, path string) (string, error) {
|
func (t *mockModel) ToYAML(ctx context.Context, path string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ func (a *App) BailOut() {
|
||||||
a.App.BailOut()
|
a.App.BailOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts the application loop
|
// Run starts the application loop.
|
||||||
func (a *App) Run() error {
|
func (a *App) Run() error {
|
||||||
a.Resume()
|
a.Resume()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func NewBrowser(gvr client.GVR) ResourceViewer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init watches all running pods in given namespace
|
// Init watches all running pods in given namespace.
|
||||||
func (b *Browser) Init(ctx context.Context) error {
|
func (b *Browser) Init(ctx context.Context) error {
|
||||||
var err error
|
var err error
|
||||||
b.meta, err = dao.MetaAccess.MetaFor(b.GVR())
|
b.meta, err = dao.MetaAccess.MetaFor(b.GVR())
|
||||||
|
|
@ -343,7 +343,6 @@ func (b *Browser) editCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
path := b.GetSelectedItem()
|
path := b.GetSelectedItem()
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return evt
|
return evt
|
||||||
|
|
||||||
}
|
}
|
||||||
ns, n := client.Namespaced(path)
|
ns, n := client.Namespaced(path)
|
||||||
if client.IsClusterScoped(ns) {
|
if client.IsClusterScoped(ns) {
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ func (c *Command) exec(cmd, gvr string, comp model.Component, clearStack bool) (
|
||||||
return fmt.Errorf("No component found for %s", gvr)
|
return fmt.Errorf("No component found for %s", gvr)
|
||||||
}
|
}
|
||||||
c.app.Flash().Infof("Viewing %s...", client.NewGVR(gvr).R())
|
c.app.Flash().Infof("Viewing %s...", client.NewGVR(gvr).R())
|
||||||
if tokens:= strings.Split(cmd, " "); len(tokens) >= 2 {
|
if tokens := strings.Split(cmd, " "); len(tokens) >= 2 {
|
||||||
cmd = tokens[0]
|
cmd = tokens[0]
|
||||||
}
|
}
|
||||||
c.app.Config.SetActiveView(cmd)
|
c.app.Config.SetActiveView(cmd)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Cow represents a bomb viewer
|
// Cow represents a bomb viewer.
|
||||||
type Cow struct {
|
type Cow struct {
|
||||||
*tview.TextView
|
*tview.TextView
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ func (c *Cow) resetCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return c.app.PrevCmd(evt)
|
return c.app.PrevCmd(evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions returns menu actions
|
// Actions returns menu actions.
|
||||||
func (c *Cow) Actions() ui.KeyActions {
|
func (c *Cow) Actions() ui.KeyActions {
|
||||||
return c.actions
|
return c.actions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/derailed/tview"
|
"github.com/derailed/tview"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
batchv1 "k8s.io/api/batch/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
@ -45,7 +45,7 @@ func (c *CronJob) showJobs(app *App, model ui.Tabular, gvr, path string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var cj batchv1beta1.CronJob
|
var cj batchv1.CronJob
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Flash().Err(err)
|
app.Flash().Err(err)
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ func (d *Details) SetSubject(s string) {
|
||||||
d.subject = s
|
d.subject = s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions returns menu actions
|
// Actions returns menu actions.
|
||||||
func (d *Details) Actions() ui.KeyActions {
|
func (d *Details) Actions() ui.KeyActions {
|
||||||
return d.actions
|
return d.actions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ func (d *Deploy) logOptions() (*dao.LogOptions, error) {
|
||||||
|
|
||||||
return &opts, nil
|
return &opts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Deploy) showPods(app *App, model ui.Tabular, gvr, path string) {
|
func (d *Deploy) showPods(app *App, model ui.Tabular, gvr, path string) {
|
||||||
var ddp dao.Deployment
|
var ddp dao.Deployment
|
||||||
dp, err := ddp.Load(app.factory, path)
|
dp, err := ddp.Load(app.factory, path)
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,8 @@ func (h *Help) showNav() model.MenuHints {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Mnemonic: "Ctrl-b",
|
Mnemonic: "Ctrl-b",
|
||||||
Description: "Page Up"},
|
Description: "Page Up",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Mnemonic: "Ctrl-f",
|
Mnemonic: "Ctrl-f",
|
||||||
Description: "Page Down",
|
Description: "Page Down",
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ type imageFormSpec struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *imageFormSpec) modified() bool {
|
func (m *imageFormSpec) modified() bool {
|
||||||
var newDockerImage = strings.TrimSpace(m.newDockerImage)
|
newDockerImage := strings.TrimSpace(m.newDockerImage)
|
||||||
return newDockerImage != "" && m.dockerImage != newDockerImage
|
return newDockerImage != "" && m.dockerImage != newDockerImage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *imageFormSpec) imageSpec() dao.ImageSpec {
|
func (m *imageFormSpec) imageSpec() dao.ImageSpec {
|
||||||
var ret = dao.ImageSpec{
|
ret := dao.ImageSpec{
|
||||||
Name: m.name,
|
Name: m.name,
|
||||||
Init: m.init,
|
Init: m.init,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ func (v *LiveView) bindKeys() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToggleRefreshCmd is used for pausing the refreshing of data on config map and secrets
|
// ToggleRefreshCmd is used for pausing the refreshing of data on config map and secrets.
|
||||||
func (v *LiveView) toggleRefreshCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (v *LiveView) toggleRefreshCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
v.autoRefresh = !v.autoRefresh
|
v.autoRefresh = !v.autoRefresh
|
||||||
if v.autoRefresh {
|
if v.autoRefresh {
|
||||||
|
|
@ -181,7 +181,7 @@ func (v *LiveView) StylesChanged(s *config.Styles) {
|
||||||
v.ResourceChanged(v.model.Peek(), nil)
|
v.ResourceChanged(v.model.Peek(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions returns menu actions
|
// Actions returns menu actions.
|
||||||
func (v *LiveView) Actions() ui.KeyActions {
|
func (v *LiveView) Actions() ui.KeyActions {
|
||||||
return v.actions
|
return v.actions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/atotto/clipboard"
|
"github.com/atotto/clipboard"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
"github.com/derailed/k9s/internal/color"
|
"github.com/derailed/k9s/internal/color"
|
||||||
"github.com/derailed/k9s/internal/config"
|
"github.com/derailed/k9s/internal/config"
|
||||||
|
|
@ -355,7 +354,6 @@ func saveData(cluster, name, data string) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("LogFile create %s", path)
|
log.Error().Err(err).Msgf("LogFile create %s", path)
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := file.Close(); err != nil {
|
if err := file.Close(); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func (l *Logger) SetSubject(s string) {
|
||||||
l.subject = s
|
l.subject = s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions returns menu actions
|
// Actions returns menu actions.
|
||||||
func (l *Logger) Actions() ui.KeyActions {
|
func (l *Logger) Actions() ui.KeyActions {
|
||||||
return l.actions
|
return l.actions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func (l *LogsExtender) showLogs(path string, prev bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildLogOpts(path, co, prev, false, config.DefaultLoggerTailCount),
|
// buildLogOpts(path, co, prev, false, config.DefaultLoggerTailCount),.
|
||||||
func (l *LogsExtender) buildLogOpts(path, co string, prevLogs bool) *dao.LogOptions {
|
func (l *LogsExtender) buildLogOpts(path, co string, prevLogs bool) *dao.LogOptions {
|
||||||
cfg := l.App().Config.K9s.Logger
|
cfg := l.App().Config.K9s.Logger
|
||||||
opts := dao.LogOptions{
|
opts := dao.LogOptions{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type Namespace struct {
|
||||||
ResourceViewer
|
ResourceViewer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNamespace returns a new viewer
|
// NewNamespace returns a new viewer.
|
||||||
func NewNamespace(gvr client.GVR) ResourceViewer {
|
func NewNamespace(gvr client.GVR) ResourceViewer {
|
||||||
n := Namespace{
|
n := Namespace{
|
||||||
ResourceViewer: NewBrowser(gvr),
|
ResourceViewer: NewBrowser(gvr),
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ func (p *Pulse) Stop() {
|
||||||
p.cancelFn = nil
|
p.cancelFn = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh updates the view
|
// Refresh updates the view.
|
||||||
func (p *Pulse) Refresh() {}
|
func (p *Pulse) Refresh() {}
|
||||||
|
|
||||||
// GVR returns a resource descriptor.
|
// GVR returns a resource descriptor.
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,9 @@ func rbacViewers(vv MetaViewers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func batchViewers(vv MetaViewers) {
|
func batchViewers(vv MetaViewers) {
|
||||||
vv[client.NewGVR("batch/v1/cronjobs")] = MetaViewer{
|
|
||||||
viewerFn: NewCronJob,
|
|
||||||
}
|
|
||||||
vv[client.NewGVR("batch/v1beta1/cronjobs")] = MetaViewer{
|
vv[client.NewGVR("batch/v1beta1/cronjobs")] = MetaViewer{
|
||||||
viewerFn: NewCronJob,
|
viewerFn: NewCronJob,
|
||||||
}
|
}
|
||||||
|
|
||||||
vv[client.NewGVR("batch/v1/jobs")] = MetaViewer{
|
vv[client.NewGVR("batch/v1/jobs")] = MetaViewer{
|
||||||
viewerFn: NewJob,
|
viewerFn: NewJob,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func NewSanitizer(gvr client.GVR) ResourceViewer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the view
|
// Init initializes the view.
|
||||||
func (s *Sanitizer) Init(ctx context.Context) error {
|
func (s *Sanitizer) Init(ctx context.Context) error {
|
||||||
s.envFn = s.k9sEnv
|
s.envFn = s.k9sEnv
|
||||||
|
|
||||||
|
|
@ -317,7 +317,7 @@ func (s *Sanitizer) hydrate(parent *tview.TreeNode, n *xray.TreeNode) {
|
||||||
// SetEnvFn sets the custom environment function.
|
// SetEnvFn sets the custom environment function.
|
||||||
func (s *Sanitizer) SetEnvFn(EnvFunc) {}
|
func (s *Sanitizer) SetEnvFn(EnvFunc) {}
|
||||||
|
|
||||||
// Refresh updates the view
|
// Refresh updates the view.
|
||||||
func (s *Sanitizer) Refresh() {}
|
func (s *Sanitizer) Refresh() {}
|
||||||
|
|
||||||
// BufferChanged indicates the buffer was changed.
|
// BufferChanged indicates the buffer was changed.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sigs.k8s.io/yaml"
|
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
"github.com/derailed/k9s/internal/ui"
|
"github.com/derailed/k9s/internal/ui"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
|
@ -10,6 +8,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Secret presents a secret viewer.
|
// Secret presents a secret viewer.
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ func (s *Service) toggleBenchCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOZO!! Refactor used by forwards
|
// BOZO!! Refactor used by forwards.
|
||||||
func (s *Service) runBenchmark(port string, cfg config.BenchConfig) error {
|
func (s *Service) runBenchmark(port string, cfg config.BenchConfig) error {
|
||||||
if cfg.HTTP.Host == "" {
|
if cfg.HTTP.Host == "" {
|
||||||
return fmt.Errorf("Invalid benchmark host %q", cfg.HTTP.Host)
|
return fmt.Errorf("Invalid benchmark host %q", cfg.HTTP.Host)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func NewTable(gvr client.GVR) *Table {
|
||||||
return &t
|
return &t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the component
|
// Init initializes the component.
|
||||||
func (t *Table) Init(ctx context.Context) (err error) {
|
func (t *Table) Init(ctx context.Context) (err error) {
|
||||||
if t.app, err = extractApp(ctx); err != nil {
|
if t.app, err = extractApp(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue