Skip to content

Commit

Permalink
remove useless dependency for spd
Browse files Browse the repository at this point in the history
  • Loading branch information
waynepeking348 committed Feb 27, 2024
1 parent be538f6 commit ae08506
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 76 deletions.
25 changes: 5 additions & 20 deletions pkg/apis/workload/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,13 @@ type ServiceProfileDescriptor struct {

// DecodeNestedObjects decodes extended indicator for known types.
func (c *ServiceProfileDescriptor) DecodeNestedObjects(d runtime.Decoder) error {
var strictDecodingErrs []error
for i := range c.Spec.ExtendedIndicator {
indicator := &c.Spec.ExtendedIndicator[i]
err := indicator.decodeNestedObjects(d)
if err != nil {
decodingErr := fmt.Errorf("decoding .spec.extendedIndicator[%d]: %w", i, err)
if runtime.IsStrictDecodingError(err) {
strictDecodingErrs = append(strictDecodingErrs, decodingErr)
} else {
return decodingErr
}
return fmt.Errorf("decoding .spec.extendedIndicator[%d]: %w", i, err)
}
}
if len(strictDecodingErrs) > 0 {
return runtime.NewStrictDecodingError(strictDecodingErrs)
}
return nil
}

Expand Down Expand Up @@ -140,21 +131,15 @@ func (c *ServiceExtendedIndicatorSpec) decodeNestedObjects(d runtime.Decoder) er
return nil
}

var strictDecodingErr error
obj, parsedGvk, err := d.Decode(c.Indicators.Raw, &gvk, nil)
if err != nil {
decodingArgsErr := fmt.Errorf("decoding extended indicators %s: %w", c.Name, err)
if obj != nil && runtime.IsStrictDecodingError(err) {
strictDecodingErr = runtime.NewStrictDecodingError([]error{decodingArgsErr})
} else {
return decodingArgsErr
}
}
if parsedGvk.GroupKind() != gvk.GroupKind() {
return fmt.Errorf("decoding extended indicators %s: %w", c.Name, err)
} else if parsedGvk.GroupKind() != gvk.GroupKind() {
return fmt.Errorf("indicators for %s were not of type %s, got %s", c.Name, gvk.GroupKind(), parsedGvk.GroupKind())
}

c.Indicators.Object = obj
return strictDecodingErr
return nil
}

func (c *ServiceExtendedIndicatorSpec) encodeNestedObjects(e runtime.Encoder) error {
Expand Down
50 changes: 10 additions & 40 deletions pkg/protocol/evictionplugin/v1alpha1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions pkg/protocol/reporterplugin/v1alpha1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae08506

Please sign in to comment.