Skip to content

Commit

Permalink
fix: extramount should have yaml:",inline" tag
Browse files Browse the repository at this point in the history
Otherwise yaml `encode` produces during validation:

```yaml
extraMounts:
  - mounts:
      destination: /var/local
      ...
```

Instead of:

```yaml
extraMounts:
  - destination: /var/local
    ...
```

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
  • Loading branch information
Unix4ever committed Aug 19, 2021
1 parent 2b614e4 commit 1abc12b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions pkg/machinery/config/decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/talos-systems/talos/pkg/machinery/config"
"github.com/talos-systems/talos/pkg/machinery/config/decoder"
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1"
)

type Mock struct {
Expand All @@ -30,6 +31,10 @@ func init() {

return &Mock{}
})

config.Register("kubelet", func(string) interface{} {
return &v1alpha1.KubeletConfig{}
})
}

func TestDecoder_Decode(t *testing.T) {
Expand Down Expand Up @@ -225,6 +230,23 @@ spec:
},
},
},
{
name: "kubelet config",
fields: fields{
source: []byte(`---
kind: kubelet
version: v1alpha1
spec:
extraMounts:
- destination: /var/local
options:
- rbind
- rshared
- rw
source: /var/local
`),
},
},
}

for _, tt := range tests {
Expand All @@ -236,8 +258,10 @@ spec:

return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Decoder.Decode() = %v, want %v", got, tt.want)
if tt.want != nil {
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Decoder.Decode() = %v, want %v", got, tt.want)
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/machinery/config/types/v1alpha1/v1alpha1_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ type ClusterConfig struct {

// ExtraMount wraps OCI Mount specification.
type ExtraMount struct {
specs.Mount
specs.Mount `yaml:",inline"`
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
Expand Down

0 comments on commit 1abc12b

Please sign in to comment.