mirror of https://github.com/fluxcd/flux2.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
4 years ago
|
/*
|
||
|
Copyright 2020 The Flux authors
|
||
|
|
||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
you may not use this file except in compliance with the License.
|
||
|
You may obtain a copy of the License at
|
||
|
|
||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
Unless required by applicable law or agreed to in writing, software
|
||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
See the License for the specific language governing permissions and
|
||
|
limitations under the License.
|
||
|
*/
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/spf13/cobra"
|
||
|
corev1 "k8s.io/api/core/v1"
|
||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||
|
"sigs.k8s.io/yaml"
|
||
|
)
|
||
|
|
||
|
var createSecretCmd = &cobra.Command{
|
||
|
Use: "secret",
|
||
|
Short: "Create or update Kubernetes secrets",
|
||
|
Long: "The create source sub-commands generate Kubernetes secrets specific to Flux.",
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
createCmd.AddCommand(createSecretCmd)
|
||
|
}
|
||
|
|
||
|
func exportSecret(secret corev1.Secret) error {
|
||
|
secret.TypeMeta = metav1.TypeMeta{
|
||
|
APIVersion: "v1",
|
||
|
Kind: "Secret",
|
||
|
}
|
||
|
|
||
|
data, err := yaml.Marshal(secret)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
fmt.Println("---")
|
||
|
fmt.Println(resourceToString(data))
|
||
|
return nil
|
||
|
}
|