forked from elastic/cloud-on-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for configuration changes under OLM (elastic#3639)
* Add support for OLM config * Fix error message
- Loading branch information
1 parent
9e27c9e
commit 7801dfb
Showing
9 changed files
with
572 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License; | ||
# you may not use this file except in compliance with the Elastic License. | ||
|
||
# Script to extract ECK configuration map contents from all-in-one.yaml | ||
|
||
set -euo pipefail | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
OUT_FILE="${SCRIPT_DIR}/../../config/eck.yaml" | ||
|
||
( | ||
cd "$SCRIPT_DIR" | ||
"${SCRIPT_DIR}"/../manifest-gen/manifest-gen.sh -g --exclude-crds --set=config.webhook.enabled=false | go run main.go > "$OUT_FILE" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/elastic/cloud-on-k8s/hack/config-extractor | ||
|
||
go 1.15 | ||
|
||
require ( | ||
k8s.io/api v0.18.8 | ||
k8s.io/apiextensions-apiserver v0.18.8 | ||
k8s.io/apimachinery v0.18.8 | ||
k8s.io/kubectl v0.18.8 | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package main | ||
|
||
import ( | ||
"bufio" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" | ||
"k8s.io/apimachinery/pkg/util/yaml" | ||
"k8s.io/kubectl/pkg/scheme" | ||
) | ||
|
||
const ( | ||
configMapName = "elastic-operator" | ||
keyName = "eck.yaml" | ||
) | ||
|
||
func main() { | ||
conf, err := extractConfig(os.Stdin) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error extracting config: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Fprint(os.Stdout, conf) | ||
} | ||
|
||
func extractConfig(stream io.Reader) (string, error) { | ||
if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil { | ||
return "", fmt.Errorf("failed to register api-extensions: %w", err) | ||
} | ||
|
||
decoder := scheme.Codecs.UniversalDeserializer() | ||
yamlReader := yaml.NewYAMLReader(bufio.NewReader(stream)) | ||
|
||
for { | ||
yamlBytes, err := yamlReader.Read() | ||
if err != nil { | ||
if errors.Is(err, io.EOF) { | ||
return "", fmt.Errorf("failed to find ConfigMap named %s", configMapName) | ||
} | ||
|
||
return "", fmt.Errorf("failed to read YAML: %w", err) | ||
} | ||
|
||
runtimeObj, _, err := decoder.Decode(yamlBytes, nil, nil) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to decode YAML: %w", err) | ||
} | ||
|
||
if cm, ok := runtimeObj.(*v1.ConfigMap); ok && cm.Name == configMapName { | ||
return cm.Data[keyName], nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters