mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-18 21:21:10 +02:00
feat: add extra headers to fetch of extraManifests
Provides capability to add extra headers in cases where files can only be fetched with token based authenction. Signed-off-by: Niklas Wik <niklas.wik@nokia.com> feat: extra manifest headers for fetching manifests - Changed config to map of key value pairs. Signed-off-by: Niklas Wik <niklas.wik@nokia.com> fix: added docs for new extra headers fetch Signed-off-by: Niklas Wik <niklas.wik@nokia.com> fix: fix linter issue Signed-off-by: Niklas Wik <niklas.wik@nokia.com>
This commit is contained in:
parent
8d2f8d6127
commit
dba6de506e
@ -597,6 +597,21 @@ extraManifests:
|
||||
|
||||
```
|
||||
|
||||
#### extraManifestHeaders
|
||||
|
||||
A map of key value pairs that will be added while fetching the ExtraManifests.
|
||||
|
||||
Type: `map`
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
extraManifestHeaders:
|
||||
Token: "1234567"
|
||||
X-ExtraInfo: info
|
||||
|
||||
```
|
||||
|
||||
#### adminKubeconfig
|
||||
|
||||
Settings for admin kubeconfig generation.
|
||||
|
@ -234,13 +234,13 @@ func generateAssets(config runtime.Configurator) (err error) {
|
||||
|
||||
// If "custom" is the CNI, we expect the user to supply one or more urls that point to CNI yamls
|
||||
if config.Cluster().Network().CNI().Name() == constants.CustomCNI {
|
||||
if err = fetchManifests(config.Cluster().Network().CNI().URLs()); err != nil {
|
||||
if err = fetchManifests(config.Cluster().Network().CNI().URLs(), map[string]string{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(config.Cluster().ExtraManifestURLs()) > 0 {
|
||||
if err = fetchManifests(config.Cluster().ExtraManifestURLs()); err != nil {
|
||||
if err = fetchManifests(config.Cluster().ExtraManifestURLs(), config.Cluster().ExtraManifestHeaderMap()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ func altNamesFromURLs(urls []string) *tlsutil.AltNames {
|
||||
}
|
||||
|
||||
// fetchManifests will lay down manifests in the provided urls to the bootkube assets directory
|
||||
func fetchManifests(urls []string) error {
|
||||
func fetchManifests(urls []string, headers map[string]string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
var result *multierror.Error
|
||||
@ -286,6 +286,12 @@ func fetchManifests(urls []string) error {
|
||||
Client: http.DefaultClient,
|
||||
}
|
||||
|
||||
httpGetter.Header = make(http.Header)
|
||||
|
||||
for k, v := range headers {
|
||||
httpGetter.Header.Add(k, v)
|
||||
}
|
||||
|
||||
getter.Getters["http"] = httpGetter
|
||||
getter.Getters["https"] = httpGetter
|
||||
|
||||
|
@ -32,6 +32,7 @@ type Cluster interface {
|
||||
PodCheckpointer() PodCheckpointer
|
||||
CoreDNS() CoreDNS
|
||||
ExtraManifestURLs() []string
|
||||
ExtraManifestHeaderMap() map[string]string
|
||||
AdminKubeconfig() AdminKubeconfig
|
||||
}
|
||||
|
||||
|
@ -429,6 +429,11 @@ func (c *ClusterConfig) ExtraManifestURLs() []string {
|
||||
return c.ExtraManifests
|
||||
}
|
||||
|
||||
// ExtraManifestHeaderMap implements the Configurator interface.
|
||||
func (c *ClusterConfig) ExtraManifestHeaderMap() map[string]string {
|
||||
return c.ExtraManifestHeaders
|
||||
}
|
||||
|
||||
// PodCheckpointer implements the Configurator interface.
|
||||
func (c *ClusterConfig) PodCheckpointer() cluster.PodCheckpointer {
|
||||
if c.PodCheckpointerConfig == nil {
|
||||
|
@ -343,6 +343,14 @@ type ClusterConfig struct {
|
||||
// - "https://www.mysweethttpserver.com/manifest2.yaml"
|
||||
ExtraManifests []string `yaml:"extraManifests,omitempty"`
|
||||
// description: |
|
||||
// A map of key value pairs that will be added while fetching the ExtraManifests.
|
||||
// examples:
|
||||
// - |
|
||||
// extraManifestHeaders:
|
||||
// Token: "1234567"
|
||||
// X-ExtraInfo: info
|
||||
ExtraManifestHeaders map[string]string `yaml:"extraManifestHeaders,omitempty"`
|
||||
// description: |
|
||||
// Settings for admin kubeconfig generation.
|
||||
// Certificate lifetime can be configured.
|
||||
// examples:
|
||||
|
Loading…
x
Reference in New Issue
Block a user