-
Notifications
You must be signed in to change notification settings - Fork 3
/
decode.go
31 lines (24 loc) · 1.11 KB
/
decode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0
package admission
import (
"github.com/gardener/gardener/extensions/pkg/util"
"k8s.io/apimachinery/pkg/runtime"
ironcore "github.com/ironcore-dev/gardener-extension-provider-ironcore/pkg/apis/ironcore"
)
// DecodeControlPlaneConfig decodes the `ControlPlaneConfig` from the given `RawExtension`.
func DecodeControlPlaneConfig(decoder runtime.Decoder, cp *runtime.RawExtension) (*ironcore.ControlPlaneConfig, error) {
controlPlaneConfig := &ironcore.ControlPlaneConfig{}
if err := util.Decode(decoder, cp.Raw, controlPlaneConfig); err != nil {
return nil, err
}
return controlPlaneConfig, nil
}
// DecodeInfrastructureConfig decodes the `InfrastructureConfig` from the given `RawExtension`.
func DecodeInfrastructureConfig(decoder runtime.Decoder, infra *runtime.RawExtension) (*ironcore.InfrastructureConfig, error) {
infraConfig := &ironcore.InfrastructureConfig{}
if err := util.Decode(decoder, infra.Raw, infraConfig); err != nil {
return nil, err
}
return infraConfig, nil
}