UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Platform One
P
Party Bus
Valkyrie
valkyrie-api
Commits
41e7c40c
Commit
41e7c40c
authored
Jul 16, 2021
by
Jason van Brackel
Browse files
fix merge conflicts
parents
87d31e2b
09ef6eeb
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
234 additions
and
220 deletions
+234
-220
PROJECT
PROJECT
+1
-1
apis/gitlab/clientConfiguration.go
apis/gitlab/clientConfiguration.go
+10
-10
apis/gitlab/v1alpha1/dnsrepocredential_types.go
apis/gitlab/v1alpha1/dnsrepocredential_types.go
+2
-2
apis/gitlab/v1alpha1/dnsrepocredential_types_test.go
apis/gitlab/v1alpha1/dnsrepocredential_types_test.go
+2
-2
apis/gitlab/v1alpha1/gitlabcredentials_types.go
apis/gitlab/v1alpha1/gitlabcredentials_types.go
+16
-16
apis/gitlab/v1alpha1/gitlabcredentials_types_test.go
apis/gitlab/v1alpha1/gitlabcredentials_types_test.go
+54
-54
apis/gitlab/v1alpha1/group_types.go
apis/gitlab/v1alpha1/group_types.go
+4
-4
apis/gitlab/v1alpha1/group_types_test.go
apis/gitlab/v1alpha1/group_types_test.go
+2
-2
apis/gitlab/v1alpha1/project_types.go
apis/gitlab/v1alpha1/project_types.go
+6
-2
apis/gitlab/v1alpha1/zz_generated.deepcopy.go
apis/gitlab/v1alpha1/zz_generated.deepcopy.go
+19
-19
clients/gitlab/client_test.go
clients/gitlab/client_test.go
+73
-73
config/crd/bases/gitlab.valkyrie.dso.mil_dnsrepocredentials.yaml
...crd/bases/gitlab.valkyrie.dso.mil_dnsrepocredentials.yaml
+2
-2
config/crd/bases/gitlab.valkyrie.dso.mil_gitlabcredentials.yaml
.../crd/bases/gitlab.valkyrie.dso.mil_gitlabcredentials.yaml
+11
-11
config/crd/bases/gitlab.valkyrie.dso.mil_groups.yaml
config/crd/bases/gitlab.valkyrie.dso.mil_groups.yaml
+9
-4
config/crd/bases/gitlab.valkyrie.dso.mil_projects.yaml
config/crd/bases/gitlab.valkyrie.dso.mil_projects.yaml
+6
-1
config/samples/gitlab_v1alpha1_gitlabcredentials.yaml
config/samples/gitlab_v1alpha1_gitlabcredentials.yaml
+1
-1
controllers/gitlab/dnsrepomergerequest_controller.go
controllers/gitlab/dnsrepomergerequest_controller.go
+4
-4
controllers/gitlab/dnsrepomergerequest_controller_test.go
controllers/gitlab/dnsrepomergerequest_controller_test.go
+9
-9
controllers/gitlab/gitlabcredentials_controller.go
controllers/gitlab/gitlabcredentials_controller.go
+2
-2
controllers/gitlab/gitlabcredentials_controller_test.go
controllers/gitlab/gitlabcredentials_controller_test.go
+1
-1
No files found.
PROJECT
View file @
41e7c40c
...
...
@@ -101,7 +101,7 @@ resources:
controller: true
domain: valkyrie.dso.mil
group: gitlab
kind: Git
l
abCredentials
kind: Git
L
abCredentials
path: valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1
version: v1alpha1
- api:
...
...
apis/gitlab/clientConfiguration.go
View file @
41e7c40c
...
...
@@ -12,14 +12,14 @@ import (
)
const
(
errorUnableToFetchGit
l
abCredentials
=
"unable to fetch gitlab credentials"
errorUnableToFetchGit
L
abCredentials
=
"unable to fetch gitlab credentials"
errorUnableToFetchSecret
=
"unable to fetch secret from gitlab credentials"
errorUnableToCreateGit
l
abClient
=
"unable to create gitlab client"
errorUnableToCreateGit
L
abClient
=
"unable to create gitlab client"
)
// ClientConfiguration represents an object whose purpose is to setup a Git
l
ab client given
// ClientConfiguration represents an object whose purpose is to setup a Git
L
ab client given
type
ClientConfiguration
interface
{
// SetupClient pulls the Git
l
abCredentials from Kubernetes and supplies the Git
l
ab user and access token.
// SetupClient pulls the Git
L
abCredentials from Kubernetes and supplies the Git
L
ab user and access token.
SetupClient
(
client
client
.
Client
,
credentialsName
string
)
(
gitlabClient
.
Client
,
error
)
}
...
...
@@ -31,18 +31,18 @@ type ClientConfigurationImpl struct {
Req
ctrl
.
Request
}
// SetupClient looks up the gitlab credentials to get the access token and username for connecting to Git
l
ab
// SetupClient looks up the gitlab credentials to get the access token and username for connecting to Git
L
ab
// on behalf of the reconciler.
func
(
c
ClientConfigurationImpl
)
SetupClient
(
client
client
.
Client
,
credentialsName
string
)
(
gitlabClient
.
Client
,
error
)
{
// Get the Git
l
ab Credentials
// Get the Git
L
ab Credentials
var
gitLabCredentialsName
=
types
.
NamespacedName
{
Namespace
:
c
.
Req
.
Namespace
,
Name
:
credentialsName
,
}
var
gitlabCredentials
gitlabv1alpha1
.
Git
l
abCredentials
var
gitlabCredentials
gitlabv1alpha1
.
Git
L
abCredentials
if
err
:=
client
.
Get
(
c
.
Ctx
,
gitLabCredentialsName
,
&
gitlabCredentials
);
err
!=
nil
{
c
.
Log
.
Error
(
err
,
errorUnableToFetchGit
l
abCredentials
)
c
.
Log
.
Error
(
err
,
errorUnableToFetchGit
L
abCredentials
)
return
nil
,
err
}
...
...
@@ -58,13 +58,13 @@ func (c ClientConfigurationImpl) SetupClient(client client.Client, credentialsNa
return
nil
,
err
}
// Login to Git
l
ab
// Login to Git
L
ab
var
accessToken
=
string
(
secret
.
Data
[
gitlabCredentials
.
Spec
.
AccessTokenKey
])
var
returnClient
gitlabClient
.
Client
var
err
error
if
returnClient
,
err
=
gitlabClient
.
NewClient
(
accessToken
,
gitlabCredentials
.
Spec
.
URL
,
nil
);
err
!=
nil
{
c
.
Log
.
Error
(
err
,
errorUnableToCreateGit
l
abClient
,
"username"
,
gitlabCredentials
.
Spec
.
Username
,
"url"
,
gitlabCredentials
.
Spec
.
URL
)
c
.
Log
.
Error
(
err
,
errorUnableToCreateGit
L
abClient
,
"username"
,
gitlabCredentials
.
Spec
.
Username
,
"url"
,
gitlabCredentials
.
Spec
.
URL
)
return
nil
,
err
}
...
...
apis/gitlab/v1alpha1/dnsrepocredential_types.go
View file @
41e7c40c
...
...
@@ -26,8 +26,8 @@ type DNSRepoCredentialSpec struct {
// RepoURL is the url for the DNS git repository. For example: https://code.il2.dso.mil/platform-one/products/valkyrie/dso-dns.git
RepoURL
string
`json:"repoUrl,omitempty"`
// Git
l
abProjectID is the project ID of the DNS project in Git
l
ab
Git
l
abProjectID
int
`json:"gitlabProjectId,omitempty"`
// Git
L
abProjectID is the project ID of the DNS project in Git
L
ab
Git
L
abProjectID
int
`json:"gitlabProjectId,omitempty"`
// UsernameSecRef is the username of project bot will be used to clone the repo
UsernameSecRef
v1
.
SecretKeySelector
`json:"usernameSecretRef,omitempty"`
...
...
apis/gitlab/v1alpha1/dnsrepocredential_types_test.go
View file @
41e7c40c
...
...
@@ -69,7 +69,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential {
// leave scaffold Foo value for testing?
testVars
.
testObjectSpec1
=
DNSRepoCredentialSpec
{
RepoURL
:
"https://test.git"
,
Git
l
abProjectID
:
4351
,
Git
L
abProjectID
:
4351
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secret"
},
Key
:
"username"
,
...
...
@@ -81,7 +81,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential {
}
testVars
.
testObjectSpec2
=
DNSRepoCredentialSpec
{
RepoURL
:
"https://test22.git"
,
Git
l
abProjectID
:
4351
,
Git
L
abProjectID
:
4351
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secret"
},
Key
:
"username"
,
...
...
apis/gitlab/v1alpha1/gitlabcredentials_types.go
View file @
41e7c40c
...
...
@@ -21,24 +21,24 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Git
l
abCredentialsSpec defines the desired state of Git
l
abCredentials, this stores a Git
l
ab username
// and Access Token for communicating with the Git
l
ab API.
type
Git
l
abCredentialsSpec
struct
{
// Git
L
abCredentialsSpec defines the desired state of Git
L
abCredentials, this stores a Git
L
ab username
// and Access Token for communicating with the Git
L
ab API.
type
Git
L
abCredentialsSpec
struct
{
// URL is the url for the GitLab API that will be contacted.
URL
string
`json:"url,omitempty"`
// Username is the Git
l
ab username for the account that will be communicating with the Git
l
ab API
// Username is the Git
L
ab username for the account that will be communicating with the Git
L
ab API
Username
string
`json:"username,omitempty"`
//AccessToken is the SecretRef to the secret containing the Git
l
ab Access Token for the user.
//AccessToken is the SecretRef to the secret containing the Git
L
ab Access Token for the user.
AccessToken
v1
.
SecretReference
`json:"accessToken,omitempty"`
//AccessTokenKey is the key of the secret data that contains the Git
l
ab Access Token for the user.
//AccessTokenKey is the key of the secret data that contains the Git
L
ab Access Token for the user.
AccessTokenKey
string
`json:"accessTokenKey"`
}
// Git
l
abCredentialsStatus defines the observed state of Git
l
abCredentials
type
Git
l
abCredentialsStatus
struct
{
// Git
L
abCredentialsStatus defines the observed state of Git
L
abCredentials
type
Git
L
abCredentialsStatus
struct
{
// LastUsedTime is the time that this credential was last used to access a GitLab API
LastUsedDate
metav1
.
Time
`json:"lastUsedDate"`
}
...
...
@@ -46,24 +46,24 @@ type GitlabCredentialsStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// Git
l
abCredentials is the Schema for the gitlabcredentials API
type
Git
l
abCredentials
struct
{
// Git
L
abCredentials is the Schema for the gitlabcredentials API
type
Git
L
abCredentials
struct
{
metav1
.
TypeMeta
`json:",inline"`
metav1
.
ObjectMeta
`json:"metadata,omitempty"`
Spec
Git
l
abCredentialsSpec
`json:"spec,omitempty"`
Status
Git
l
abCredentialsStatus
`json:"status,omitempty"`
Spec
Git
L
abCredentialsSpec
`json:"spec,omitempty"`
Status
Git
L
abCredentialsStatus
`json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// Git
l
abCredentialsList contains a list of Git
l
abCredentials
type
Git
l
abCredentialsList
struct
{
// Git
L
abCredentialsList contains a list of Git
L
abCredentials
type
Git
L
abCredentialsList
struct
{
metav1
.
TypeMeta
`json:",inline"`
metav1
.
ListMeta
`json:"metadata,omitempty"`
Items
[]
Git
l
abCredentials
`json:"items"`
Items
[]
Git
L
abCredentials
`json:"items"`
}
func
init
()
{
SchemeBuilder
.
Register
(
&
Git
l
abCredentials
{},
&
Git
l
abCredentialsList
{})
SchemeBuilder
.
Register
(
&
Git
L
abCredentials
{},
&
Git
L
abCredentialsList
{})
}
apis/gitlab/v1alpha1/gitlabcredentials_types_test.go
View file @
41e7c40c
...
...
@@ -12,7 +12,7 @@ import (
)
// Reusable test variables
type
testVarsGit
l
abcredentials
=
struct
{
type
testVarsGit
L
abcredentials
=
struct
{
testKind
string
testApiversion
string
testSpec
string
...
...
@@ -23,24 +23,24 @@ type testVarsGitlabcredentials = struct {
expectedSpec
string
expectedStatus
string
testObject1
Git
l
abCredentials
testObject2
Git
l
abCredentials
testObject1
Git
L
abCredentials
testObject2
Git
L
abCredentials
objectItems1
[]
Git
l
abCredentials
objectList1
Git
l
abCredentialsList
objectItems1
[]
Git
L
abCredentials
objectList1
Git
L
abCredentialsList
objectItems2
[]
Git
l
abCredentials
objectList2
Git
l
abCredentialsList
objectItems2
[]
Git
L
abCredentials
objectList2
Git
L
abCredentialsList
testObjectSpec1
Git
l
abCredentialsSpec
testObjectSpec2
Git
l
abCredentialsSpec
testObjectSpec1
Git
L
abCredentialsSpec
testObjectSpec2
Git
L
abCredentialsSpec
testObjectStatus1
Git
l
abCredentialsStatus
testObjectStatus2
Git
l
abCredentialsStatus
testObjectStatus1
Git
L
abCredentialsStatus
testObjectStatus2
Git
L
abCredentialsStatus
}
func
initVarsGit
l
abCredentials
()
testVarsGit
l
abcredentials
{
testVars
:=
testVarsGit
l
abcredentials
{}
func
initVarsGit
L
abCredentials
()
testVarsGit
L
abcredentials
{
testVars
:=
testVarsGit
L
abcredentials
{}
testVars
.
testKind
=
"TestKind"
testVars
.
testApiversion
=
"v22"
...
...
@@ -53,27 +53,27 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
testVars
.
expectedStatus
=
testVars
.
testStatus
var
object1Metatype
metav1
.
TypeMeta
=
metav1
.
TypeMeta
{
Kind
:
testVars
.
testKind
,
APIVersion
:
testVars
.
testApiversion
}
testVars
.
testObject1
=
Git
l
abCredentials
{
TypeMeta
:
object1Metatype
}
testVars
.
testObject1
=
Git
L
abCredentials
{
TypeMeta
:
object1Metatype
}
var
object2Metatype
metav1
.
TypeMeta
=
metav1
.
TypeMeta
{
Kind
:
"TestKind2"
,
APIVersion
:
"V99"
}
testVars
.
testObject2
=
Git
l
abCredentials
{
TypeMeta
:
object2Metatype
}
testVars
.
testObject2
=
Git
L
abCredentials
{
TypeMeta
:
object2Metatype
}
var
objectList1Metatype
metav1
.
TypeMeta
=
metav1
.
TypeMeta
{
Kind
:
"TestKind_List"
,
APIVersion
:
"V12"
}
var
objectItems1
[]
Git
l
abCredentials
=
[]
Git
l
abCredentials
{
testVars
.
testObject1
,
testVars
.
testObject2
}
testVars
.
objectList1
=
Git
l
abCredentialsList
{
TypeMeta
:
objectList1Metatype
,
Items
:
objectItems1
}
var
objectItems1
[]
Git
L
abCredentials
=
[]
Git
L
abCredentials
{
testVars
.
testObject1
,
testVars
.
testObject2
}
testVars
.
objectList1
=
Git
L
abCredentialsList
{
TypeMeta
:
objectList1Metatype
,
Items
:
objectItems1
}
var
objectList2Metatype
metav1
.
TypeMeta
=
metav1
.
TypeMeta
{
Kind
:
"TestKind_List"
,
APIVersion
:
"V12"
}
var
objectItems2
[]
Git
l
abCredentials
=
[]
Git
l
abCredentials
{
testVars
.
testObject2
}
testVars
.
objectList2
=
Git
l
abCredentialsList
{
TypeMeta
:
objectList2Metatype
,
Items
:
objectItems2
}
var
objectItems2
[]
Git
L
abCredentials
=
[]
Git
L
abCredentials
{
testVars
.
testObject2
}
testVars
.
objectList2
=
Git
L
abCredentialsList
{
TypeMeta
:
objectList2Metatype
,
Items
:
objectItems2
}
testVars
.
testObjectSpec1
=
Git
l
abCredentialsSpec
{
testVars
.
testObjectSpec1
=
Git
L
abCredentialsSpec
{
URL
:
"https://example1.com"
,
Username
:
""
,
AccessToken
:
v1
.
SecretReference
{
Name
:
"mySecret"
,
Namespace
:
"aNamespace"
,
}}
testVars
.
testObjectSpec2
=
Git
l
abCredentialsSpec
{
testVars
.
testObjectSpec2
=
Git
L
abCredentialsSpec
{
URL
:
"https://example.com"
,
Username
:
"user2"
,
AccessToken
:
v1
.
SecretReference
{
...
...
@@ -83,12 +83,12 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
}
// leave scaffold Foo value for testing?
testVars
.
testObjectStatus1
=
Git
l
abCredentialsStatus
{
testVars
.
testObjectStatus1
=
Git
L
abCredentialsStatus
{
LastUsedDate
:
metav1
.
Time
{
Time
:
time
.
Now
(),
},
}
testVars
.
testObjectStatus2
=
Git
l
abCredentialsStatus
{
testVars
.
testObjectStatus2
=
Git
L
abCredentialsStatus
{
LastUsedDate
:
metav1
.
Time
{
Time
:
time
.
Now
(),
},
...
...
@@ -97,7 +97,7 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
return
testVars
}
func
TestGroupVars_Git
l
abCredentials
(
t
*
testing
.
T
)
{
func
TestGroupVars_Git
L
abCredentials
(
t
*
testing
.
T
)
{
xType
:=
reflect
.
TypeOf
(
GroupVersion
)
// convert object type to string
...
...
@@ -110,9 +110,9 @@ func TestGroupVars_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
// Test Type called Git
l
abCredentials
func
TestTypes_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
// Test Type called Git
L
abCredentials
func
TestTypes_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
want
:=
testVariables
.
expectedApiversion
got
:=
testVariables
.
testObject1
.
APIVersion
...
...
@@ -123,8 +123,8 @@ func TestTypes_GitlabCredentials(t *testing.T) {
}
// DeepCopy
func
TestDeepCopy_DeepCopy_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopy_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newObject
:=
testVariables
.
testObject1
.
DeepCopy
()
...
...
@@ -144,7 +144,7 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) {
t
.
Errorf
(
"got %s want %s"
,
got
,
want
)
}
var
nilTestPtr
*
Git
l
abCredentials
=
nil
var
nilTestPtr
*
Git
L
abCredentials
=
nil
var
val
=
nilTestPtr
.
DeepCopyObject
()
if
val
!=
nil
{
t
.
Errorf
(
"got %s want %s"
,
"not nil"
,
"nil"
)
...
...
@@ -153,8 +153,8 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyInto_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyInto_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
testVariables
.
testObject1
.
DeepCopyInto
(
&
testVariables
.
testObject2
)
...
...
@@ -167,11 +167,11 @@ func TestDeepCopy_DeepCopyInto_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyObject_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyObject_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newRuntimeObject
:=
testVariables
.
testObject1
.
DeepCopyObject
()
newObject
:=
newRuntimeObject
.
(
*
Git
l
abCredentials
)
newObject
:=
newRuntimeObject
.
(
*
Git
L
abCredentials
)
got
:=
newObject
.
APIVersion
want
:=
testVariables
.
expectedApiversion
...
...
@@ -181,8 +181,8 @@ func TestDeepCopy_DeepCopyObject_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyList_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyList_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newObjectList
:=
testVariables
.
objectList1
.
DeepCopy
()
got
:=
newObjectList
.
Items
[
0
]
.
APIVersion
...
...
@@ -193,7 +193,7 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) {
}
// a typed pointer set to nil
var
nilTestPtr
*
Git
l
abCredentialsList
=
nil
var
nilTestPtr
*
Git
L
abCredentialsList
=
nil
var
val
=
nilTestPtr
.
DeepCopy
()
if
val
!=
nil
{
t
.
Errorf
(
"got %s want %s"
,
"not nil"
,
"nil"
)
...
...
@@ -201,8 +201,8 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyIntoList_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyIntoList_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
testVariables
.
objectList1
.
DeepCopyInto
(
&
testVariables
.
objectList2
)
...
...
@@ -215,11 +215,11 @@ func TestDeepCopy_DeepCopyIntoList_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyListObject_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyListObject_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newRuntimeObject
:=
testVariables
.
objectList1
.
DeepCopyObject
()
newObject
:=
newRuntimeObject
.
(
*
Git
l
abCredentialsList
)
newObject
:=
newRuntimeObject
.
(
*
Git
L
abCredentialsList
)
got
:=
newObject
.
Items
[
0
]
.
APIVersion
want
:=
testVariables
.
expectedApiversion
...
...
@@ -227,7 +227,7 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) {
t
.
Errorf
(
"got %s want %s"
,
got
,
want
)
}
var
nilTestPtr
*
Git
l
abCredentialsList
=
nil
var
nilTestPtr
*
Git
L
abCredentialsList
=
nil
var
val
=
nilTestPtr
.
DeepCopyObject
()
if
val
!=
nil
{
t
.
Errorf
(
"got %s want %s"
,
"not nil"
,
"nil"
)
...
...
@@ -236,8 +236,8 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopySpec_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopySpec_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newObjectList
:=
testVariables
.
testObjectSpec1
.
DeepCopy
()
...
...
@@ -245,7 +245,7 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) {
Expect
(
newObjectList
)
.
To
(
Equal
(
testVariables
.
testObjectSpec1
))
})
var
nilTestPtr
*
Git
l
abCredentialsSpec
=
nil
var
nilTestPtr
*
Git
L
abCredentialsSpec
=
nil
var
val
=
nilTestPtr
.
DeepCopy
()
if
val
!=
nil
{
t
.
Errorf
(
"got %s want %s"
,
"not nil"
,
"nil"
)
...
...
@@ -253,8 +253,8 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopySpecInto_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopySpecInto_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
testVariables
.
testObjectSpec1
.
DeepCopyInto
(
&
testVariables
.
testObjectSpec2
)
...
...
@@ -263,8 +263,8 @@ func TestDeepCopy_DeepCopySpecInto_GitlabCredentials(t *testing.T) {
})
}
func
TestDeepCopy_DeepCopyStatus_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyStatus_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
newObjectStatus
:=
testVariables
.
testObjectStatus1
.
DeepCopy
()
...
...
@@ -273,7 +273,7 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) {
})
// a typed pointer set to nil
var
nilTestPtr
*
Git
l
abCredentialsStatus
=
nil
var
nilTestPtr
*
Git
L
abCredentialsStatus
=
nil
var
val
=
nilTestPtr
.
DeepCopy
()
if
val
!=
nil
{
t
.
Errorf
(
"got %s want %s"
,
"not nil"
,
"nil"
)
...
...
@@ -282,8 +282,8 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) {
t
.
Log
(
"Success"
)
}
func
TestDeepCopy_DeepCopyStatusInto_Git
l
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
l
abCredentials
()
func
TestDeepCopy_DeepCopyStatusInto_Git
L
abCredentials
(
t
*
testing
.
T
)
{
testVariables
:=
initVarsGit
L
abCredentials
()
testVariables
.
testObjectStatus1
.
DeepCopyInto
(
&
testVariables
.
testObjectStatus2
)
...
...
apis/gitlab/v1alpha1/group_types.go
View file @
41e7c40c
...
...
@@ -26,17 +26,17 @@ type GroupSpec struct {
// +kubebuilder:validation:required
FullPath
string
`json:"path"`
// Name is the name of the Group and will be used as part of the URL in Git
l
ab
// Name is the name of the Group and will be used as part of the URL in Git
L
ab
// +kubebuilder:validation:Required
Name
string
`json:"name"`
// Description is the Git
l
ab Description for the group
// Description is the Git
L
ab Description for the group
// +kubebuilder:validation:optional
Description
string
`json:"description"`
// Git
l
abCredentialsName is the name of the object in this namespace that contains authentication
// Git
L
abCredentialsName is the name of the object in this namespace that contains authentication
// information for logging into the
Git
l
abCredentialsName
string
`json:"gitlabCredentialsName"`
Git
L
abCredentialsName
string
`json:"gitlabCredentialsName"`
// KustomizeProductionPath is the relative path for the kustomization manifest for production use
// +kubebuilder:validation:required
...
...
apis/gitlab/v1alpha1/group_types_test.go
View file @
41e7c40c
...
...
@@ -69,12 +69,12 @@ func initVarsGroup() testVarsGroup {
testVars
.
testObjectSpec1
=
GroupSpec
{
Name
:
"testGroup1"
,
Git
l
abCredentialsName
:
"nameOfTheCredentials"
,
Git
L
abCredentialsName
:
"nameOfTheCredentials"
,
Description
:
"testDescription1"
,
}
testVars
.
testObjectSpec2
=
GroupSpec
{
Name
:
"testGroup2"
,
Git
l
abCredentialsName
:
"nameOfCredentials2"
,
Git
L
abCredentialsName
:
"nameOfCredentials2"
,
ProjectSpecs
:
nil
,
Description
:
"testDescription2"
,
}
...
...
apis/gitlab/v1alpha1/project_types.go
View file @
41e7c40c
...
...
@@ -34,9 +34,9 @@ type ProjectSpec struct {
// +kubebuilder:validation:required
FullPath
string
`json:"path"`
// Git
l
abCredentialsName is the name of the object in this namespace that contains authentication
// Git
L
abCredentialsName is the name of the object in this namespace that contains authentication
// information for logging into the
Git
l
abCredentialsName
string
`json:"gitlabCredentialsName"`
Git
L
abCredentialsName
string
`json:"gitlabCredentialsName"`
// ImpactLevel is the RMF Impact Level for this Project
// +kubebuilder:validation:Enum=2;4;5;6
...
...
@@ -61,6 +61,10 @@ type ProjectSpec struct {
// ManifestImage is the name of the DockerImage for the Project application
// +kubebuilder:validation:required
ManifestImage
string
`json:"manifestImage"`
// CiConfigurationPath is the GitLab path to the CI configuration file in the CI/CD Settings of the project
// +kubebuilder:validation:required
CiConfigurationPath
string
`json:"ciConfigurationPath"`
}
// ProjectStatus defines the observed state of Project
...
...
apis/gitlab/v1alpha1/zz_generated.deepcopy.go
View file @
41e7c40c
...
...
@@ -214,7 +214,7 @@ func (in *DNSRepoMergeRequestStatus) DeepCopy() *DNSRepoMergeRequestStatus {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func
(
in
*
Git
l
abCredentials
)
DeepCopyInto
(
out
*
Git
l
abCredentials
)
{
func
(
in
*
Git
L
abCredentials
)
DeepCopyInto
(
out
*
Git
L
abCredentials
)
{
*
out
=
*
in
out
.
TypeMeta
=
in
.
TypeMeta
in
.
ObjectMeta
.
DeepCopyInto
(
&
out
.
ObjectMeta
)
...
...
@@ -222,18 +222,18 @@ func (in *GitlabCredentials) DeepCopyInto(out *GitlabCredentials) {
in
.
Status
.
DeepCopyInto
(
&
out
.
Status
)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
l
abCredentials.
func
(
in
*
Git
l
abCredentials
)
DeepCopy
()
*
Git
l
abCredentials
{
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
L
abCredentials.
func
(
in
*
Git
L
abCredentials
)
DeepCopy
()
*
Git
L
abCredentials
{
if
in
==
nil
{
return
nil
}
out
:=
new
(
Git
l
abCredentials
)
out
:=
new
(
Git
L
abCredentials
)
in
.
DeepCopyInto
(
out
)
return
out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func
(
in
*
Git
l
abCredentials
)
DeepCopyObject
()
runtime
.
Object
{
func
(
in
*
Git
L
abCredentials
)
DeepCopyObject
()
runtime
.
Object
{
if
c
:=
in
.
DeepCopy
();
c
!=
nil
{
return
c
}
...
...
@@ -241,31 +241,31 @@ func (in *GitlabCredentials) DeepCopyObject() runtime.Object {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func
(
in
*
Git
l
abCredentialsList
)
DeepCopyInto
(
out
*
Git
l
abCredentialsList
)
{
func
(
in
*
Git
L
abCredentialsList
)
DeepCopyInto
(
out
*
Git
L
abCredentialsList
)
{
*
out
=
*
in
out
.
TypeMeta
=
in
.
TypeMeta
in
.
ListMeta
.
DeepCopyInto
(
&
out
.
ListMeta
)
if
in
.
Items
!=
nil
{
in
,
out
:=
&
in
.
Items
,
&
out
.
Items
*
out
=
make
([]
Git
l
abCredentials
,
len
(
*
in
))
*
out
=
make
([]
Git
L
abCredentials
,
len
(
*
in
))
for
i
:=
range
*
in
{
(
*
in
)[
i
]
.
DeepCopyInto
(
&
(
*
out
)[
i
])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
l
abCredentialsList.
func
(
in
*
Git
l
abCredentialsList
)
DeepCopy
()
*
Git
l
abCredentialsList
{
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
L
abCredentialsList.
func
(
in
*
Git
L
abCredentialsList
)
DeepCopy
()
*
Git
L
abCredentialsList
{
if
in
==
nil
{
return
nil
}
out
:=
new
(
Git
l
abCredentialsList
)
out
:=
new
(
Git
L
abCredentialsList
)
in
.
DeepCopyInto
(
out
)
return
out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func
(
in
*
Git
l
abCredentialsList
)
DeepCopyObject
()
runtime
.
Object
{
func
(
in
*
Git
L
abCredentialsList
)
DeepCopyObject
()
runtime
.
Object
{
if
c
:=
in
.
DeepCopy
();
c
!=
nil
{
return
c
}
...
...
@@ -273,33 +273,33 @@ func (in *GitlabCredentialsList) DeepCopyObject() runtime.Object {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func
(
in
*
Git
l
abCredentialsSpec
)
DeepCopyInto
(
out
*
Git
l
abCredentialsSpec
)
{
func
(
in
*
Git
L
abCredentialsSpec
)
DeepCopyInto
(
out
*
Git
L
abCredentialsSpec
)
{
*
out
=
*
in
out
.
AccessToken
=
in
.
AccessToken
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
l
abCredentialsSpec.
func
(
in
*
Git
l
abCredentialsSpec
)
DeepCopy
()
*
Git
l
abCredentialsSpec
{
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
L
abCredentialsSpec.
func
(
in
*
Git
L
abCredentialsSpec
)
DeepCopy
()
*
Git
L
abCredentialsSpec
{
if
in
==
nil
{
return
nil
}
out
:=
new
(
Git
l
abCredentialsSpec
)
out
:=
new
(
Git
L
abCredentialsSpec
)
in
.
DeepCopyInto
(
out
)
return
out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func
(
in
*
Git
l
abCredentialsStatus
)
DeepCopyInto
(
out
*
Git
l
abCredentialsStatus
)
{
func
(
in
*
Git
L
abCredentialsStatus
)
DeepCopyInto
(
out
*
Git
L
abCredentialsStatus
)
{
*
out
=
*
in
in
.
LastUsedDate
.
DeepCopyInto
(
&
out
.
LastUsedDate
)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
l
abCredentialsStatus.
func
(
in
*
Git
l
abCredentialsStatus
)
DeepCopy
()
*
Git
l
abCredentialsStatus
{
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Git
L
abCredentialsStatus.
func
(
in
*
Git
L
abCredentialsStatus
)
DeepCopy
()
*
Git
L
abCredentialsStatus
{
if
in
==
nil
{
return
nil
}
out
:=
new
(
Git
l
abCredentialsStatus
)
out
:=
new
(
Git
L
abCredentialsStatus
)
in
.
DeepCopyInto
(
out
)
return
out
}
...
...
clients/gitlab/client_test.go
View file @
41e7c40c
This diff is collapsed.
Click to expand it.
config/crd/bases/gitlab.valkyrie.dso.mil_dnsrepocredentials.yaml
View file @
41e7c40c
...
...
@@ -37,8 +37,8 @@ spec:
description
:
DNSRepoCredentialSpec defines the desired state of DNSRepoCredential
properties
:
gitlabProjectId
:
description
:
Git
l
abProjectID is the project ID of the DNS project
in Git
l
ab
description
:
Git
L
abProjectID is the project ID of the DNS project
in Git
L
ab
type
:
integer
repoUrl
:
description
:
'
RepoURL
is
the
url
for
the
DNS
git
repository.
For
example:
...
...
config/crd/bases/gitlab.valkyrie.dso.mil_gitlabcredentials.yaml
View file @
41e7c40c
...
...
@@ -10,8 +10,8 @@ metadata:
spec
:
group
:
gitlab.valkyrie.dso.mil
names
:
kind
:
Git
l
abCredentials
listKind
:
Git
l
abCredentialsList
kind
:
Git
L
abCredentials
listKind
:
Git
L
abCredentialsList
plural
:
gitlabcredentials
singular
:
gitlabcredentials
scope
:
Namespaced
...
...
@@ -19,7 +19,7 @@ spec:
-
name
:
v1alpha1
schema
:
openAPIV3Schema
:
description
:
Git
l
abCredentials is the Schema for the gitlabcredentials API
description
:
Git
L
abCredentials is the Schema for the gitlabcredentials API
properties
:
apiVersion
:
description
:
'
APIVersion
defines
the
versioned
schema
of
this
representation
...
...
@@ -34,13 +34,13 @@ spec:
metadata
:
type
:
object
spec
:
description
:
Git
l
abCredentialsSpec defines the desired state of Git
l
abCredentials,
this stores a Git
l
ab username and Access Token for communicating with
the Git
l
ab API.
description
:
Git
L
abCredentialsSpec defines the desired state of Git
L
abCredentials,
this stores a Git
L
ab username and Access Token for communicating with
the Git
L
ab API.
properties
:
accessToken
:
description
:
AccessToken is the SecretRef to the secret containing
the Git
l
ab Access Token for the user.
the Git
L
ab Access Token for the user.
properties
:
name
:
description
:
Name is unique within a namespace to reference a
...
...
@@ -53,20 +53,20 @@ spec:
type
:
object
accessTokenKey
:
description
:
AccessTokenKey is the key of the secret data that contains
the Git
l
ab Access Token for the user.
the Git
L
ab Access Token for the user.
type
:
string
url
:
description
:
URL is the url for the GitLab API that will be contacted.
type
:
string
username
:
description
:
Username is the Git
l
ab username for the account that
will be communicating with the Git
l
ab API
description
:
Username is the Git
L
ab username for the account that
will be communicating with the Git
L
ab API
type
:
string
required
:
-
accessTokenKey
type
:
object
status
:
description
:
Git
l
abCredentialsStatus defines the observed state of Git
l
abCredentials
description
:
Git
L
abCredentialsStatus defines the observed state of Git
L
abCredentials
properties
:
lastUsedDate
:
description
:
LastUsedTime is the time that this credential was last
...
...
config/crd/bases/gitlab.valkyrie.dso.mil_groups.yaml
View file @
41e7c40c
...
...
@@ -37,10 +37,10 @@ spec:
description
:
GroupSpec defines the desired state of Group
properties
:
description
:
description
:
Description is the Git
l
ab Description for the group
description
:
Description is the Git
L
ab Description for the group
type
:
string
gitlabCredentialsName
:
description
:
Git
l
abCredentialsName is the name of the object in this
description
:
Git
L
abCredentialsName is the name of the object in this
namespace that contains authentication information for logging into
the
type
:
string
...
...
@@ -58,7 +58,7 @@ spec:
type
:
string
name
:
description
:
Name is the name of the Group and will be used as part
of the URL in Git
l
ab
of the URL in Git
L
ab
type
:
string
path
:
description
:
FullPath is the gitlab path for this Project
...
...
@@ -70,8 +70,12 @@ spec:
items
:
description
:
ProjectSpec defines the desired state of Project
properties
:
ciConfigurationPath
:
description
:
CiConfigurationPath is the GitLab path to the CI
configuration file in the CI/CD Settings of the project
type
:
string
gitlabCredentialsName
:
description
:
Git
l
abCredentialsName is the name of the object
description
:
Git
L
abCredentialsName is the name of the object
in this namespace that contains authentication information
for logging into the
type
:
string
...
...
@@ -118,6 +122,7 @@ spec:
will be created for this Project
type
:
string
required
:
-
ciConfigurationPath
-
gitlabCredentialsName
-
groupId
-
impactLevel
...
...
config/crd/bases/gitlab.valkyrie.dso.mil_projects.yaml
View file @
41e7c40c
...
...
@@ -36,8 +36,12 @@ spec:
spec
:
description
:
ProjectSpec defines the desired state of Project
properties
:
ciConfigurationPath
:
description
:
CiConfigurationPath is the GitLab path to the CI configuration
file in the CI/CD Settings of the project
type
:
string
gitlabCredentialsName
:
description
:
Git
l
abCredentialsName is the name of the object in this
description
:
Git
L
abCredentialsName is the name of the object in this
namespace that contains authentication information for logging into
the
type
:
string
...
...
@@ -84,6 +88,7 @@ spec:
be created for this Project
type
:
string
required
:
-
ciConfigurationPath
-
gitlabCredentialsName
-
groupId
-
impactLevel
...
...
config/samples/gitlab_v1alpha1_gitlabcredentials.yaml
View file @
41e7c40c
...
...
@@ -7,7 +7,7 @@ data:
accesstoken
:
cGFzc3dvcmQ=
---
apiVersion
:
gitlab.valkyrie.dso.mil/v1alpha1
kind
:
Git
l
abCredentials
kind
:
Git
L
abCredentials
metadata
:
name
:
gitlab-credentials
namespace
:
default
...
...
controllers/gitlab/dnsrepomergerequest_controller.go
View file @
41e7c40c
...
...
@@ -105,10 +105,10 @@ func (r *DNSRepoMergeRequestReconciler) Reconcile(ctx context.Context, req ctrl.
}
repoURL
:=
credential
.
Spec
.
RepoURL
projectID
:=
credential
.
Spec
.
Git
l
abProjectID
projectID
:=
credential
.
Spec
.
Git
L
abProjectID
//create Git
l
ab client for API calls
gitlabAPIURL
:=
getGit
l
abAPIURL
(
repoURL
)
//create Git
L
ab client for API calls
gitlabAPIURL
:=
getGit
L
abAPIURL
(
repoURL
)
var
gitlabClient
gitlab
.
Client
if
r
.
gitlabTestClient
!=
nil
{
gitlabClient
=
r
.
gitlabTestClient
...
...
@@ -222,7 +222,7 @@ func cleanUpOldResources(dnsMergeRequest gitlabv1alpha1.DNSRepoMergeRequest, log
//example input: https://code.il2.dso.mil/platform-one/products/valkyrie/dso-dns.git
//example output: https://code.il2.dso.mil/api/v4
func
getGit
l
abAPIURL
(
repoURL
string
)
string
{
func
getGit
L
abAPIURL
(
repoURL
string
)
string
{
subs
:=
strings
.
Split
(
repoURL
,
"/"
)
return
subs
[
0
]
+
"/"
+
subs
[
1
]
+
"/"
+
subs
[
2
]
+
"/api/v4"
}
...
...
controllers/gitlab/dnsrepomergerequest_controller_test.go
View file @
41e7c40c
...
...
@@ -128,7 +128,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta
:
metav1
.
ObjectMeta
{},
Spec
:
gitlabv1alpha1
.
DNSRepoCredentialSpec
{
RepoURL
:
"https://test"
,
Git
l
abProjectID
:
4148
,
Git
L
abProjectID
:
4148
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secretName"
},
Key
:
"username"
,
...
...
@@ -198,7 +198,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta
:
metav1
.
ObjectMeta
{},
Spec
:
gitlabv1alpha1
.
DNSRepoCredentialSpec
{
RepoURL
:
"https://test"
,
Git
l
abProjectID
:
4148
,
Git
L
abProjectID
:
4148
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secretName"
},
Key
:
"username"
,
...
...
@@ -246,7 +246,7 @@ var _ = Describe("Reconcile", func() {
Name
:
repoCred
.
Spec
.
UsernameSecRef
.
Name
,
}]
=
&
secret
sut
.
gitlabTestClient
=
&
MockGit
l
abClient
{
sut
.
gitlabTestClient
=
&
MockGit
L
abClient
{
getMRByIDFunc
:
func
(
projectID
int
,
mrID
int
)
(
*
gitlab
.
MergeRequest
,
error
)
{
return
&
gitlab
.
MergeRequest
{
ProjectID
:
projectID
,
...
...
@@ -307,7 +307,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta
:
metav1
.
ObjectMeta
{},
Spec
:
gitlabv1alpha1
.
DNSRepoCredentialSpec
{
RepoURL
:
"https://test"
,
Git
l
abProjectID
:
4148
,
Git
L
abProjectID
:
4148
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secretName"
},
Key
:
"username"
,
...
...
@@ -359,7 +359,7 @@ var _ = Describe("Reconcile", func() {
Name
:
repoCred
.
Spec
.
UsernameSecRef
.
Name
,
}]
=
&
secret
sut
.
gitlabTestClient
=
&
MockGit
l
abClient
{
sut
.
gitlabTestClient
=
&
MockGit
L
abClient
{
getMRByIDFunc
:
func
(
projectID
int
,
mrID
int
)
(
*
gitlab
.
MergeRequest
,
error
)
{
return
&
gitlab
.
MergeRequest
{
ProjectID
:
projectID
,
...
...
@@ -416,7 +416,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta
:
metav1
.
ObjectMeta
{},
Spec
:
gitlabv1alpha1
.
DNSRepoCredentialSpec
{
RepoURL
:
"https://test"
,
Git
l
abProjectID
:
4148
,
Git
L
abProjectID
:
4148
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secretName"
},
Key
:
"username"
,
...
...
@@ -468,7 +468,7 @@ var _ = Describe("Reconcile", func() {
Name
:
repoCred
.
Spec
.
UsernameSecRef
.
Name
,
}]
=
&
secret
sut
.
gitlabTestClient
=
&
MockGit
l
abClient
{
sut
.
gitlabTestClient
=
&
MockGit
L
abClient
{
getMRByIDFunc
:
func
(
projectID
int
,
mrID
int
)
(
*
gitlab
.
MergeRequest
,
error
)
{
return
&
gitlab
.
MergeRequest
{
ProjectID
:
projectID
,
...
...
@@ -578,7 +578,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta
:
metav1
.
ObjectMeta
{},
Spec
:
gitlabv1alpha1
.
DNSRepoCredentialSpec
{
RepoURL
:
"https://test"
,
Git
l
abProjectID
:
4148
,
Git
L
abProjectID
:
4148
,
UsernameSecRef
:
v1
.
SecretKeySelector
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"secretName"
},
Key
:
"username"
,
...
...
@@ -630,7 +630,7 @@ var _ = Describe("Reconcile", func() {
Name
:
repoCred
.
Spec
.
UsernameSecRef
.
Name
,
}]
=
&
secret
sut
.
gitlabTestClient
=
&
MockGit
l
abClient
{
sut
.
gitlabTestClient
=
&
MockGit
L
abClient
{
getMRByIDFunc
:
func
(
projectID
int
,
mrID
int
)
(
*
gitlab
.
MergeRequest
,
error
)
{
return
&
gitlab
.
MergeRequest
{
ProjectID
:
projectID
,
...
...
controllers/gitlab/gitlabcredentials_controller.go
View file @
41e7c40c
...
...
@@ -27,7 +27,7 @@ import (
gitlabv1alpha1
"valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1"
)
// CredentialsReconciler reconciles a Git
l
abCredentials object
// CredentialsReconciler reconciles a Git
L
abCredentials object
type
CredentialsReconciler
struct
{
client
.
Client
Log
logr
.
Logger
...
...
@@ -52,6 +52,6 @@ func (r *CredentialsReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// SetupWithManager sets up the controller with the Manager.
func
(
r
*
CredentialsReconciler
)
SetupWithManager
(
mgr
ctrl
.
Manager
)
error
{
return
ctrl
.
NewControllerManagedBy
(
mgr
)
.
For
(
&
gitlabv1alpha1
.
Git
l
abCredentials
{})
.
For
(
&
gitlabv1alpha1
.
Git
L
abCredentials
{})
.
Complete
(
r
)
}
controllers/gitlab/gitlabcredentials_controller_test.go
View file @
41e7c40c
...
...
@@ -41,7 +41,7 @@ var _ = Describe("gitlabcredentials_controller", func() {
})
})
Describe
(
"SetupWithManager"
,
func
()
{
gitlabv1alpha1
.
SchemeBuilder
.
Register
(
&
gitlabv1alpha1
.
Git
l
abCredentials
{},
&
gitlabv1alpha1
.
Git
l
abCredentialsList
{})
gitlabv1alpha1
.
SchemeBuilder
.
Register
(
&
gitlabv1alpha1
.
Git
L
abCredentials
{},
&
gitlabv1alpha1
.
Git
L
abCredentialsList
{})
sut
:=
CredentialsReconciler
{
Client
:
nil
,
Log
:
nil
,
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment