@@ -37,7 +37,6 @@ import (
37
37
"k8s.io/cli-runtime/pkg/genericclioptions"
38
38
"k8s.io/cli-runtime/pkg/genericiooptions"
39
39
"k8s.io/cli-runtime/pkg/printers"
40
- "k8s.io/cli-runtime/pkg/resource"
41
40
"k8s.io/client-go/dynamic"
42
41
"k8s.io/client-go/openapi3"
43
42
"k8s.io/client-go/util/csaupgrade"
@@ -52,6 +51,8 @@ import (
52
51
"k8s.io/kubectl/pkg/util/prune"
53
52
"k8s.io/kubectl/pkg/util/templates"
54
53
"k8s.io/kubectl/pkg/validation"
54
+
55
+ "github.com/zapier/kubechecks/pkg/kubectl/cli-runtime/resource"
55
56
)
56
57
57
58
// ApplyFlags directly reflect the information that CLI is gathering via flags. They will be converted to Options, which
@@ -584,15 +585,25 @@ func (o *ApplyOptions) applyOneObject(info *resource.Info) error {
584
585
options := metav1.PatchOptions {
585
586
Force : & o .ForceConflicts ,
586
587
}
587
- obj , err := helper .
588
+ result := helper .
588
589
WithSubresource (o .Subresource ).
589
- Patch (
590
+ PatchWithWarnings (
590
591
info .Namespace ,
591
592
info .Name ,
592
593
types .ApplyPatchType ,
593
594
data ,
594
595
& options ,
595
596
)
597
+ if len (result .Warnings ()) > 0 {
598
+ warnings := ""
599
+ for _ , warning := range result .Warnings () {
600
+ warnings += fmt .Sprintf ("Warning: %s\n " , warning .Text )
601
+ }
602
+ if warnings != "" {
603
+ return fmt .Errorf ("%s" , warnings )
604
+ }
605
+ }
606
+ obj , err := result .Get ()
596
607
if err != nil {
597
608
if isIncompatibleServerError (err ) {
598
609
err = fmt .Errorf ("Server-side apply not available on the server: (%v)" , err )
0 commit comments