generator_ecr.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
  16. )
  17. type ECRAuthorizationTokenSpec struct {
  18. // Region specifies the region to operate in.
  19. Region string `json:"region"`
  20. // Auth defines how to authenticate with AWS
  21. // +optional
  22. Auth AWSAuth `json:"auth,omitempty"`
  23. // You can assume a role before making calls to the
  24. // desired AWS service.
  25. // +optional
  26. Role string `json:"role,omitempty"`
  27. }
  28. // AWSAuth tells the controller how to do authentication with aws.
  29. // Only one of secretRef or jwt can be specified.
  30. // if none is specified the controller will load credentials using the aws sdk defaults.
  31. type AWSAuth struct {
  32. // +optional
  33. SecretRef *AWSAuthSecretRef `json:"secretRef,omitempty"`
  34. // +optional
  35. JWTAuth *AWSJWTAuth `json:"jwt,omitempty"`
  36. }
  37. // AWSAuthSecretRef holds secret references for AWS credentials
  38. // both AccessKeyID and SecretAccessKey must be defined in order to properly authenticate.
  39. type AWSAuthSecretRef struct {
  40. // The AccessKeyID is used for authentication
  41. AccessKeyID esmeta.SecretKeySelector `json:"accessKeyIDSecretRef,omitempty"`
  42. // The SecretAccessKey is used for authentication
  43. SecretAccessKey esmeta.SecretKeySelector `json:"secretAccessKeySecretRef,omitempty"`
  44. // The SessionToken used for authentication
  45. // This must be defined if AccessKeyID and SecretAccessKey are temporary credentials
  46. // see: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html
  47. // +Optional
  48. SessionToken *esmeta.SecretKeySelector `json:"sessionTokenSecretRef,omitempty"`
  49. }
  50. // Authenticate against AWS using service account tokens.
  51. type AWSJWTAuth struct {
  52. ServiceAccountRef *esmeta.ServiceAccountSelector `json:"serviceAccountRef,omitempty"`
  53. }
  54. // ECRAuthorizationTokenSpec uses the GetAuthorizationToken API to retrieve an
  55. // authorization token.
  56. // The authorization token is valid for 12 hours.
  57. // The authorizationToken returned is a base64 encoded string that can be decoded
  58. // and used in a docker login command to authenticate to a registry.
  59. // For more information, see Registry authentication (https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth) in the Amazon Elastic Container Registry User Guide.
  60. // +kubebuilder:object:root=true
  61. // +kubebuilder:storageversion
  62. // +kubebuilder:subresource:status
  63. // +kubebuilder:resource:scope=Namespaced,categories={ecrauthorizationtoken},shortName=ecrauthorizationtoken
  64. type ECRAuthorizationToken struct {
  65. metav1.TypeMeta `json:",inline"`
  66. metav1.ObjectMeta `json:"metadata,omitempty"`
  67. Spec ECRAuthorizationTokenSpec `json:"spec,omitempty"`
  68. }
  69. // +kubebuilder:object:root=true
  70. // ECRAuthorizationTokenList contains a list of ExternalSecret resources.
  71. type ECRAuthorizationTokenList struct {
  72. metav1.TypeMeta `json:",inline"`
  73. metav1.ListMeta `json:"metadata,omitempty"`
  74. Items []ECRAuthorizationToken `json:"items"`
  75. }