csrsigningcontroller.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package options
  14. import (
  15. "github.com/spf13/pflag"
  16. csrsigningconfig "k8s.io/kubernetes/pkg/controller/certificates/signer/config"
  17. )
  18. const (
  19. // These defaults are deprecated and exported so that we can warn if
  20. // they are being used.
  21. // DefaultClusterSigningCertFile is deprecated. Do not use.
  22. DefaultClusterSigningCertFile = "/etc/kubernetes/ca/ca.pem"
  23. // DefaultClusterSigningKeyFile is deprecated. Do not use.
  24. DefaultClusterSigningKeyFile = "/etc/kubernetes/ca/ca.key"
  25. )
  26. // CSRSigningControllerOptions holds the CSRSigningController options.
  27. type CSRSigningControllerOptions struct {
  28. *csrsigningconfig.CSRSigningControllerConfiguration
  29. }
  30. // AddFlags adds flags related to CSRSigningController for controller manager to the specified FlagSet.
  31. func (o *CSRSigningControllerOptions) AddFlags(fs *pflag.FlagSet) {
  32. if o == nil {
  33. return
  34. }
  35. fs.StringVar(&o.ClusterSigningCertFile, "cluster-signing-cert-file", o.ClusterSigningCertFile, "Filename containing a PEM-encoded X509 CA certificate used to issue cluster-scoped certificates")
  36. fs.StringVar(&o.ClusterSigningKeyFile, "cluster-signing-key-file", o.ClusterSigningKeyFile, "Filename containing a PEM-encoded RSA or ECDSA private key used to sign cluster-scoped certificates")
  37. fs.DurationVar(&o.ClusterSigningDuration.Duration, "experimental-cluster-signing-duration", o.ClusterSigningDuration.Duration, "The length of duration signed certificates will be given.")
  38. }
  39. // ApplyTo fills up CSRSigningController config with options.
  40. func (o *CSRSigningControllerOptions) ApplyTo(cfg *csrsigningconfig.CSRSigningControllerConfiguration) error {
  41. if o == nil {
  42. return nil
  43. }
  44. cfg.ClusterSigningCertFile = o.ClusterSigningCertFile
  45. cfg.ClusterSigningKeyFile = o.ClusterSigningKeyFile
  46. cfg.ClusterSigningDuration = o.ClusterSigningDuration
  47. return nil
  48. }
  49. // Validate checks validation of CSRSigningControllerOptions.
  50. func (o *CSRSigningControllerOptions) Validate() []error {
  51. if o == nil {
  52. return nil
  53. }
  54. errs := []error{}
  55. return errs
  56. }