Skip to content

Commit b92a68a

Browse files
authored
Merge pull request #9 from pluralsh/global-pull-credentials
Add ability to set up additional global pull credentials
2 parents bd5376d + 3983643 commit b92a68a

11 files changed

+702
-10
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package v1alpha1
2+
3+
import (
4+
"fmt"
5+
corev1 "k8s.io/api/core/v1"
6+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+
)
8+
9+
// PasswordSecretRef the password secret reference
10+
type PasswordSecretRef struct {
11+
// The Secret to select from.
12+
corev1.LocalObjectReference `json:",inline"`
13+
14+
// Key for Secret data
15+
Key string `json:"key"`
16+
}
17+
18+
// RegistryCredentialSpec is a specification of registry credentials
19+
type RegistryCredentialSpec struct {
20+
// Registry username
21+
Username string `json:"username"`
22+
23+
// Registry user email address
24+
Email string `json:"email"`
25+
26+
// Registry FQDN
27+
Server string `json:"server"`
28+
29+
// The password Secret to select from
30+
PasswordSecretRef PasswordSecretRef `json:"password"`
31+
}
32+
33+
// RegistryCredentialStatus defines the observed state of RegistryCredential
34+
type RegistryCredentialStatus struct {
35+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
36+
// Important: Run "make" to regenerate code after modifying this file
37+
}
38+
39+
//+kubebuilder:object:root=true
40+
//+kubebuilder:subresource:status
41+
42+
type RegistryCredential struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty"`
45+
46+
Spec RegistryCredentialSpec `json:"spec"`
47+
Status RegistryCredentialStatus `json:"status,omitempty"`
48+
}
49+
50+
//+kubebuilder:object:root=true
51+
52+
// RegistryCredentialList contains a list of RegistryCredential
53+
type RegistryCredentialList struct {
54+
metav1.TypeMeta `json:",inline"`
55+
metav1.ListMeta `json:"metadata,omitempty"`
56+
Items []RegistryCredential `json:"items"`
57+
}
58+
59+
func (r *RegistryCredential) GetPasswordSecretName() string {
60+
return fmt.Sprintf("registry-secret-%s", r.Name)
61+
}
62+
63+
func init() {
64+
SchemeBuilder.Register(&RegistryCredential{}, &RegistryCredentialList{})
65+
}

api/platform/v1alpha1/zz_generated.deepcopy.go

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.4.1
8+
creationTimestamp: null
9+
name: registrycredentials.platform.plural.sh
10+
spec:
11+
group: platform.plural.sh
12+
names:
13+
kind: RegistryCredential
14+
listKind: RegistryCredentialList
15+
plural: registrycredentials
16+
singular: registrycredential
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: RegistryCredentialSpec is a specification of registry credentials
37+
properties:
38+
email:
39+
description: Registry user email address
40+
type: string
41+
password:
42+
description: The password Secret to select from
43+
properties:
44+
key:
45+
description: Key for Secret data
46+
type: string
47+
name:
48+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
49+
TODO: Add other useful fields. apiVersion, kind, uid?'
50+
type: string
51+
required:
52+
- key
53+
type: object
54+
server:
55+
description: Registry FQDN
56+
type: string
57+
username:
58+
description: Registry username
59+
type: string
60+
required:
61+
- email
62+
- password
63+
- server
64+
- username
65+
type: object
66+
status:
67+
description: RegistryCredentialStatus defines the observed state of RegistryCredential
68+
type: object
69+
required:
70+
- spec
71+
type: object
72+
served: true
73+
storage: true
74+
subresources:
75+
status: {}
76+
status:
77+
acceptedNames:
78+
kind: ""
79+
plural: ""
80+
conditions: []
81+
storedVersions: []

controllers/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ package controllers
22

33
const (
44
managedLabel = "app.kubernetes.io/managed-by"
5+
secretTypeLabel = "platform.plural.sh/type"
56
ignoreAnnotation = "platform.plural.sh/ignore"
67
)

0 commit comments

Comments
 (0)