Repository: kubernetes
Issue: kubectl patch command throws an error without providing any indication when using 'imagePullSecret: - {}'
Labels: kind/bug,sig/cli,triage/accepted

### What happened?

I'm using HELM to install chart 

During the HELM upgrade I got the following error 

```
failed to create patch: map: map[] does not contain declared merge key: name
```
In order to find root cause problem , I got the YAML file from helm,  with command  ```helm upgrade --dry-run `

Copied part of Deployment to new file `t1.yaml`

Then tried to apply patch to that file where I encountered the same error . I applied the following command:

```bash
$ kubectl patch deployment mainflux-ui -n mf --patch-file ./t1.yaml
```
```error
Error from server: map: map[] does not contain declared merge key: name
```

The contents of `t1.yaml` are as follows:

```YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mainflux-ui
spec:
  selector:
    matchLabels:
      app: mainflux
      component: ui
  template:
    metadata:
      labels:
        app: mainflux
        component: ui
    spec:
      containers:
        - env:
            - name: MF_UI_PORT
              value: "3000"
            - name: MF_UI_MQTT_WS_URL
              value: "ws://localhost/mqtt"
            - name: MF_PROXY_AUTH
              value: "false"
            - name: MF_UI_APP_PREFIX
              value: "ui"
            - name : MF_PROXY_LOGOUT_URL
              value: "/logout"
          image: "mainflux/ui:latest"
          imagePullPolicy: IfNotPresent
          name: ui
          ports:
            - containerPort: 3000
              protocol: TCP
          stdin: true
          tty: true
      imagePullSecrets:
            - {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always
```

## When I removed the `imagePullSecrets` section as shown below, the patch command executed successfully:

```
    spec:
      containers:
        - env:
            - name: MF_UI_PORT
              value: "3000"
            - name: MF_UI_MQTT_WS_URL
              value: "ws://localhost/mqtt"
            - name: MF_PROXY_AUTH
              value: "false"
            - name: MF_UI_APP_PREFIX
              value: "ui"
            - name : MF_PROXY_LOGOUT_URL
              value: "/logout"
          image: "mainflux/ui:latest"
          imagePullPolicy: IfNotPresent
          name: ui
          ports:
            - containerPort: 3000
              protocol: TCP
          stdin: true
          tty: true
      dnsPolicy: ClusterFirst
      restartPolicy: Always
 ```
Output  after removingimagePullSecrets

```
deployment.apps/mainflux-ui patched (no change)
```

### What did you expect to happen?

Expectation is to accept the patch and provide a message stating "no changes" if there are no modifications.
 or
alternatively, The minimum expectation is to display the correct error message indicating the location of the error.


### How can we reproduce it (as minimally and precisely as possible)?

## When I removed the `imagePullSecrets` section as shown below, the patch command executed successfully:

```
    spec:
      containers:
        - env:
            - name: MF_UI_PORT
              value: "3000"
            - name: MF_UI_MQTT_WS_URL
              value: "ws://localhost/mqtt"
            - name: MF_PROXY_AUTH
              value: "false"
            - name: MF_UI_APP_PREFIX
              value: "ui"
            - name : MF_PROXY_LOGOUT_URL
              value: "/logout"
          image: "mainflux/ui:latest"
          imagePullPolicy: IfNotPresent
          name: ui
          ports:
            - containerPort: 3000
              protocol: TCP
          stdin: true
          tty: true
      dnsPolicy: ClusterFirst
      restartPolicy: Always
 ```
Output  after removingimagePullSecrets

```
deployment.apps/mainflux-ui patched (no change)
```

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.2", GitCommit:"fc04e732bb3e7198d2fa44efa5457c7c6f8c0f5b", GitTreeState:"clean", BuildDate:"2023-02-22T13:39:03Z", GoVersion:"go1.19.6", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3", GitCommit:"9e644106593f3f4aa98f8a84b23db5fa378900bd", GitTreeState:"clean", BuildDate:"2023-03-15T13:33:12Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
```

</details>


### Cloud provider

<details>

</details>


### OS version

<details>

```console
$ cat /etc/os-release

NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

$ uname -a
Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux


```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>