Rename variable, constants and struct fields following stylecheck linter recommendation

This commit is contained in:
Arthur Mello
2019-12-05 22:39:29 -03:00
parent f2c7066088
commit e811da14d8
14 changed files with 25 additions and 25 deletions

View File

@@ -111,7 +111,7 @@ func (r *CatRunner) runE(c *cobra.Command, args []string) error {
Writer: c.OutOrStdout(),
KeepReaderAnnotations: r.KeepAnnotations,
WrappingKind: r.WrapKind,
WrappingApiVersion: r.WrapApiVersion,
WrappingAPIVersion: r.WrapApiVersion,
FunctionConfig: functionConfig,
Style: yaml.GetStyle(r.Styles...),
})

View File

@@ -134,7 +134,7 @@ func (r *WrapRunner) runE(c *cobra.Command, args []string) error {
KeepReaderAnnotations: true,
Writer: c.OutOrStdout(),
WrappingKind: kio.ResourceListKind,
WrappingApiVersion: kio.ResourceListApiVersion}}}.Execute()
WrappingAPIVersion: kio.ResourceListAPIVersion}}}.Execute()
if err != nil {
return err
}

View File

@@ -186,7 +186,7 @@ func (r *XArgsRunner) runE(c *cobra.Command, _ []string) error {
if version := rw.FunctionConfig.Field("apiVersion"); !yaml.IsFieldEmpty(version) {
version.Value.YNode().Value = r.WrapVersion
}
rw.WrappingApiVersion = r.WrapVersion
rw.WrappingAPIVersion = r.WrapVersion
}
return nil
}(); err != nil {

View File

@@ -17,7 +17,7 @@ import (
const (
ResourceListKind = "ResourceList"
ResourceListApiVersion = "config.kubernetes.io/v1alpha1"
ResourceListAPIVersion = "config.kubernetes.io/v1alpha1"
)
// ByteReadWriter reads from an input and writes to an output.
@@ -41,7 +41,7 @@ type ByteReadWriter struct {
FunctionConfig *yaml.RNode
WrappingApiVersion string
WrappingAPIVersion string
WrappingKind string
}
@@ -52,7 +52,7 @@ func (rw *ByteReadWriter) Read() ([]*yaml.RNode, error) {
}
val, err := b.Read()
rw.FunctionConfig = b.FunctionConfig
rw.WrappingApiVersion = b.WrappingApiVersion
rw.WrappingAPIVersion = b.WrappingAPIVersion
rw.WrappingKind = b.WrappingKind
return val, errors.Wrap(err)
}
@@ -63,7 +63,7 @@ func (rw *ByteReadWriter) Write(nodes []*yaml.RNode) error {
KeepReaderAnnotations: rw.KeepReaderAnnotations,
Style: rw.Style,
FunctionConfig: rw.FunctionConfig,
WrappingApiVersion: rw.WrappingApiVersion,
WrappingAPIVersion: rw.WrappingAPIVersion,
WrappingKind: rw.WrappingKind,
}.Write(nodes)
}
@@ -88,9 +88,9 @@ type ByteReader struct {
// DisableUnwrapping prevents Resources in Lists and ResourceLists from being unwrapped
DisableUnwrapping bool
// WrappingApiVersion is set by Read(), and is the apiVersion of the object that
// WrappingAPIVersion is set by Read(), and is the apiVersion of the object that
// the read objects were originally wrapped in.
WrappingApiVersion string
WrappingAPIVersion string
// WrappingKind is set by Read(), and is the kind of the object that
// the read objects were originally wrapped in.
@@ -140,7 +140,7 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) {
node.Field("items") != nil {
r.WrappingKind = meta.Kind
r.WrappingApiVersion = meta.ApiVersion
r.WrappingAPIVersion = meta.APIVersion
// unwrap the list
fc := node.Field("functionConfig")

View File

@@ -86,7 +86,7 @@ elems:
`, r.FunctionConfig.MustString())
assert.Equal(t, ResourceListKind, r.WrappingKind)
assert.Equal(t, ResourceListApiVersion, r.WrappingApiVersion)
assert.Equal(t, ResourceListAPIVersion, r.WrappingAPIVersion)
}
@@ -131,7 +131,7 @@ spec:
// verify the function config
assert.Nil(t, r.FunctionConfig)
assert.Equal(t, "List", r.WrappingKind)
assert.Equal(t, "v1", r.WrappingApiVersion)
assert.Equal(t, "v1", r.WrappingAPIVersion)
}
// TestByteReader_Read tests the default Read behavior

View File

@@ -35,8 +35,8 @@ type ByteWriter struct {
// ByteWriter will wrap the Resources in a List .items field.
WrappingKind string
// WrappingApiVersion is the apiVersion for WrappingKind
WrappingApiVersion string
// WrappingAPIVersion is the apiVersion for WrappingKind
WrappingAPIVersion string
// Sort if set, will cause ByteWriter to sort the the nodes before writing them.
Sort bool
@@ -102,7 +102,7 @@ func (w ByteWriter) Write(nodes []*yaml.RNode) error {
Style: w.Style,
Content: []*yaml.Node{
{Kind: yaml.ScalarNode, Value: "apiVersion"},
{Kind: yaml.ScalarNode, Value: w.WrappingApiVersion},
{Kind: yaml.ScalarNode, Value: w.WrappingAPIVersion},
{Kind: yaml.ScalarNode, Value: "kind"},
{Kind: yaml.ScalarNode, Value: w.WrappingKind},
{Kind: yaml.ScalarNode, Value: "items"}, items,

View File

@@ -40,7 +40,7 @@ g:
Writer: buff,
FunctionConfig: node3,
WrappingKind: ResourceListKind,
WrappingApiVersion: ResourceListApiVersion}.
WrappingAPIVersion: ResourceListAPIVersion}.
Write([]*yaml.RNode{node2, node1})
if !assert.NoError(t, err) {
return

View File

@@ -78,7 +78,7 @@ func (c *ContainerFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
// write the input
err = kio.ByteWriter{
WrappingApiVersion: kio.ResourceListApiVersion,
WrappingAPIVersion: kio.ResourceListAPIVersion,
WrappingKind: kio.ResourceListKind,
Writer: in, KeepReaderAnnotations: true, FunctionConfig: c.Config}.Write(input)
if err != nil {

View File

@@ -459,7 +459,7 @@ func TestFormatFileOrDirectory_YamlExtFileWithJson(t *testing.T) {
f, err := ioutil.TempFile("", "yamlfmt*.yaml")
assert.NoError(t, err)
defer os.Remove(f.Name())
err = ioutil.WriteFile(f.Name(), testyaml.UnformattedJson1, 0600)
err = ioutil.WriteFile(f.Name(), testyaml.UnformattedJSON1, 0600)
assert.NoError(t, err)
// format the file

View File

@@ -44,7 +44,7 @@ func (c MergeFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
return nil, err
}
key := mergeKey{
apiVersion: meta.ApiVersion,
apiVersion: meta.APIVersion,
kind: meta.Kind,
namespace: meta.Namespace,
name: meta.Name,

View File

@@ -113,7 +113,7 @@ func (ts *tuples) add(node *yaml.RNode) error {
for i := range ts.list {
t := ts.list[i]
if t.meta.Name == nodeMeta.Name && t.meta.Namespace == nodeMeta.Namespace &&
t.meta.ApiVersion == nodeMeta.ApiVersion && t.meta.Kind == nodeMeta.Kind {
t.meta.APIVersion == nodeMeta.APIVersion && t.meta.Kind == nodeMeta.Kind {
return t.add(node)
}
}

View File

@@ -27,7 +27,7 @@ apiVersion: example.com/v1beta1
kind: MyType2
`)
var UnformattedJson1 = []byte(`
var UnformattedJSON1 = []byte(`
{
"spec": "a",
"status": {"conditions": [3, 1, 2]},

View File

@@ -285,8 +285,8 @@ func compareNodes(i, j *yaml.RNode) bool {
}
// compare apiVersion
if metai.ApiVersion != metaj.ApiVersion {
return metai.ApiVersion < metaj.ApiVersion
if metai.APIVersion != metaj.APIVersion {
return metai.APIVersion < metaj.APIVersion
}
return true
}

View File

@@ -221,8 +221,8 @@ func (m MapNodeSlice) Values() []*RNode {
// ResourceMeta contains the metadata for a both Resource Type and Resource.
type ResourceMeta struct {
// ApiVersion is the apiVersion field of a Resource
ApiVersion string `yaml:"apiVersion,omitempty"`
// APIVersion is the apiVersion field of a Resource
APIVersion string `yaml:"apiVersion,omitempty"`
// Kind is the kind field of a Resource
Kind string `yaml:"kind,omitempty"`
// ObjectMeta is the metadata field of a Resource