InitializeConfigBundle initializes a Talos configuration bundle from opts. nolint:gocritic // hugeParam: Options is the package's public facing configuration carrier; converting this to a pointer would propagate the change across every caller in pkg/commands and break the API for external consumers
(opts Options)
| 197 | // |
| 198 | //nolint:gocritic // hugeParam: Options is the package's public facing configuration carrier; converting this to a pointer would propagate the change across every caller in pkg/commands and break the API for external consumers. |
| 199 | func InitializeConfigBundle(opts Options) (*bundle.Bundle, error) { |
| 200 | genOptions := []generate.Option{} |
| 201 | |
| 202 | if opts.TalosVersion != "" { |
| 203 | versionContract, err := config.ParseContractFromVersion(opts.TalosVersion) |
| 204 | if err != nil { |
| 205 | return nil, errors.Wrap(err, "invalid talos-version") |
| 206 | } |
| 207 | |
| 208 | genOptions = append(genOptions, generate.WithVersionContract(versionContract)) |
| 209 | } |
| 210 | |
| 211 | if opts.WithSecrets != "" { |
| 212 | secretsBundle, err := secrets.LoadBundle(opts.WithSecrets) |
| 213 | if err != nil { |
| 214 | return nil, errors.Wrap(err, "failed to load secrets bundle") |
| 215 | } |
| 216 | |
| 217 | genOptions = append(genOptions, generate.WithSecretsBundle(secretsBundle)) |
| 218 | } |
| 219 | |
| 220 | configBundleOpts := []bundle.Option{ |
| 221 | bundle.WithInputOptions( |
| 222 | &bundle.InputOptions{ |
| 223 | ClusterName: opts.ClusterName, |
| 224 | Endpoint: opts.Endpoint, |
| 225 | KubeVersion: strings.TrimPrefix(opts.KubernetesVersion, "v"), |
| 226 | GenOptions: genOptions, |
| 227 | }, |
| 228 | ), |
| 229 | bundle.WithVerbose(false), |
| 230 | } |
| 231 | |
| 232 | configBundle, err := bundle.NewBundle(configBundleOpts...) |
| 233 | if err != nil { |
| 234 | return nil, errors.Wrap(err, "creating config bundle") |
| 235 | } |
| 236 | |
| 237 | return configBundle, nil |
| 238 | } |
| 239 | |
| 240 | // SerializeConfiguration serializes the configuration bundle for machineType. |
| 241 | func SerializeConfiguration(configBundle *bundle.Bundle, machineType machine.Type) ([]byte, error) { |
no outgoing calls