mirror of https://github.com/fluxcd/cli-utils.git
refactor: Fix linting issues found in golangci-lint v1.50.0
This commit is contained in:
parent
31fa3deb2a
commit
c494d01128
|
|
@ -4,7 +4,6 @@
|
||||||
package diff
|
package diff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -104,7 +103,7 @@ func Initialize(o *diff.DiffOptions, f util.Factory, args []string) (func(), err
|
||||||
func createTempDir() (string, error) {
|
func createTempDir() (string, error) {
|
||||||
// Create a temporary file with the passed prefix in
|
// Create a temporary file with the passed prefix in
|
||||||
// the default temporary directory.
|
// the default temporary directory.
|
||||||
tmpDir, err := ioutil.TempDir("", tmpDirPrefix)
|
tmpDir, err := os.MkdirTemp("", tmpDirPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -240,20 +240,20 @@ func (g *genericHandler) handle(t *testing.T, req *http.Request) (*http.Response
|
||||||
|
|
||||||
if req.URL.Path == singlePath && req.Method == http.MethodGet {
|
if req.URL.Path == singlePath && req.Method == http.MethodGet {
|
||||||
if r.exists {
|
if r.exists {
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
return &http.Response{StatusCode: http.StatusNotFound, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.StringBody("")}, true, nil
|
return &http.Response{StatusCode: http.StatusNotFound, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.StringBody("")}, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.URL.Path == singlePath && req.Method == http.MethodPatch {
|
if req.URL.Path == singlePath && req.Method == http.MethodPatch {
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.URL.Path == singlePath && req.Method == http.MethodDelete {
|
if req.URL.Path == singlePath && req.Method == http.MethodDelete {
|
||||||
if r.exists {
|
if r.exists {
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,12 +271,12 @@ func (g *genericHandler) handle(t *testing.T, req *http.Request) (*http.Response
|
||||||
Kind: r.resource.GetKind(),
|
Kind: r.resource.GetKind(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, result)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, result)))
|
||||||
return &http.Response{StatusCode: status, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: status, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.URL.Path == allPath && req.Method == http.MethodPost {
|
if req.URL.Path == allPath && req.Method == http.MethodPost {
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, r.resource)))
|
||||||
return &http.Response{StatusCode: http.StatusCreated, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: http.StatusCreated, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -341,7 +341,7 @@ func (n *nsHandler) handle(t *testing.T, req *http.Request) (*http.Response, boo
|
||||||
Name: nsName,
|
Name: nsName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(t, &ns)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(t, &ns)))
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, true, nil
|
||||||
}
|
}
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Type determines the type of events that are available.
|
// Type determines the type of events that are available.
|
||||||
|
//
|
||||||
//go:generate stringer -type=Type
|
//go:generate stringer -type=Type
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ func CreateEventFactory(isDelete bool, groupName string) EventFactory {
|
||||||
|
|
||||||
// PruneEventFactory implements EventFactory interface as a concrete
|
// PruneEventFactory implements EventFactory interface as a concrete
|
||||||
// representation of for prune events.
|
// representation of for prune events.
|
||||||
|
//
|
||||||
//nolint:revive // stuttering ok because Prune is a type of PruneEvent
|
//nolint:revive // stuttering ok because Prune is a type of PruneEvent
|
||||||
type PruneEventFactory struct {
|
type PruneEventFactory struct {
|
||||||
groupName string
|
groupName string
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,12 @@ type Options struct {
|
||||||
// automatically prune/delete).
|
// automatically prune/delete).
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// objs - objects to prune (delete)
|
//
|
||||||
// pruneFilters - list of filters for deletion permission
|
// objs - objects to prune (delete)
|
||||||
// taskContext - task for apply/prune
|
// pruneFilters - list of filters for deletion permission
|
||||||
// taskName - name of the parent task group, for events
|
// taskContext - task for apply/prune
|
||||||
// opts - options for dry-run
|
// taskName - name of the parent task group, for events
|
||||||
|
// opts - options for dry-run
|
||||||
func (p *Pruner) Prune(
|
func (p *Pruner) Prune(
|
||||||
objs object.UnstructuredSet,
|
objs object.UnstructuredSet,
|
||||||
pruneFilters []filter.ValidationFilter,
|
pruneFilters []filter.ValidationFilter,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
|
@ -192,8 +192,8 @@ func newApplyOptions(taskName string, eventChannel chan<- event.Event, serverSid
|
||||||
OpenAPIPatch: true, // Normally set in apply.NewApplyOptions
|
OpenAPIPatch: true, // Normally set in apply.NewApplyOptions
|
||||||
Recorder: genericclioptions.NoopRecorder{},
|
Recorder: genericclioptions.NoopRecorder{},
|
||||||
IOStreams: genericclioptions.IOStreams{
|
IOStreams: genericclioptions.IOStreams{
|
||||||
Out: ioutil.Discard,
|
Out: io.Discard,
|
||||||
ErrOut: ioutil.Discard, // TODO: Warning for no lastConfigurationAnnotation
|
ErrOut: io.Discard, // TODO: Warning for no lastConfigurationAnnotation
|
||||||
// is printed directly to stderr in ApplyOptions. We
|
// is printed directly to stderr in ApplyOptions. We
|
||||||
// should turn that into a warning on the event channel.
|
// should turn that into a warning on the event channel.
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,11 @@ type Options struct {
|
||||||
//
|
//
|
||||||
// The tasks run in a loop where a single goroutine will process events from
|
// The tasks run in a loop where a single goroutine will process events from
|
||||||
// three different channels.
|
// three different channels.
|
||||||
// - taskQueue is read to allow updating the task queue at runtime.
|
// - taskQueue is read to allow updating the task queue at runtime.
|
||||||
// - statusChannel is read to allow updates to the resource cache and triggering
|
// - statusChannel is read to allow updates to the resource cache and triggering
|
||||||
// validation of wait conditions.
|
// validation of wait conditions.
|
||||||
// - eventChannel is written to with events based on status updates, if
|
// - eventChannel is written to with events based on status updates, if
|
||||||
// emitStatusEvents is true.
|
// emitStatusEvents is true.
|
||||||
func (tsr *TaskStatusRunner) Run(
|
func (tsr *TaskStatusRunner) Run(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
taskContext *TaskContext,
|
taskContext *TaskContext,
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ClientDryRun returns true if input drs is DryRunClient
|
// ClientDryRun returns true if input drs is DryRunClient
|
||||||
|
//
|
||||||
//nolint:stylecheck // Prevent lint errors on receiver names caused by string generation above
|
//nolint:stylecheck // Prevent lint errors on receiver names caused by string generation above
|
||||||
func (drs DryRunStrategy) ClientDryRun() bool {
|
func (drs DryRunStrategy) ClientDryRun() bool {
|
||||||
return drs == DryRunClient
|
return drs == DryRunClient
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package common
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -94,11 +93,11 @@ func ExpandPackageDir(f genericclioptions.FileNameFlags) (genericclioptions.File
|
||||||
// an error if one occurs.
|
// an error if one occurs.
|
||||||
func FilterInputFile(in io.Reader, tmpDir string) error {
|
func FilterInputFile(in io.Reader, tmpDir string) error {
|
||||||
// Copy the config from "in" into a local temp file.
|
// Copy the config from "in" into a local temp file.
|
||||||
dir, err := ioutil.TempDir("", tmpDirPrefix)
|
dir, err := os.MkdirTemp("", tmpDirPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tmpFile, err := ioutil.TempFile(dir, fileRegexp)
|
tmpFile, err := os.CreateTemp(dir, fileRegexp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -201,7 +200,7 @@ func TestFilterInputFile(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error in FilterInputFile: %s", err)
|
t.Fatalf("Unexpected error in FilterInputFile: %s", err)
|
||||||
}
|
}
|
||||||
// Retrieve the files from the test filesystem.
|
// Retrieve the files from the test filesystem.
|
||||||
actualFiles, err := ioutil.ReadDir(tf.GetRootDir())
|
actualFiles, err := os.ReadDir(tf.GetRootDir())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error reading test filesystem directory: %s", err)
|
t.Fatalf("Error reading test filesystem directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +214,7 @@ func TestFilterInputFile(t *testing.T) {
|
||||||
if len(actualFiles) != 0 {
|
if len(actualFiles) != 0 {
|
||||||
actualFilename := (actualFiles[0]).Name()
|
actualFilename := (actualFiles[0]).Name()
|
||||||
defer os.Remove(actualFilename)
|
defer os.Remove(actualFilename)
|
||||||
actual, err := ioutil.ReadFile(actualFilename)
|
actual, err := os.ReadFile(actualFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error reading created file (%s): %s", actualFilename, err)
|
t.Fatalf("Error reading created file (%s): %s", actualFilename, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@ func FindNamespace(loader namespaceLoader, dir string) (string, error) {
|
||||||
// passed directory or an error. This function cleans up paths
|
// passed directory or an error. This function cleans up paths
|
||||||
// such as current directory (.), relative directories (..), or
|
// such as current directory (.), relative directories (..), or
|
||||||
// multiple separators.
|
// multiple separators.
|
||||||
//
|
|
||||||
func NormalizeDir(dirPath string) (string, error) {
|
func NormalizeDir(dirPath string) (string, error) {
|
||||||
if !common.IsDir(dirPath) {
|
if !common.IsDir(dirPath) {
|
||||||
return "", fmt.Errorf("invalid directory argument: %s", dirPath)
|
return "", fmt.Errorf("invalid directory argument: %s", dirPath)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
@ -19,7 +18,7 @@ import (
|
||||||
|
|
||||||
// writeFile writes a file under the test directory
|
// writeFile writes a file under the test directory
|
||||||
func writeFile(t *testing.T, path string, value []byte) {
|
func writeFile(t *testing.T, path string, value []byte) {
|
||||||
err := ioutil.WriteFile(path, value, 0600)
|
err := os.WriteFile(path, value, 0600)
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +152,7 @@ func TestComplete(t *testing.T) {
|
||||||
for name, tc := range tests {
|
for name, tc := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
dir, err := ioutil.TempDir("", "test-dir")
|
dir, err := os.MkdirTemp("", "test-dir")
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +221,7 @@ func TestFindNamespace(t *testing.T) {
|
||||||
for tn, tc := range testCases {
|
for tn, tc := range testCases {
|
||||||
t.Run(tn, func(t *testing.T) {
|
t.Run(tn, func(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
dir, err := ioutil.TempDir("", "test-dir")
|
dir, err := os.MkdirTemp("", "test-dir")
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package flowcontrol
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -37,7 +36,7 @@ func TestIsEnabled(t *testing.T) {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
Header: headers,
|
Header: headers,
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(nil)),
|
Body: io.NopCloser(bytes.NewReader(nil)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
expectedEnabled: true,
|
expectedEnabled: true,
|
||||||
|
|
@ -49,7 +48,7 @@ func TestIsEnabled(t *testing.T) {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
Header: http.Header{},
|
Header: http.Header{},
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(nil)),
|
Body: io.NopCloser(bytes.NewReader(nil)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
expectedEnabled: false,
|
expectedEnabled: false,
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,10 @@ package configmap
|
||||||
// Template for ConfigMap inventory object. The following fields
|
// Template for ConfigMap inventory object. The following fields
|
||||||
// must be filled in for this to be valid:
|
// must be filled in for this to be valid:
|
||||||
//
|
//
|
||||||
// <DATETIME>: The time this is auto-generated
|
// <DATETIME>: The time this is auto-generated
|
||||||
// <NAMESPACE>: The namespace to place this inventory object
|
// <NAMESPACE>: The namespace to place this inventory object
|
||||||
// <RANDOMSUFFIX>: The random suffix added to the end of the name
|
// <RANDOMSUFFIX>: The random suffix added to the end of the name
|
||||||
// <INVENTORYID>: The label value to retrieve this inventory object
|
// <INVENTORYID>: The label value to retrieve this inventory object
|
||||||
//
|
|
||||||
const ConfigMapTemplate = `# NOTE: auto-generated. Some fields should NOT be modified.
|
const ConfigMapTemplate = `# NOTE: auto-generated. Some fields should NOT be modified.
|
||||||
# Date: <DATETIME>
|
# Date: <DATETIME>
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ package inventory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ func fakeClient(objs object.ObjMetadataSet) resource.FakeClientFunc {
|
||||||
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
|
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
|
||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
if req.Method == "POST" && cmPathRegex.Match([]byte(req.URL.Path)) {
|
if req.Method == "POST" && cmPathRegex.Match([]byte(req.URL.Path)) {
|
||||||
b, err := ioutil.ReadAll(req.Body)
|
b, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +74,7 @@ func fakeClient(objs object.ObjMetadataSet) resource.FakeClientFunc {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(b))
|
bodyRC := io.NopCloser(bytes.NewReader(b))
|
||||||
return &http.Response{StatusCode: http.StatusCreated, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
return &http.Response{StatusCode: http.StatusCreated, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
||||||
}
|
}
|
||||||
if req.Method == "GET" && cmPathRegex.Match([]byte(req.URL.Path)) {
|
if req.Method == "GET" && cmPathRegex.Match([]byte(req.URL.Path)) {
|
||||||
|
|
@ -97,7 +97,7 @@ func fakeClient(objs object.ObjMetadataSet) resource.FakeClientFunc {
|
||||||
Data: objs.ToStringMap(),
|
Data: objs.ToStringMap(),
|
||||||
}
|
}
|
||||||
cmList.Items = append(cmList.Items, cm)
|
cmList.Items = append(cmList.Items, cm)
|
||||||
bodyRC := ioutil.NopCloser(bytes.NewReader(toJSONBytes(&cmList)))
|
bodyRC := io.NopCloser(bytes.NewReader(toJSONBytes(&cmList)))
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import (
|
||||||
// can go through for a resource based on the comparison
|
// can go through for a resource based on the comparison
|
||||||
// the inventory-id value in the package and the owning-inventory
|
// the inventory-id value in the package and the owning-inventory
|
||||||
// annotation in the live object.
|
// annotation in the live object.
|
||||||
|
//
|
||||||
//go:generate stringer -type=Policy -linecomment
|
//go:generate stringer -type=Policy -linecomment
|
||||||
type Policy int
|
type Policy int
|
||||||
|
|
||||||
|
|
@ -72,6 +73,7 @@ const OwningInventoryKey = "config.k8s.io/owning-inventory"
|
||||||
|
|
||||||
// IDMatchStatus represents the result of comparing the
|
// IDMatchStatus represents the result of comparing the
|
||||||
// id from current inventory info and the inventory-id from a live object.
|
// id from current inventory info and the inventory-id from a live object.
|
||||||
|
//
|
||||||
//go:generate stringer -type=IDMatchStatus
|
//go:generate stringer -type=IDMatchStatus
|
||||||
type IDMatchStatus int
|
type IDMatchStatus int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package inventory
|
||||||
// StatusPolicy specifies whether the inventory client should apply status to
|
// StatusPolicy specifies whether the inventory client should apply status to
|
||||||
// the inventory object. The status contains the actuation and reconcile stauts
|
// the inventory object. The status contains the actuation and reconcile stauts
|
||||||
// of each object in the inventory.
|
// of each object in the inventory.
|
||||||
|
//
|
||||||
//go:generate stringer -type=StatusPolicy -linecomment
|
//go:generate stringer -type=StatusPolicy -linecomment
|
||||||
type StatusPolicy int
|
type StatusPolicy int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ import (
|
||||||
|
|
||||||
// AggregateStatus computes the aggregate status for all the resources.
|
// AggregateStatus computes the aggregate status for all the resources.
|
||||||
// The rules are the following:
|
// The rules are the following:
|
||||||
// - If any of the resources has the FailedStatus, the aggregate status is also
|
// - If any of the resources has the FailedStatus, the aggregate status is also
|
||||||
// FailedStatus
|
// FailedStatus
|
||||||
// - If none of the resources have the FailedStatus and at least one is
|
// - If none of the resources have the FailedStatus and at least one is
|
||||||
// UnknownStatus, the aggregate status is UnknownStatus
|
// UnknownStatus, the aggregate status is UnknownStatus
|
||||||
// - If all the resources have the desired status, the aggregate status is the
|
// - If all the resources have the desired status, the aggregate status is the
|
||||||
// desired status.
|
// desired status.
|
||||||
// - If none of the first three rules apply, the aggregate status is
|
// - If none of the first three rules apply, the aggregate status is
|
||||||
// InProgressStatus
|
// InProgressStatus
|
||||||
func AggregateStatus(rss []*event.ResourceStatus, desired status.Status) status.Status {
|
func AggregateStatus(rss []*event.ResourceStatus, desired status.Status) status.Status {
|
||||||
if len(rss) == 0 {
|
if len(rss) == 0 {
|
||||||
return desired
|
return desired
|
||||||
|
|
|
||||||
|
|
@ -12,30 +12,29 @@
|
||||||
// are several interfaces that can be implemented to support custom
|
// are several interfaces that can be implemented to support custom
|
||||||
// behavior.
|
// behavior.
|
||||||
//
|
//
|
||||||
//
|
// # Polling Resources
|
||||||
// Polling Resources
|
|
||||||
//
|
//
|
||||||
// In order to poll a set of resources, create a StatusPoller
|
// In order to poll a set of resources, create a StatusPoller
|
||||||
// and pass in the list of ResourceIdentifiers to the Poll function.
|
// and pass in the list of ResourceIdentifiers to the Poll function.
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "sigs.k8s.io/cli-utils/pkg/kstatus/polling"
|
// "sigs.k8s.io/cli-utils/pkg/kstatus/polling"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// identifiers := []prune.ObjMetadata{
|
// identifiers := []prune.ObjMetadata{
|
||||||
// {
|
// {
|
||||||
// GroupKind: schema.GroupKind{
|
// GroupKind: schema.GroupKind{
|
||||||
// Group: "apps",
|
// Group: "apps",
|
||||||
// Kind: "Deployment",
|
// Kind: "Deployment",
|
||||||
// },
|
// },
|
||||||
// Name: "dep",
|
// Name: "dep",
|
||||||
// Namespace: "default",
|
// Namespace: "default",
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// poller := polling.NewStatusPoller(reader, mapper, true)
|
// poller := polling.NewStatusPoller(reader, mapper, true)
|
||||||
// eventsChan := poller.Poll(context.Background(), identifiers, polling.PollOptions{})
|
// eventsChan := poller.Poll(context.Background(), identifiers, polling.PollOptions{})
|
||||||
// for e := range eventsChan {
|
// for e := range eventsChan {
|
||||||
// // Handle event
|
// // Handle event
|
||||||
// }
|
// }
|
||||||
package polling
|
package polling
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,26 @@
|
||||||
// of Kubernetes resources.
|
// of Kubernetes resources.
|
||||||
//
|
//
|
||||||
// The statuses defined in this package are:
|
// The statuses defined in this package are:
|
||||||
// * InProgress
|
// - InProgress
|
||||||
// * Current
|
// - Current
|
||||||
// * Failed
|
// - Failed
|
||||||
// * Terminating
|
// - Terminating
|
||||||
// * NotFound
|
// - NotFound
|
||||||
// * Unknown
|
// - Unknown
|
||||||
//
|
//
|
||||||
// Computing the status of a resources can be done by calling the
|
// Computing the status of a resources can be done by calling the
|
||||||
// Compute function in the status package.
|
// Compute function in the status package.
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "sigs.k8s.io/cli-utils/pkg/kstatus/status"
|
// "sigs.k8s.io/cli-utils/pkg/kstatus/status"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// res, err := status.Compute(resource)
|
// res, err := status.Compute(resource)
|
||||||
//
|
//
|
||||||
// The package also defines a set of new conditions:
|
// The package also defines a set of new conditions:
|
||||||
// * InProgress
|
// - InProgress
|
||||||
// * Failed
|
// - Failed
|
||||||
|
//
|
||||||
// These conditions have been chosen to follow the
|
// These conditions have been chosen to follow the
|
||||||
// "abnormal-true" pattern where conditions should be set to true
|
// "abnormal-true" pattern where conditions should be set to true
|
||||||
// for error/abnormal conditions and the absence of a condition means
|
// for error/abnormal conditions and the absence of a condition means
|
||||||
|
|
@ -34,9 +35,9 @@
|
||||||
// these conditions are decided based on other status information
|
// these conditions are decided based on other status information
|
||||||
// available in the resources.
|
// available in the resources.
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "sigs.k8s.io/cli-utils/pkg/kstatus/status
|
// "sigs.k8s.io/cli-utils/pkg/kstatus/status
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// err := status.Augment(resource)
|
// err := status.Augment(resource)
|
||||||
package status
|
package status
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,11 @@ type Condition struct {
|
||||||
//
|
//
|
||||||
// The returned result contains the status of the resource, which will be
|
// The returned result contains the status of the resource, which will be
|
||||||
// one of
|
// one of
|
||||||
// * InProgress
|
// - InProgress
|
||||||
// * Current
|
// - Current
|
||||||
// * Failed
|
// - Failed
|
||||||
// * Terminating
|
// - Terminating
|
||||||
|
//
|
||||||
// It also contains a message that provides more information on why
|
// It also contains a message that provides more information on why
|
||||||
// the resource has the given status. Finally, the result also contains
|
// the resource has the given status. Finally, the result also contains
|
||||||
// a list of standard resources that would belong on the given resource.
|
// a list of standard resources that would belong on the given resource.
|
||||||
|
|
|
||||||
|
|
@ -6,34 +6,34 @@
|
||||||
// until it is cancelled through the provided context. Updates on the status of
|
// until it is cancelled through the provided context. Updates on the status of
|
||||||
// objects are streamed back to the caller through a channel.
|
// objects are streamed back to the caller through a channel.
|
||||||
//
|
//
|
||||||
// Watching Resources
|
// # Watching Resources
|
||||||
//
|
//
|
||||||
// In order to watch a set of resources objects, create a StatusWatcher
|
// In order to watch a set of resources objects, create a StatusWatcher
|
||||||
// and pass in the list of object identifiers to the Watch function.
|
// and pass in the list of object identifiers to the Watch function.
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "sigs.k8s.io/cli-utils/pkg/kstatus/watcher"
|
// "sigs.k8s.io/cli-utils/pkg/kstatus/watcher"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// ids := []prune.ObjMetadata{
|
// ids := []prune.ObjMetadata{
|
||||||
// {
|
// {
|
||||||
// GroupKind: schema.GroupKind{
|
// GroupKind: schema.GroupKind{
|
||||||
// Group: "apps",
|
// Group: "apps",
|
||||||
// Kind: "Deployment",
|
// Kind: "Deployment",
|
||||||
// },
|
// },
|
||||||
// Name: "dep",
|
// Name: "dep",
|
||||||
// Namespace: "default",
|
// Namespace: "default",
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// statusWatcher := watcher.NewDefaultStatusWatcher(dynamicClient, mapper)
|
// statusWatcher := watcher.NewDefaultStatusWatcher(dynamicClient, mapper)
|
||||||
// ctx, cancelFunc := context.WithCancel(context.Background())
|
// ctx, cancelFunc := context.WithCancel(context.Background())
|
||||||
// eventCh := statusWatcher.Watch(ctx, ids, watcher.Options{})
|
// eventCh := statusWatcher.Watch(ctx, ids, watcher.Options{})
|
||||||
// for e := range eventCh {
|
// for e := range eventCh {
|
||||||
// // Handle event
|
// // Handle event
|
||||||
// if e.Type == event.ErrorEvent {
|
// if e.Type == event.ErrorEvent {
|
||||||
// cancelFunc()
|
// cancelFunc()
|
||||||
// return e.Err
|
// return e.Err
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
package watcher
|
package watcher
|
||||||
|
|
|
||||||
|
|
@ -48,18 +48,18 @@ func (gkn GroupKindNamespace) GroupKind() schema.GroupKind {
|
||||||
// network of informers to watch one or more resources (types).
|
// network of informers to watch one or more resources (types).
|
||||||
//
|
//
|
||||||
// Unlike SharedIndexInformer, ObjectStatusReporter...
|
// Unlike SharedIndexInformer, ObjectStatusReporter...
|
||||||
// - Reports object status.
|
// - Reports object status.
|
||||||
// - Can watch multiple resource types simultaneously.
|
// - Can watch multiple resource types simultaneously.
|
||||||
// - Specific objects can be ignored for efficiency by specifying an ObjectFilter.
|
// - Specific objects can be ignored for efficiency by specifying an ObjectFilter.
|
||||||
// - Resolves GroupKinds into Resources at runtime, to pick up newly added
|
// - Resolves GroupKinds into Resources at runtime, to pick up newly added
|
||||||
// resources.
|
// resources.
|
||||||
// - Starts and Stops individual watches automaically to reduce errors when a
|
// - Starts and Stops individual watches automaically to reduce errors when a
|
||||||
// CRD or Namespace is deleted.
|
// CRD or Namespace is deleted.
|
||||||
// - Resources can be watched in root-scope mode or namespace-scope mode,
|
// - Resources can be watched in root-scope mode or namespace-scope mode,
|
||||||
// allowing the caller to optimize for efficiency or least-privilege.
|
// allowing the caller to optimize for efficiency or least-privilege.
|
||||||
// - Gives unschedulable Pods (and objects that generate them) a 15s grace
|
// - Gives unschedulable Pods (and objects that generate them) a 15s grace
|
||||||
// period before reporting them as Failed.
|
// period before reporting them as Failed.
|
||||||
// - Resets the RESTMapper cache automatically when CRDs are modified.
|
// - Resets the RESTMapper cache automatically when CRDs are modified.
|
||||||
//
|
//
|
||||||
// ObjectStatusReporter is NOT repeatable. It will panic if started more than
|
// ObjectStatusReporter is NOT repeatable. It will panic if started more than
|
||||||
// once. If you need a repeatable factory, use DefaultStatusWatcher.
|
// once. If you need a repeatable factory, use DefaultStatusWatcher.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
package manifestreader
|
package manifestreader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -50,10 +50,10 @@ func TestMReader_Read(t *testing.T) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "reader-test")
|
dir, err := os.MkdirTemp("", "reader-test")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
p := filepath.Join(dir, "dep.yaml")
|
p := filepath.Join(dir, "dep.yaml")
|
||||||
err = ioutil.WriteFile(p, []byte(depManifest), 0600)
|
err = os.WriteFile(p, []byte(depManifest), 0600)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
stringReader := strings.NewReader(depManifest)
|
stringReader := strings.NewReader(depManifest)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
package manifestreader
|
package manifestreader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -56,11 +56,11 @@ func TestPathManifestReader_Read(t *testing.T) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "path-reader-test")
|
dir, err := os.MkdirTemp("", "path-reader-test")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
for filename, content := range tc.manifests {
|
for filename, content := range tc.manifests {
|
||||||
p := filepath.Join(dir, filename)
|
p := filepath.Join(dir, filename)
|
||||||
err := ioutil.WriteFile(p, []byte(content), 0600)
|
err := os.WriteFile(p, []byte(content), 0600)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,9 @@ func ParseDependencySet(depsStr string) (DependencySet, error) {
|
||||||
// Fields are separated by '/'.
|
// Fields are separated by '/'.
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// Cluster-Scoped: <group>/<kind>/<name> (3 fields)
|
//
|
||||||
// Namespaced: <group>/namespaces/<namespace>/<kind>/<name> (5 fields)
|
// Cluster-Scoped: <group>/<kind>/<name> (3 fields)
|
||||||
|
// Namespaced: <group>/namespaces/<namespace>/<kind>/<name> (5 fields)
|
||||||
//
|
//
|
||||||
// Group and namespace may be empty, but name and kind may not.
|
// Group and namespace may be empty, but name and kind may not.
|
||||||
//
|
//
|
||||||
|
|
@ -101,8 +102,9 @@ func FormatObjMetadata(obj object.ObjMetadata) (string, error) {
|
||||||
// Fields are separated by '/'.
|
// Fields are separated by '/'.
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// Cluster-Scoped: <group>/<kind>/<name> (3 fields)
|
//
|
||||||
// Namespaced: <group>/namespaces/<namespace>/<kind>/<name> (5 fields)
|
// Cluster-Scoped: <group>/<kind>/<name> (3 fields)
|
||||||
|
// Namespaced: <group>/namespaces/<namespace>/<kind>/<name> (5 fields)
|
||||||
//
|
//
|
||||||
// Group and namespace may be empty, but name and kind may not.
|
// Group and namespace may be empty, but name and kind may not.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
e1 Edge = Edge{From: o1, To: o2}
|
e1 = Edge{From: o1, To: o2}
|
||||||
e2 Edge = Edge{From: o2, To: o3}
|
e2 = Edge{From: o2, To: o3}
|
||||||
e3 Edge = Edge{From: o1, To: o3}
|
e3 = Edge{From: o1, To: o3}
|
||||||
e4 Edge = Edge{From: o3, To: o4}
|
e4 = Edge{From: o3, To: o4}
|
||||||
e5 Edge = Edge{From: o2, To: o4}
|
e5 = Edge{From: o2, To: o4}
|
||||||
e6 Edge = Edge{From: o2, To: o1}
|
e6 = Edge{From: o2, To: o1}
|
||||||
e7 Edge = Edge{From: o3, To: o1}
|
e7 = Edge{From: o3, To: o1}
|
||||||
e8 Edge = Edge{From: o4, To: o5}
|
e8 = Edge{From: o4, To: o5}
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestObjectGraphSort(t *testing.T) {
|
func TestObjectGraphSort(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ type ObjMetadata struct {
|
||||||
// and returns an ObjMetadata struct storing the four fields.
|
// and returns an ObjMetadata struct storing the four fields.
|
||||||
// Example inventory string:
|
// Example inventory string:
|
||||||
//
|
//
|
||||||
// test-namespace_test-name_apps_ReplicaSet
|
// test-namespace_test-name_apps_ReplicaSet
|
||||||
//
|
//
|
||||||
// Returns an error if unable to parse and create the ObjMetadata struct.
|
// Returns an error if unable to parse and create the ObjMetadata struct.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ func (sc *StatusCollector) LatestStatus() map[object.ObjMetadata]event.StatusEve
|
||||||
// format on StdOut. As we support other printer implementations
|
// format on StdOut. As we support other printer implementations
|
||||||
// this should probably be an interface.
|
// this should probably be an interface.
|
||||||
// This function will block until the channel is closed.
|
// This function will block until the channel is closed.
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func (b *BaseListPrinter) Print(ch <-chan event.Event, previewStrategy common.DryRunStrategy, printStatus bool) error {
|
func (b *BaseListPrinter) Print(ch <-chan event.Event, previewStrategy common.DryRunStrategy, printStatus bool) error {
|
||||||
var actionGroups []event.ActionGroup
|
var actionGroups []event.ActionGroup
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,18 @@
|
||||||
// appear as a stream of json objects, each representing a single event.
|
// appear as a stream of json objects, each representing a single event.
|
||||||
//
|
//
|
||||||
// Every event will contain the following properties:
|
// Every event will contain the following properties:
|
||||||
// * timestamp: RFC3339-formatted timestamp describing when the event happened.
|
// - timestamp: RFC3339-formatted timestamp describing when the event happened.
|
||||||
// * type: Describes the type of the operation which the event is related to.
|
// - type: Describes the type of the operation which the event is related to.
|
||||||
// Type values include:
|
// Type values include:
|
||||||
// * validation - ValidationEvent
|
// - validation - ValidationEvent
|
||||||
// * error - ErrorEvent
|
// - error - ErrorEvent
|
||||||
// * group - ActionGroupEvent
|
// - group - ActionGroupEvent
|
||||||
// * apply - ApplyEvent
|
// - apply - ApplyEvent
|
||||||
// * prune - PruneEvent
|
// - prune - PruneEvent
|
||||||
// * delete - DeleteEvent
|
// - delete - DeleteEvent
|
||||||
// * wait - WaitEvent
|
// - wait - WaitEvent
|
||||||
// * status - StatusEvent
|
// - status - StatusEvent
|
||||||
// * summary - aggregate stats collected by the printer
|
// - summary - aggregate stats collected by the printer
|
||||||
//
|
//
|
||||||
// Validation events correspond to zero or more objects. For these events, the
|
// Validation events correspond to zero or more objects. For these events, the
|
||||||
// objects field includes a list of object identifiers. These generally fire
|
// objects field includes a list of object identifiers. These generally fire
|
||||||
|
|
@ -25,10 +25,11 @@
|
||||||
//
|
//
|
||||||
// Validation events have the following fields:
|
// Validation events have the following fields:
|
||||||
// * objects (array of objects) - a list of object identifiers
|
// * objects (array of objects) - a list of object identifiers
|
||||||
// * group (string, optional) - The object's API group.
|
// - group (string, optional) - The object's API group.
|
||||||
// * kind (string) - The object's kind.
|
// - kind (string) - The object's kind.
|
||||||
// * name (string) - The object's name.
|
// - name (string) - The object's name.
|
||||||
// * namespace (string, optional) - The object's namespace.
|
// - namespace (string, optional) - The object's namespace.
|
||||||
|
//
|
||||||
// * timestamp (string) - ISO-8601 format
|
// * timestamp (string) - ISO-8601 format
|
||||||
// * type (string) - "validation"
|
// * type (string) - "validation"
|
||||||
// * error (string) - a fatal error message specific to these objects
|
// * error (string) - a fatal error message specific to these objects
|
||||||
|
|
@ -55,29 +56,29 @@
|
||||||
// group, kind, name, and namespace fields identify the object.
|
// group, kind, name, and namespace fields identify the object.
|
||||||
//
|
//
|
||||||
// Operation events have the following fields:
|
// Operation events have the following fields:
|
||||||
// * group (string, optional) - The object's API group.
|
// - group (string, optional) - The object's API group.
|
||||||
// * kind (string) - The object's kind.
|
// - kind (string) - The object's kind.
|
||||||
// * name (string) - The object's name.
|
// - name (string) - The object's name.
|
||||||
// * namespace (string, optional) - The object's namespace.
|
// - namespace (string, optional) - The object's namespace.
|
||||||
// * status (string) - One of: "Pending", "Successful", "Skipped", "Failed", or
|
// - status (string) - One of: "Pending", "Successful", "Skipped", "Failed", or
|
||||||
// "Timeout".
|
// "Timeout".
|
||||||
// * timestamp (string) - ISO-8601 format
|
// - timestamp (string) - ISO-8601 format
|
||||||
// * type (string) - "apply", "prune", "delete", or "wait"
|
// - type (string) - "apply", "prune", "delete", or "wait"
|
||||||
// * error (string, optional) - A non-fatal error message specific to this object
|
// - error (string, optional) - A non-fatal error message specific to this object
|
||||||
//
|
//
|
||||||
// Status types are asynchronous events that correspond to status updates for
|
// Status types are asynchronous events that correspond to status updates for
|
||||||
// a specific object.
|
// a specific object.
|
||||||
//
|
//
|
||||||
// Status events have the following fields:
|
// Status events have the following fields:
|
||||||
// * group (string, optional) - The object's API group.
|
// - group (string, optional) - The object's API group.
|
||||||
// * kind (string) - The object's kind.
|
// - kind (string) - The object's kind.
|
||||||
// * name (string) - The object's name.
|
// - name (string) - The object's name.
|
||||||
// * namespace (string, optional) - The object's namespace.
|
// - namespace (string, optional) - The object's namespace.
|
||||||
// * status (string) - One of: "InProgress", "Failed", "Current", "Terminating",
|
// - status (string) - One of: "InProgress", "Failed", "Current", "Terminating",
|
||||||
// "NotFound", or "Unknown".
|
// "NotFound", or "Unknown".
|
||||||
// * message (string) - Human readable description of the status.
|
// - message (string) - Human readable description of the status.
|
||||||
// * timestamp (string) - ISO-8601 format
|
// - timestamp (string) - ISO-8601 format
|
||||||
// * type (string) - "status"
|
// - type (string) - "status"
|
||||||
//
|
//
|
||||||
// Summary types are a meta-event sent by the printer to summarize some stats
|
// Summary types are a meta-event sent by the printer to summarize some stats
|
||||||
// that have been collected from other events. For these events, the action
|
// that have been collected from other events. For these events, the action
|
||||||
|
|
@ -93,5 +94,4 @@
|
||||||
// * timeout (number, optional) - Number of objects for which the action timed out.
|
// * timeout (number, optional) - Number of objects for which the action timed out.
|
||||||
// * timestamp (string) - ISO-8601 format
|
// * timestamp (string) - ISO-8601 format
|
||||||
// * type (string) - "summary"
|
// * type (string) - "summary"
|
||||||
//
|
|
||||||
package json
|
package json
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func (t *Printer) Print(ch <-chan event.Event, _ common.DryRunStrategy, _ bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// columns defines the columns we want to print
|
// columns defines the columns we want to print
|
||||||
//TODO: We should have the number of columns and their widths be
|
// TODO: We should have the number of columns and their widths be
|
||||||
// dependent on the space available.
|
// dependent on the space available.
|
||||||
var (
|
var (
|
||||||
actionColumnDef = table.ColumnDef{
|
actionColumnDef = table.ColumnDef{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
package testutil
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -22,7 +21,7 @@ type TestFilesystem struct {
|
||||||
// the TestFilesystem.
|
// the TestFilesystem.
|
||||||
func Setup(t *testing.T, dirs ...string) TestFilesystem {
|
func Setup(t *testing.T, dirs ...string) TestFilesystem {
|
||||||
tempDir := "" // Use the default temp directory
|
tempDir := "" // Use the default temp directory
|
||||||
d, err := ioutil.TempDir(tempDir, "test-filesystem")
|
d, err := os.MkdirTemp(tempDir, "test-filesystem")
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +51,7 @@ func (tf TestFilesystem) WriteFile(t *testing.T, path string, value []byte) {
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(filepath.Join(tf.root, path), value, 0600)
|
err = os.WriteFile(filepath.Join(tf.root, path), value, 0600)
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue