Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove useless dependency for spd #67

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading