"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "operator/pkg/object/objects.go" between
istio-1.10.0.tar.gz and istio-1.10.1.tar.gz

About: Istio is a platform-independent service mesh that provides a uniform way to connect, secure, control, and observe microservices.

objects.go  (istio-1.10.0):objects.go  (istio-1.10.1)
skipping to change at line 31 skipping to change at line 31
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"sort" "sort"
"strings" "strings"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
k8syaml "k8s.io/apimachinery/pkg/util/yaml" k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"istio.io/istio/operator/pkg/apis/istio/v1alpha1" "istio.io/istio/operator/pkg/apis/istio/v1alpha1"
"istio.io/istio/operator/pkg/helm" "istio.io/istio/operator/pkg/helm"
names "istio.io/istio/operator/pkg/name" names "istio.io/istio/operator/pkg/name"
"istio.io/istio/operator/pkg/tpath" "istio.io/istio/operator/pkg/tpath"
"istio.io/istio/operator/pkg/util" "istio.io/istio/operator/pkg/util"
"istio.io/pkg/log" "istio.io/pkg/log"
) )
skipping to change at line 134 skipping to change at line 135
return nil, fmt.Errorf("error decoding object %v: %v", string(yam l), err) return nil, fmt.Errorf("error decoding object %v: %v", string(yam l), err)
} }
return NewK8sObject(out, nil, yaml), nil return NewK8sObject(out, nil, yaml), nil
} }
// UnstructuredObject exposes the raw object, primarily for testing // UnstructuredObject exposes the raw object, primarily for testing
func (o *K8sObject) UnstructuredObject() *unstructured.Unstructured { func (o *K8sObject) UnstructuredObject() *unstructured.Unstructured {
return o.object return o.object
} }
// ResolveK8sConflict - This method resolves k8s object possible
// conflicting settings. Which K8sObjects may need such method
// depends on the type of the K8sObject.
func (o *K8sObject) ResolveK8sConflict() *K8sObject {
if o.Kind == names.PDBStr {
return resolvePDBConflict(o)
}
return o
}
// Unstructured exposes the raw object content, primarily for testing // Unstructured exposes the raw object content, primarily for testing
func (o *K8sObject) Unstructured() map[string]interface{} { func (o *K8sObject) Unstructured() map[string]interface{} {
return o.UnstructuredObject().UnstructuredContent() return o.UnstructuredObject().UnstructuredContent()
} }
// Container returns a container subtree for Deployment objects if one is found, or nil otherwise. // Container returns a container subtree for Deployment objects if one is found, or nil otherwise.
func (o *K8sObject) Container(name string) map[string]interface{} { func (o *K8sObject) Container(name string) map[string]interface{} {
u := o.Unstructured() u := o.Unstructured()
path := fmt.Sprintf("spec.template.spec.containers.[name:%s]", name) path := fmt.Sprintf("spec.template.spec.containers.[name:%s]", name)
node, f, err := tpath.GetPathContext(u, util.PathFromString(path), false) node, f, err := tpath.GetPathContext(u, util.PathFromString(path), false)
skipping to change at line 526 skipping to change at line 537
objs, err := ParseK8sObjectsFromYAMLManifest(m) objs, err := ParseK8sObjectsFromYAMLManifest(m)
if err != nil { if err != nil {
log.Error(err.Error()) log.Error(err.Error())
} }
for _, o := range objs { for _, o := range objs {
ret[o.Hash()] = true ret[o.Hash()] = true
} }
return ret return ret
} }
// resolvePDBConflict When user uses both minAvailable and
// maxUnavailable to configure istio instances, these two
// parameters are mutually exclusive, care must be taken
// to resolve the issue
func resolvePDBConflict(o *K8sObject) *K8sObject {
if o.json != nil {
spec := o.object.Object["spec"].(map[string]interface{})
isDefault := func(item interface{}) bool {
var ii intstr.IntOrString
switch item := item.(type) {
case int:
ii = intstr.FromInt(item)
case int64:
ii = intstr.FromInt(int(item))
case string:
ii = intstr.FromString(item)
default:
ii = intstr.FromInt(0)
}
intVal, err := intstr.GetScaledValueFromIntOrPercent(&ii,
100, false)
if err != nil || intVal == 0 {
return true
}
return false
}
if spec["maxUnavailable"] != nil && spec["minAvailable"] != nil {
// When both maxUnavailable and minAvailable present and
// neither has value 0, this is considered a conflict,
// then maxUnavailale will take precedence.
if !isDefault(spec["maxUnavailable"]) && !isDefault(spec[
"minAvailable"]) {
delete(spec, "minAvailable")
// Make sure that the json and yaml representatio
n of the object
// is consistent with the changed object
o.json = nil
o.json, _ = o.JSON()
if o.yaml != nil {
o.yaml = nil
o.yaml, _ = o.YAML()
}
return o
}
}
}
return o
}
 End of changes. 3 change blocks. 
0 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)