Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
9a9a1e09
Commit
9a9a1e09
authored
Nov 30, 2014
by
Sam Ghods
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move from go-yaml/yaml to ghodss/yaml
parent
603ec338
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
60 additions
and
121 deletions
+60
-121
enscope.go
contrib/enscope/enscope.go
+1
-1
podex.go
contrib/podex/podex.go
+1
-1
simplegen.go
contrib/simplegen/simplegen.go
+1
-1
srvexpand.go
contrib/srvexpand/srvexpand.go
+1
-1
serialization_test.go
pkg/api/serialization_test.go
+10
-1
decode.go
pkg/conversion/decode.go
+1
-1
meta.go
pkg/conversion/meta.go
+1
-1
scheme_test.go
pkg/conversion/scheme_test.go
+1
-1
kubecfg.go
pkg/kubecfg/kubecfg.go
+1
-1
parse_test.go
pkg/kubecfg/parse_test.go
+1
-1
resource_printer.go
pkg/kubecfg/resource_printer.go
+1
-1
resource_printer_test.go
pkg/kubecfg/resource_printer_test.go
+1
-1
createall.go
pkg/kubectl/cmd/createall.go
+1
-1
resource_printer.go
pkg/kubectl/resource_printer.go
+1
-1
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+1
-1
config.go
pkg/kubelet/config/config.go
+1
-1
config_test.go
pkg/kubelet/config/config_test.go
+5
-2
file.go
pkg/kubelet/config/file.go
+4
-3
file_test.go
pkg/kubelet/config/file_test.go
+1
-1
http.go
pkg/kubelet/config/http.go
+1
-1
server.go
pkg/kubelet/server.go
+1
-1
types.go
pkg/kubelet/types.go
+4
-0
embedded.go
pkg/runtime/embedded.go
+0
-86
extension.go
pkg/runtime/extension.go
+1
-1
diff.go
pkg/util/diff.go
+14
-6
time_test.go
pkg/util/time_test.go
+3
-3
util_test.go
pkg/util/util_test.go
+1
-1
No files found.
contrib/enscope/enscope.go
View file @
9a9a1e09
...
@@ -23,8 +23,8 @@ import (
...
@@ -23,8 +23,8 @@ import (
"os"
"os"
"strings"
"strings"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
const
usage
=
"usage: enscope specFilename configFilename"
const
usage
=
"usage: enscope specFilename configFilename"
...
...
contrib/podex/podex.go
View file @
9a9a1e09
...
@@ -37,7 +37,7 @@ import (
...
@@ -37,7 +37,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
dockerclient
"github.com/fsouza/go-dockerclient"
dockerclient
"github.com/fsouza/go-dockerclient"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
const
usage
=
"usage: podex [-json|-yaml] [-id PODNAME] IMAGES"
const
usage
=
"usage: podex [-json|-yaml] [-id PODNAME] IMAGES"
...
...
contrib/simplegen/simplegen.go
View file @
9a9a1e09
...
@@ -35,8 +35,8 @@ import (
...
@@ -35,8 +35,8 @@ import (
// TODO: handle multiple versions correctly
// TODO: handle multiple versions correctly
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
// TODO: Also handle lists of simple services, and multiple input files
// TODO: Also handle lists of simple services, and multiple input files
...
...
contrib/srvexpand/srvexpand.go
View file @
9a9a1e09
...
@@ -45,8 +45,8 @@ import (
...
@@ -45,8 +45,8 @@ import (
// it should be possible to specify the version for the whole map.
// it should be possible to specify the version for the whole map.
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
const
usage
=
"usage: srvexpand filename"
const
usage
=
"usage: srvexpand filename"
...
...
pkg/api/serialization_test.go
View file @
9a9a1e09
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"reflect"
"reflect"
"strconv"
"strconv"
"testing"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
...
@@ -138,6 +139,14 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
...
@@ -138,6 +139,14 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
c
.
RandString
()
:
c
.
RandString
(),
c
.
RandString
()
:
c
.
RandString
(),
}
}
},
},
func
(
t
*
time
.
Time
,
c
fuzz
.
Continue
)
{
// This is necessary because the standard fuzzed time.Time object is
// completely nil, but when JSON unmarshals dates it fills in the
// unexported loc field with the time.UTC object, resulting in
// reflect.DeepEqual returning false in the round trip tests. We solve it
// by using a date that will be identical to the one JSON unmarshals.
*
t
=
time
.
Date
(
2000
,
1
,
1
,
1
,
1
,
1
,
0
,
time
.
UTC
)
},
)
)
func
runTest
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
source
runtime
.
Object
)
{
func
runTest
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
source
runtime
.
Object
)
{
...
@@ -162,7 +171,7 @@ func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
...
@@ -162,7 +171,7 @@ func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
return
return
}
}
if
!
reflect
.
DeepEqual
(
source
,
obj2
)
{
if
!
reflect
.
DeepEqual
(
source
,
obj2
)
{
t
.
Errorf
(
"1: %v: diff: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v"
,
name
,
util
.
ObjectDiff
(
source
,
obj2
),
codec
,
string
(
data
),
source
)
t
.
Errorf
(
"1: %v: diff: %v
\n
Codec: %v
\n
Data: %s
\n
Source: %#v"
,
name
,
util
.
Object
GoPrint
Diff
(
source
,
obj2
),
codec
,
string
(
data
),
source
)
return
return
}
}
...
...
pkg/conversion/decode.go
View file @
9a9a1e09
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
// Decode converts a YAML or JSON string back into a pointer to an api object.
// Decode converts a YAML or JSON string back into a pointer to an api object.
...
...
pkg/conversion/meta.go
View file @
9a9a1e09
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"reflect"
"reflect"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
// MetaFactory is used to store and retrieve the version and kind
// MetaFactory is used to store and retrieve the version and kind
...
...
pkg/conversion/scheme_test.go
View file @
9a9a1e09
...
@@ -26,8 +26,8 @@ import (
...
@@ -26,8 +26,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/google/gofuzz"
"github.com/google/gofuzz"
"gopkg.in/v1/yaml"
)
)
var
fuzzIters
=
flag
.
Int
(
"fuzz_iters"
,
50
,
"How many fuzzing iterations to do."
)
var
fuzzIters
=
flag
.
Int
(
"fuzz_iters"
,
50
,
"How many fuzzing iterations to do."
)
...
...
pkg/kubecfg/kubecfg.go
View file @
9a9a1e09
...
@@ -33,8 +33,8 @@ import (
...
@@ -33,8 +33,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
func
GetServerVersion
(
client
*
client
.
Client
)
(
*
version
.
Info
,
error
)
{
func
GetServerVersion
(
client
*
client
.
Client
)
(
*
version
.
Info
,
error
)
{
...
...
pkg/kubecfg/parse_test.go
View file @
9a9a1e09
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
func
TestParseBadStorage
(
t
*
testing
.
T
)
{
func
TestParseBadStorage
(
t
*
testing
.
T
)
{
...
...
pkg/kubecfg/resource_printer.go
View file @
9a9a1e09
...
@@ -29,8 +29,8 @@ import (
...
@@ -29,8 +29,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
// ResourcePrinter is an interface that knows how to print API resources.
// ResourcePrinter is an interface that knows how to print API resources.
...
...
pkg/kubecfg/resource_printer_test.go
View file @
9a9a1e09
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
func
TestYAMLPrinterPrint
(
t
*
testing
.
T
)
{
func
TestYAMLPrinterPrint
(
t
*
testing
.
T
)
{
...
...
pkg/kubectl/cmd/createall.go
View file @
9a9a1e09
...
@@ -24,9 +24,9 @@ import (
...
@@ -24,9 +24,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/config"
"github.com/GoogleCloudPlatform/kubernetes/pkg/config"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"gopkg.in/v1/yaml"
)
)
// DataToObjects converts the raw JSON data into API objects
// DataToObjects converts the raw JSON data into API objects
...
...
pkg/kubectl/resource_printer.go
View file @
9a9a1e09
...
@@ -29,8 +29,8 @@ import (
...
@@ -29,8 +29,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
// GetPrinter takes a format type, an optional format argument, a version and a convertor
// GetPrinter takes a format type, an optional format argument, a version and a convertor
...
...
pkg/kubectl/resource_printer_test.go
View file @
9a9a1e09
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
type
testStruct
struct
{
type
testStruct
struct
{
...
...
pkg/kubelet/config/config.go
View file @
9a9a1e09
...
@@ -287,7 +287,7 @@ func (s *podStorage) Sync() {
...
@@ -287,7 +287,7 @@ func (s *podStorage) Sync() {
func
(
s
*
podStorage
)
MergedState
()
interface
{}
{
func
(
s
*
podStorage
)
MergedState
()
interface
{}
{
s
.
podLock
.
RLock
()
s
.
podLock
.
RLock
()
defer
s
.
podLock
.
RUnlock
()
defer
s
.
podLock
.
RUnlock
()
var
pods
[]
api
.
BoundPod
pods
:=
make
([]
api
.
BoundPod
,
0
)
for
_
,
sourcePods
:=
range
s
.
pods
{
for
_
,
sourcePods
:=
range
s
.
pods
{
for
_
,
podRef
:=
range
sourcePods
{
for
_
,
podRef
:=
range
sourcePods
{
pod
,
err
:=
api
.
Scheme
.
Copy
(
podRef
)
pod
,
err
:=
api
.
Scheme
.
Copy
(
podRef
)
...
...
pkg/kubelet/config/config_test.go
View file @
9a9a1e09
...
@@ -59,10 +59,13 @@ func CreateValidPod(name, namespace, source string) api.BoundPod {
...
@@ -59,10 +59,13 @@ func CreateValidPod(name, namespace, source string) api.BoundPod {
}
}
func
CreatePodUpdate
(
op
kubelet
.
PodOperation
,
pods
...
api
.
BoundPod
)
kubelet
.
PodUpdate
{
func
CreatePodUpdate
(
op
kubelet
.
PodOperation
,
pods
...
api
.
BoundPod
)
kubelet
.
PodUpdate
{
// We deliberately return an empty slice instead of a nil pointer here
// because reflect.DeepEqual differentiates between the two and we need to
// pick one for consistency.
newPods
:=
make
([]
api
.
BoundPod
,
len
(
pods
))
if
len
(
pods
)
==
0
{
if
len
(
pods
)
==
0
{
return
kubelet
.
PodUpdate
{
Op
:
op
}
return
kubelet
.
PodUpdate
{
newPods
,
op
}
}
}
newPods
:=
make
([]
api
.
BoundPod
,
len
(
pods
))
for
i
:=
range
pods
{
for
i
:=
range
pods
{
newPods
[
i
]
=
pods
[
i
]
newPods
[
i
]
=
pods
[
i
]
}
}
...
...
pkg/kubelet/config/file.go
View file @
9a9a1e09
...
@@ -33,8 +33,8 @@ import (
...
@@ -33,8 +33,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
type
sourceFile
struct
{
type
sourceFile
struct
{
...
@@ -97,12 +97,13 @@ func extractFromDir(name string) ([]api.BoundPod, error) {
...
@@ -97,12 +97,13 @@ func extractFromDir(name string) ([]api.BoundPod, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"glob failed: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"glob failed: %v"
,
err
)
}
}
pods
:=
make
([]
api
.
BoundPod
,
0
)
if
len
(
dirents
)
==
0
{
if
len
(
dirents
)
==
0
{
return
nil
,
nil
return
pods
,
nil
}
}
sort
.
Strings
(
dirents
)
sort
.
Strings
(
dirents
)
pods
:=
[]
api
.
BoundPod
{}
for
_
,
path
:=
range
dirents
{
for
_
,
path
:=
range
dirents
{
statInfo
,
err
:=
os
.
Stat
(
path
)
statInfo
,
err
:=
os
.
Stat
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubelet/config/file_test.go
View file @
9a9a1e09
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
func
ExampleManifestAndPod
(
id
string
)
(
api
.
ContainerManifest
,
api
.
BoundPod
)
{
func
ExampleManifestAndPod
(
id
string
)
(
api
.
ContainerManifest
,
api
.
BoundPod
)
{
...
...
pkg/kubelet/config/http.go
View file @
9a9a1e09
...
@@ -29,8 +29,8 @@ import (
...
@@ -29,8 +29,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"gopkg.in/v1/yaml"
)
)
type
sourceURL
struct
{
type
sourceURL
struct
{
...
...
pkg/kubelet/server.go
View file @
9a9a1e09
...
@@ -35,9 +35,9 @@ import (
...
@@ -35,9 +35,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/google/cadvisor/info"
"github.com/google/cadvisor/info"
"gopkg.in/v1/yaml"
)
)
// Server is a http.Handler which exposes kubelet functionality over HTTP.
// Server is a http.Handler which exposes kubelet functionality over HTTP.
...
...
pkg/kubelet/types.go
View file @
9a9a1e09
...
@@ -43,6 +43,10 @@ const (
...
@@ -43,6 +43,10 @@ const (
// For setting the state of the system to a given state for this source configuration, set
// For setting the state of the system to a given state for this source configuration, set
// Pods as desired and Op to SET, which will reset the system state to that specified in this
// Pods as desired and Op to SET, which will reset the system state to that specified in this
// operation for this source channel. To remove all pods, set Pods to empty object and Op to SET.
// operation for this source channel. To remove all pods, set Pods to empty object and Op to SET.
//
// Additionally, Pods should never be nil - it should always point to an empty slice. While
// functionally similar, this helps our unit tests properly check that the correct PodUpdates
// are generated.
type
PodUpdate
struct
{
type
PodUpdate
struct
{
Pods
[]
api
.
BoundPod
Pods
[]
api
.
BoundPod
Op
PodOperation
Op
PodOperation
...
...
pkg/runtime/embedded.go
deleted
100644 → 0
View file @
603ec338
/*
Copyright 2014 Google Inc. All rights reserved.
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.
*/
package
runtime
import
(
"gopkg.in/v1/yaml"
)
// Encode()/Decode() are the canonical way of converting an API object to/from
// wire format. This file provides utility functions which permit doing so
// recursively, such that API objects of types known only at run time can be
// embedded within other API types.
// UnmarshalJSON implements the json.Unmarshaler interface.
func
CodecUnmarshalJSON
(
codec
Codec
,
b
[]
byte
)
(
Object
,
error
)
{
// Handle JSON's "null": Decode() doesn't expect it.
if
len
(
b
)
==
4
&&
string
(
b
)
==
"null"
{
return
nil
,
nil
}
obj
,
err
:=
codec
.
Decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
return
obj
,
nil
}
// MarshalJSON implements the json.Marshaler interface.
func
CodecMarshalJSON
(
codec
Codec
,
obj
Object
)
([]
byte
,
error
)
{
if
obj
==
nil
{
// Encode unset/nil objects as JSON's "null".
return
[]
byte
(
"null"
),
nil
}
return
codec
.
Encode
(
obj
)
}
// SetYAML implements the yaml.Setter interface.
func
CodecSetYAML
(
codec
Codec
,
tag
string
,
value
interface
{})
(
Object
,
bool
)
{
if
value
==
nil
{
return
nil
,
true
}
// Why does the yaml package send value as a map[interface{}]interface{}?
// It's especially frustrating because encoding/json does the right thing
// by giving a []byte. So here we do the embarrasing thing of re-encode and
// de-encode the right way.
// TODO: Write a version of Decode that uses reflect to turn this value
// into an API object.
b
,
err
:=
yaml
.
Marshal
(
value
)
if
err
!=
nil
{
panic
(
"yaml can't reverse its own object"
)
}
obj
,
err
:=
codec
.
Decode
(
b
)
if
err
!=
nil
{
return
nil
,
false
}
return
obj
,
true
}
// GetYAML implements the yaml.Getter interface.
func
CodecGetYAML
(
codec
Codec
,
obj
Object
)
(
tag
string
,
value
interface
{})
{
if
obj
==
nil
{
value
=
"null"
return
}
// Encode returns JSON, which is conveniently a subset of YAML.
v
,
err
:=
codec
.
Encode
(
obj
)
if
err
!=
nil
{
panic
(
"impossible to encode API object!"
)
}
return
tag
,
v
}
pkg/runtime/extension.go
View file @
9a9a1e09
...
@@ -19,7 +19,7 @@ package runtime
...
@@ -19,7 +19,7 @@ package runtime
import
(
import
(
"errors"
"errors"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
func
(
re
*
RawExtension
)
UnmarshalJSON
(
in
[]
byte
)
error
{
func
(
re
*
RawExtension
)
UnmarshalJSON
(
in
[]
byte
)
error
{
...
...
pkg/util/diff.go
View file @
9a9a1e09
...
@@ -19,6 +19,8 @@ package util
...
@@ -19,6 +19,8 @@ package util
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/davecgh/go-spew/spew"
)
)
// StringDiff diffs a and b and returns a human readable diff.
// StringDiff diffs a and b and returns a human readable diff.
...
@@ -56,13 +58,19 @@ func ObjectDiff(a, b interface{}) string {
...
@@ -56,13 +58,19 @@ func ObjectDiff(a, b interface{}) string {
return
StringDiff
(
string
(
ab
),
string
(
bb
))
return
StringDiff
(
string
(
ab
),
string
(
bb
))
}
}
// ObjectGoPrintDiff is like ObjectDiff, but uses go's %#v formatter to print the
// ObjectGoPrintDiff is like ObjectDiff, but uses go-spew to print the objects,
// objects, in case json isn't showing you the difference. (reflect.DeepEqual makes
// which shows absolutely everything by recursing into every single pointer
// a distinction between nil and empty slices, for example, even though nothing else
// (go's %#v formatters OTOH stop at a certain point). This is needed when you
// really does.)
// can't figure out why reflect.DeepEqual is returning false and nothing is
// showing you differences. This will.
func
ObjectGoPrintDiff
(
a
,
b
interface
{})
string
{
func
ObjectGoPrintDiff
(
a
,
b
interface
{})
string
{
s
:=
spew
.
ConfigState
{
Indent
:
" "
,
// Extra deep spew.
DisableMethods
:
true
,
}
return
StringDiff
(
return
StringDiff
(
fmt
.
Sprintf
(
"%#v"
,
a
),
s
.
Sdump
(
a
),
fmt
.
Sprintf
(
"%#v"
,
b
),
s
.
Sdump
(
b
),
)
)
}
}
pkg/util/time_test.go
View file @
9a9a1e09
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"testing"
"testing"
"time"
"time"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
type
TimeHolder
struct
{
type
TimeHolder
struct
{
...
@@ -34,7 +34,7 @@ func TestTimeMarshalYAML(t *testing.T) {
...
@@ -34,7 +34,7 @@ func TestTimeMarshalYAML(t *testing.T) {
input
Time
input
Time
result
string
result
string
}{
}{
{
Time
{},
"t:
\"
null
\"
\n
"
},
{
Time
{},
"t:
null
\n
"
},
{
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
50
,
time
.
UTC
),
"t: 1998-05-05T05:05:05Z
\n
"
},
{
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
50
,
time
.
UTC
),
"t: 1998-05-05T05:05:05Z
\n
"
},
{
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
0
,
time
.
UTC
),
"t: 1998-05-05T05:05:05Z
\n
"
},
{
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
0
,
time
.
UTC
),
"t: 1998-05-05T05:05:05Z
\n
"
},
}
}
...
@@ -56,7 +56,7 @@ func TestTimeUnmarshalYAML(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestTimeUnmarshalYAML(t *testing.T) {
input
string
input
string
result
Time
result
Time
}{
}{
{
"t:
\"
null
\"
\n
"
,
Time
{}},
{
"t:
null
\n
"
,
Time
{}},
{
"t: 1998-05-05T05:05:05Z
\n
"
,
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
0
,
time
.
UTC
)},
{
"t: 1998-05-05T05:05:05Z
\n
"
,
Date
(
1998
,
time
.
May
,
5
,
5
,
5
,
5
,
0
,
time
.
UTC
)},
}
}
...
...
pkg/util/util_test.go
View file @
9a9a1e09
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"reflect"
"reflect"
"testing"
"testing"
"g
opkg.in/v1
/yaml"
"g
ithub.com/ghodss
/yaml"
)
)
func
TestHandleCrash
(
t
*
testing
.
T
)
{
func
TestHandleCrash
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment