@@ -18,13 +18,10 @@ package v1beta1
1818
1919import (
2020 "encoding/json"
21- "fmt"
2221 "time"
2322
24- jsonpatch "github.com/evanphx/json-patch"
2523 k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
2624 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27- k8syaml "sigs.k8s.io/yaml"
2825)
2926
3027// UnsupportedOverrides holds the config overrides used to configure
@@ -148,32 +145,6 @@ type Extensions struct {
148145 Helm * Helm `json:"helm,omitempty"`
149146}
150147
151- func ConvertTo (e Helm , t * k0sv1beta1.HelmExtensions ) (* k0sv1beta1.HelmExtensions , error ) {
152- j , err := json .Marshal (e )
153- if err != nil {
154- return t , fmt .Errorf ("unable to convert extensions: %w" , err )
155- }
156-
157- if err = json .Unmarshal (j , t ); err != nil {
158- return t , fmt .Errorf ("unable to unmarshal to new type: %w" , err )
159- }
160-
161- return t , nil
162- }
163-
164- func ConvertFrom (e k0sv1beta1.HelmExtensions , t * Helm ) (* Helm , error ) {
165- j , err := json .Marshal (e )
166- if err != nil {
167- return t , fmt .Errorf ("unable to convert extensions: %w" , err )
168- }
169-
170- if err = json .Unmarshal (j , t ); err != nil {
171- return t , fmt .Errorf ("unable to unmarshal to new type: %w" , err )
172- }
173-
174- return t , nil
175- }
176-
177148// ConfigSpec defines the desired state of Config
178149type ConfigSpec struct {
179150 Version string `json:"version,omitempty"`
@@ -201,35 +172,6 @@ func (c ConfigSpec) OverrideForBuiltIn(bi string) string {
201172 return ""
202173}
203174
204- // ApplyEndUserAddOnOverrides applies the end-user provided addon config on top
205- // of the provided addon configuration (cfg).
206- func (c * ConfigSpec ) ApplyEndUserAddOnOverrides (name , cfg string ) (string , error ) {
207- patch := c .OverrideForBuiltIn (name )
208- if len (cfg ) == 0 || len (patch ) == 0 {
209- if len (cfg ) == 0 {
210- return patch , nil
211- }
212- return cfg , nil
213- }
214- originalJSON , err := k8syaml .YAMLToJSON ([]byte (cfg ))
215- if err != nil {
216- return "" , fmt .Errorf ("unable to convert source yaml to json: %w" , err )
217- }
218- patchJSON , err := k8syaml .YAMLToJSON ([]byte (patch ))
219- if err != nil {
220- return "" , fmt .Errorf ("unable to convert patch yaml to json: %w" , err )
221- }
222- result , err := jsonpatch .MergePatch (originalJSON , patchJSON )
223- if err != nil {
224- return "" , fmt .Errorf ("unable to patch configuration: %w" , err )
225- }
226- resultYAML , err := k8syaml .JSONToYAML (result )
227- if err != nil {
228- return "" , fmt .Errorf ("unable to convert result json to yaml: %w" , err )
229- }
230- return string (resultYAML ), nil
231- }
232-
233175// ConfigStatus defines the observed state of Config
234176type ConfigStatus struct {
235177}
0 commit comments