generator_password.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package v1alpha1
  13. import (
  14. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  15. )
  16. // PasswordSpec controls the behavior of the password generator.
  17. type PasswordSpec struct {
  18. // Length of the password to be generated.
  19. // Defaults to 24
  20. // +kubebuilder:default=24
  21. Length int `json:"length"`
  22. // Digits specifies the number of digits in the generated
  23. // password. If omitted it defaults to 25% of the length of the password
  24. Digits *int `json:"digits,omitempty"`
  25. // Symbols specifies the number of symbol characters in the generated
  26. // password. If omitted it defaults to 25% of the length of the password
  27. Symbols *int `json:"symbols,omitempty"`
  28. // SymbolCharacters specifies the special characters that should be used
  29. // in the generated password.
  30. SymbolCharacters *string `json:"symbolCharacters,omitempty"`
  31. // Set NoUpper to disable uppercase characters
  32. // +kubebuilder:default=false
  33. NoUpper bool `json:"noUpper"`
  34. // set AllowRepeat to true to allow repeating characters.
  35. // +kubebuilder:default=false
  36. AllowRepeat bool `json:"allowRepeat"`
  37. }
  38. // Password generates a random password based on the
  39. // configuration parameters in spec.
  40. // You can specify the length, characterset and other attributes.
  41. // +kubebuilder:object:root=true
  42. // +kubebuilder:storageversion
  43. // +kubebuilder:subresource:status
  44. // +kubebuilder:resource:scope=Namespaced,categories={password},shortName=password
  45. type Password struct {
  46. metav1.TypeMeta `json:",inline"`
  47. metav1.ObjectMeta `json:"metadata,omitempty"`
  48. Spec PasswordSpec `json:"spec,omitempty"`
  49. }
  50. // +kubebuilder:object:root=true
  51. // PasswordList contains a list of ExternalSecret resources.
  52. type PasswordList struct {
  53. metav1.TypeMeta `json:",inline"`
  54. metav1.ListMeta `json:"metadata,omitempty"`
  55. Items []Password `json:"items"`
  56. }