UNCLASSIFIED

Commit 09ef6eeb authored by Jason van Brackel's avatar Jason van Brackel
Browse files

feat: Add CI Config file to project reconciler

parent 19224546
...@@ -101,7 +101,7 @@ resources: ...@@ -101,7 +101,7 @@ resources:
controller: true controller: true
domain: valkyrie.dso.mil domain: valkyrie.dso.mil
group: gitlab group: gitlab
kind: GitlabCredentials kind: GitLabCredentials
path: valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1 path: valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1
version: v1alpha1 version: v1alpha1
- api: - api:
......
...@@ -12,14 +12,14 @@ import ( ...@@ -12,14 +12,14 @@ import (
) )
const ( const (
errorUnableToFetchGitlabCredentials = "unable to fetch gitlab credentials" errorUnableToFetchGitLabCredentials = "unable to fetch gitlab credentials"
errorUnableToFetchSecret = "unable to fetch secret from gitlab credentials" errorUnableToFetchSecret = "unable to fetch secret from gitlab credentials"
errorUnableToCreateGitlabClient = "unable to create gitlab client" errorUnableToCreateGitLabClient = "unable to create gitlab client"
) )
// ClientConfiguration represents an object whose purpose is to setup a Gitlab client given // ClientConfiguration represents an object whose purpose is to setup a GitLab client given
type ClientConfiguration interface { type ClientConfiguration interface {
// SetupClient pulls the GitlabCredentials from Kubernetes and supplies the Gitlab user and access token. // SetupClient pulls the GitLabCredentials from Kubernetes and supplies the GitLab user and access token.
SetupClient(client client.Client, credentialsName string) (gitlabClient.Client, error) SetupClient(client client.Client, credentialsName string) (gitlabClient.Client, error)
} }
...@@ -31,18 +31,18 @@ type ClientConfigurationImpl struct { ...@@ -31,18 +31,18 @@ type ClientConfigurationImpl struct {
Req ctrl.Request Req ctrl.Request
} }
// SetupClient looks up the gitlab credentials to get the access token and username for connecting to Gitlab // SetupClient looks up the gitlab credentials to get the access token and username for connecting to GitLab
// on behalf of the reconciler. // on behalf of the reconciler.
func (c ClientConfigurationImpl) SetupClient(client client.Client, credentialsName string) (gitlabClient.Client, error) { func (c ClientConfigurationImpl) SetupClient(client client.Client, credentialsName string) (gitlabClient.Client, error) {
// Get the Gitlab Credentials // Get the GitLab Credentials
var gitLabCredentialsName = types.NamespacedName{ var gitLabCredentialsName = types.NamespacedName{
Namespace: c.Req.Namespace, Namespace: c.Req.Namespace,
Name: credentialsName, Name: credentialsName,
} }
var gitlabCredentials gitlabv1alpha1.GitlabCredentials var gitlabCredentials gitlabv1alpha1.GitLabCredentials
if err := client.Get(c.Ctx, gitLabCredentialsName, &gitlabCredentials); err != nil { if err := client.Get(c.Ctx, gitLabCredentialsName, &gitlabCredentials); err != nil {
c.Log.Error(err, errorUnableToFetchGitlabCredentials) c.Log.Error(err, errorUnableToFetchGitLabCredentials)
return nil, err return nil, err
} }
...@@ -58,13 +58,13 @@ func (c ClientConfigurationImpl) SetupClient(client client.Client, credentialsNa ...@@ -58,13 +58,13 @@ func (c ClientConfigurationImpl) SetupClient(client client.Client, credentialsNa
return nil, err return nil, err
} }
// Login to Gitlab // Login to GitLab
var accessToken = string(secret.Data[gitlabCredentials.Spec.AccessTokenKey]) var accessToken = string(secret.Data[gitlabCredentials.Spec.AccessTokenKey])
var returnClient gitlabClient.Client var returnClient gitlabClient.Client
var err error var err error
if returnClient, err = gitlabClient.NewClient(accessToken, gitlabCredentials.Spec.URL, nil); err != nil { if returnClient, err = gitlabClient.NewClient(accessToken, gitlabCredentials.Spec.URL, nil); err != nil {
c.Log.Error(err, errorUnableToCreateGitlabClient, "username", gitlabCredentials.Spec.Username, "url", gitlabCredentials.Spec.URL) c.Log.Error(err, errorUnableToCreateGitLabClient, "username", gitlabCredentials.Spec.Username, "url", gitlabCredentials.Spec.URL)
return nil, err return nil, err
} }
......
...@@ -26,8 +26,8 @@ type DNSRepoCredentialSpec struct { ...@@ -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 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"` RepoURL string `json:"repoUrl,omitempty"`
// GitlabProjectID is the project ID of the DNS project in Gitlab // GitLabProjectID is the project ID of the DNS project in GitLab
GitlabProjectID int `json:"gitlabProjectId,omitempty"` GitLabProjectID int `json:"gitlabProjectId,omitempty"`
// UsernameSecRef is the username of project bot will be used to clone the repo // UsernameSecRef is the username of project bot will be used to clone the repo
UsernameSecRef v1.SecretKeySelector `json:"usernameSecretRef,omitempty"` UsernameSecRef v1.SecretKeySelector `json:"usernameSecretRef,omitempty"`
......
...@@ -69,7 +69,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential { ...@@ -69,7 +69,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential {
// leave scaffold Foo value for testing? // leave scaffold Foo value for testing?
testVars.testObjectSpec1 = DNSRepoCredentialSpec{ testVars.testObjectSpec1 = DNSRepoCredentialSpec{
RepoURL: "https://test.git", RepoURL: "https://test.git",
GitlabProjectID: 4351, GitLabProjectID: 4351,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secret"}, LocalObjectReference: v1.LocalObjectReference{Name: "secret"},
Key: "username", Key: "username",
...@@ -81,7 +81,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential { ...@@ -81,7 +81,7 @@ func initVarsDNSRepoCredential() testVarsDNSRepoCredential {
} }
testVars.testObjectSpec2 = DNSRepoCredentialSpec{ testVars.testObjectSpec2 = DNSRepoCredentialSpec{
RepoURL: "https://test22.git", RepoURL: "https://test22.git",
GitlabProjectID: 4351, GitLabProjectID: 4351,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secret"}, LocalObjectReference: v1.LocalObjectReference{Name: "secret"},
Key: "username", Key: "username",
......
...@@ -21,24 +21,24 @@ import ( ...@@ -21,24 +21,24 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// GitlabCredentialsSpec defines the desired state of GitlabCredentials, this stores a Gitlab username // GitLabCredentialsSpec defines the desired state of GitLabCredentials, this stores a GitLab username
// and Access Token for communicating with the Gitlab API. // and Access Token for communicating with the GitLab API.
type GitlabCredentialsSpec struct { type GitLabCredentialsSpec struct {
// URL is the url for the GitLab API that will be contacted. // URL is the url for the GitLab API that will be contacted.
URL string `json:"url,omitempty"` URL string `json:"url,omitempty"`
// Username is the Gitlab username for the account that will be communicating with the Gitlab API // Username is the GitLab username for the account that will be communicating with the GitLab API
Username string `json:"username,omitempty"` Username string `json:"username,omitempty"`
//AccessToken is the SecretRef to the secret containing the Gitlab Access Token for the user. //AccessToken is the SecretRef to the secret containing the GitLab Access Token for the user.
AccessToken v1.SecretReference `json:"accessToken,omitempty"` AccessToken v1.SecretReference `json:"accessToken,omitempty"`
//AccessTokenKey is the key of the secret data that contains the Gitlab Access Token for the user. //AccessTokenKey is the key of the secret data that contains the GitLab Access Token for the user.
AccessTokenKey string `json:"accessTokenKey"` AccessTokenKey string `json:"accessTokenKey"`
} }
// GitlabCredentialsStatus defines the observed state of GitlabCredentials // GitLabCredentialsStatus defines the observed state of GitLabCredentials
type GitlabCredentialsStatus struct { type GitLabCredentialsStatus struct {
// LastUsedTime is the time that this credential was last used to access a GitLab API // LastUsedTime is the time that this credential was last used to access a GitLab API
LastUsedDate metav1.Time `json:"lastUsedDate"` LastUsedDate metav1.Time `json:"lastUsedDate"`
} }
...@@ -46,24 +46,24 @@ type GitlabCredentialsStatus struct { ...@@ -46,24 +46,24 @@ type GitlabCredentialsStatus struct {
//+kubebuilder:object:root=true //+kubebuilder:object:root=true
//+kubebuilder:subresource:status //+kubebuilder:subresource:status
// GitlabCredentials is the Schema for the gitlabcredentials API // GitLabCredentials is the Schema for the gitlabcredentials API
type GitlabCredentials struct { type GitLabCredentials struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GitlabCredentialsSpec `json:"spec,omitempty"` Spec GitLabCredentialsSpec `json:"spec,omitempty"`
Status GitlabCredentialsStatus `json:"status,omitempty"` Status GitLabCredentialsStatus `json:"status,omitempty"`
} }
//+kubebuilder:object:root=true //+kubebuilder:object:root=true
// GitlabCredentialsList contains a list of GitlabCredentials // GitLabCredentialsList contains a list of GitLabCredentials
type GitlabCredentialsList struct { type GitLabCredentialsList struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"` metav1.ListMeta `json:"metadata,omitempty"`
Items []GitlabCredentials `json:"items"` Items []GitLabCredentials `json:"items"`
} }
func init() { func init() {
SchemeBuilder.Register(&GitlabCredentials{}, &GitlabCredentialsList{}) SchemeBuilder.Register(&GitLabCredentials{}, &GitLabCredentialsList{})
} }
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
) )
// Reusable test variables // Reusable test variables
type testVarsGitlabcredentials = struct { type testVarsGitLabcredentials = struct {
testKind string testKind string
testApiversion string testApiversion string
testSpec string testSpec string
...@@ -23,24 +23,24 @@ type testVarsGitlabcredentials = struct { ...@@ -23,24 +23,24 @@ type testVarsGitlabcredentials = struct {
expectedSpec string expectedSpec string
expectedStatus string expectedStatus string
testObject1 GitlabCredentials testObject1 GitLabCredentials
testObject2 GitlabCredentials testObject2 GitLabCredentials
objectItems1 []GitlabCredentials objectItems1 []GitLabCredentials
objectList1 GitlabCredentialsList objectList1 GitLabCredentialsList
objectItems2 []GitlabCredentials objectItems2 []GitLabCredentials
objectList2 GitlabCredentialsList objectList2 GitLabCredentialsList
testObjectSpec1 GitlabCredentialsSpec testObjectSpec1 GitLabCredentialsSpec
testObjectSpec2 GitlabCredentialsSpec testObjectSpec2 GitLabCredentialsSpec
testObjectStatus1 GitlabCredentialsStatus testObjectStatus1 GitLabCredentialsStatus
testObjectStatus2 GitlabCredentialsStatus testObjectStatus2 GitLabCredentialsStatus
} }
func initVarsGitlabCredentials() testVarsGitlabcredentials { func initVarsGitLabCredentials() testVarsGitLabcredentials {
testVars := testVarsGitlabcredentials{} testVars := testVarsGitLabcredentials{}
testVars.testKind = "TestKind" testVars.testKind = "TestKind"
testVars.testApiversion = "v22" testVars.testApiversion = "v22"
...@@ -53,27 +53,27 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials { ...@@ -53,27 +53,27 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
testVars.expectedStatus = testVars.testStatus testVars.expectedStatus = testVars.testStatus
var object1Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: testVars.testKind, APIVersion: testVars.testApiversion} var object1Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: testVars.testKind, APIVersion: testVars.testApiversion}
testVars.testObject1 = GitlabCredentials{TypeMeta: object1Metatype} testVars.testObject1 = GitLabCredentials{TypeMeta: object1Metatype}
var object2Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind2", APIVersion: "V99"} var object2Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind2", APIVersion: "V99"}
testVars.testObject2 = GitlabCredentials{TypeMeta: object2Metatype} testVars.testObject2 = GitLabCredentials{TypeMeta: object2Metatype}
var objectList1Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind_List", APIVersion: "V12"} var objectList1Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind_List", APIVersion: "V12"}
var objectItems1 []GitlabCredentials = []GitlabCredentials{testVars.testObject1, testVars.testObject2} var objectItems1 []GitLabCredentials = []GitLabCredentials{testVars.testObject1, testVars.testObject2}
testVars.objectList1 = GitlabCredentialsList{TypeMeta: objectList1Metatype, Items: objectItems1} testVars.objectList1 = GitLabCredentialsList{TypeMeta: objectList1Metatype, Items: objectItems1}
var objectList2Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind_List", APIVersion: "V12"} var objectList2Metatype metav1.TypeMeta = metav1.TypeMeta{Kind: "TestKind_List", APIVersion: "V12"}
var objectItems2 []GitlabCredentials = []GitlabCredentials{testVars.testObject2} var objectItems2 []GitLabCredentials = []GitLabCredentials{testVars.testObject2}
testVars.objectList2 = GitlabCredentialsList{TypeMeta: objectList2Metatype, Items: objectItems2} testVars.objectList2 = GitLabCredentialsList{TypeMeta: objectList2Metatype, Items: objectItems2}
testVars.testObjectSpec1 = GitlabCredentialsSpec{ testVars.testObjectSpec1 = GitLabCredentialsSpec{
URL: "https://example1.com", URL: "https://example1.com",
Username: "", Username: "",
AccessToken: v1.SecretReference{ AccessToken: v1.SecretReference{
Name: "mySecret", Name: "mySecret",
Namespace: "aNamespace", Namespace: "aNamespace",
}} }}
testVars.testObjectSpec2 = GitlabCredentialsSpec{ testVars.testObjectSpec2 = GitLabCredentialsSpec{
URL: "https://example.com", URL: "https://example.com",
Username: "user2", Username: "user2",
AccessToken: v1.SecretReference{ AccessToken: v1.SecretReference{
...@@ -83,12 +83,12 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials { ...@@ -83,12 +83,12 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
} }
// leave scaffold Foo value for testing? // leave scaffold Foo value for testing?
testVars.testObjectStatus1 = GitlabCredentialsStatus{ testVars.testObjectStatus1 = GitLabCredentialsStatus{
LastUsedDate: metav1.Time{ LastUsedDate: metav1.Time{
Time: time.Now(), Time: time.Now(),
}, },
} }
testVars.testObjectStatus2 = GitlabCredentialsStatus{ testVars.testObjectStatus2 = GitLabCredentialsStatus{
LastUsedDate: metav1.Time{ LastUsedDate: metav1.Time{
Time: time.Now(), Time: time.Now(),
}, },
...@@ -97,7 +97,7 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials { ...@@ -97,7 +97,7 @@ func initVarsGitlabCredentials() testVarsGitlabcredentials {
return testVars return testVars
} }
func TestGroupVars_GitlabCredentials(t *testing.T) { func TestGroupVars_GitLabCredentials(t *testing.T) {
xType := reflect.TypeOf(GroupVersion) xType := reflect.TypeOf(GroupVersion)
// convert object type to string // convert object type to string
...@@ -110,9 +110,9 @@ func TestGroupVars_GitlabCredentials(t *testing.T) { ...@@ -110,9 +110,9 @@ func TestGroupVars_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
// Test Type called GitlabCredentials // Test Type called GitLabCredentials
func TestTypes_GitlabCredentials(t *testing.T) { func TestTypes_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
want := testVariables.expectedApiversion want := testVariables.expectedApiversion
got := testVariables.testObject1.APIVersion got := testVariables.testObject1.APIVersion
...@@ -123,8 +123,8 @@ func TestTypes_GitlabCredentials(t *testing.T) { ...@@ -123,8 +123,8 @@ func TestTypes_GitlabCredentials(t *testing.T) {
} }
// DeepCopy // DeepCopy
func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopy_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newObject := testVariables.testObject1.DeepCopy() newObject := testVariables.testObject1.DeepCopy()
...@@ -144,7 +144,7 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) { ...@@ -144,7 +144,7 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) {
t.Errorf("got %s want %s", got, want) t.Errorf("got %s want %s", got, want)
} }
var nilTestPtr *GitlabCredentials = nil var nilTestPtr *GitLabCredentials = nil
var val = nilTestPtr.DeepCopyObject() var val = nilTestPtr.DeepCopyObject()
if val != nil { if val != nil {
t.Errorf("got %s want %s", "not nil", "nil") t.Errorf("got %s want %s", "not nil", "nil")
...@@ -153,8 +153,8 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) { ...@@ -153,8 +153,8 @@ func TestDeepCopy_DeepCopy_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyInto_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyInto_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
testVariables.testObject1.DeepCopyInto(&testVariables.testObject2) testVariables.testObject1.DeepCopyInto(&testVariables.testObject2)
...@@ -167,11 +167,11 @@ func TestDeepCopy_DeepCopyInto_GitlabCredentials(t *testing.T) { ...@@ -167,11 +167,11 @@ func TestDeepCopy_DeepCopyInto_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyObject_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyObject_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newRuntimeObject := testVariables.testObject1.DeepCopyObject() newRuntimeObject := testVariables.testObject1.DeepCopyObject()
newObject := newRuntimeObject.(*GitlabCredentials) newObject := newRuntimeObject.(*GitLabCredentials)
got := newObject.APIVersion got := newObject.APIVersion
want := testVariables.expectedApiversion want := testVariables.expectedApiversion
...@@ -181,8 +181,8 @@ func TestDeepCopy_DeepCopyObject_GitlabCredentials(t *testing.T) { ...@@ -181,8 +181,8 @@ func TestDeepCopy_DeepCopyObject_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyList_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newObjectList := testVariables.objectList1.DeepCopy() newObjectList := testVariables.objectList1.DeepCopy()
got := newObjectList.Items[0].APIVersion got := newObjectList.Items[0].APIVersion
...@@ -193,7 +193,7 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) { ...@@ -193,7 +193,7 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) {
} }
// a typed pointer set to nil // a typed pointer set to nil
var nilTestPtr *GitlabCredentialsList = nil var nilTestPtr *GitLabCredentialsList = nil
var val = nilTestPtr.DeepCopy() var val = nilTestPtr.DeepCopy()
if val != nil { if val != nil {
t.Errorf("got %s want %s", "not nil", "nil") t.Errorf("got %s want %s", "not nil", "nil")
...@@ -201,8 +201,8 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) { ...@@ -201,8 +201,8 @@ func TestDeepCopy_DeepCopyList_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyIntoList_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyIntoList_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
testVariables.objectList1.DeepCopyInto(&testVariables.objectList2) testVariables.objectList1.DeepCopyInto(&testVariables.objectList2)
...@@ -215,11 +215,11 @@ func TestDeepCopy_DeepCopyIntoList_GitlabCredentials(t *testing.T) { ...@@ -215,11 +215,11 @@ func TestDeepCopy_DeepCopyIntoList_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyListObject_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newRuntimeObject := testVariables.objectList1.DeepCopyObject() newRuntimeObject := testVariables.objectList1.DeepCopyObject()
newObject := newRuntimeObject.(*GitlabCredentialsList) newObject := newRuntimeObject.(*GitLabCredentialsList)
got := newObject.Items[0].APIVersion got := newObject.Items[0].APIVersion
want := testVariables.expectedApiversion want := testVariables.expectedApiversion
...@@ -227,7 +227,7 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) { ...@@ -227,7 +227,7 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) {
t.Errorf("got %s want %s", got, want) t.Errorf("got %s want %s", got, want)
} }
var nilTestPtr *GitlabCredentialsList = nil var nilTestPtr *GitLabCredentialsList = nil
var val = nilTestPtr.DeepCopyObject() var val = nilTestPtr.DeepCopyObject()
if val != nil { if val != nil {
t.Errorf("got %s want %s", "not nil", "nil") t.Errorf("got %s want %s", "not nil", "nil")
...@@ -236,8 +236,8 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) { ...@@ -236,8 +236,8 @@ func TestDeepCopy_DeepCopyListObject_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopySpec_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newObjectList := testVariables.testObjectSpec1.DeepCopy() newObjectList := testVariables.testObjectSpec1.DeepCopy()
...@@ -245,7 +245,7 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) { ...@@ -245,7 +245,7 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) {
Expect(newObjectList).To(Equal(testVariables.testObjectSpec1)) Expect(newObjectList).To(Equal(testVariables.testObjectSpec1))
}) })
var nilTestPtr *GitlabCredentialsSpec = nil var nilTestPtr *GitLabCredentialsSpec = nil
var val = nilTestPtr.DeepCopy() var val = nilTestPtr.DeepCopy()
if val != nil { if val != nil {
t.Errorf("got %s want %s", "not nil", "nil") t.Errorf("got %s want %s", "not nil", "nil")
...@@ -253,8 +253,8 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) { ...@@ -253,8 +253,8 @@ func TestDeepCopy_DeepCopySpec_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopySpecInto_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopySpecInto_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
testVariables.testObjectSpec1.DeepCopyInto(&testVariables.testObjectSpec2) testVariables.testObjectSpec1.DeepCopyInto(&testVariables.testObjectSpec2)
...@@ -263,8 +263,8 @@ func TestDeepCopy_DeepCopySpecInto_GitlabCredentials(t *testing.T) { ...@@ -263,8 +263,8 @@ func TestDeepCopy_DeepCopySpecInto_GitlabCredentials(t *testing.T) {
}) })
} }
func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyStatus_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
newObjectStatus := testVariables.testObjectStatus1.DeepCopy() newObjectStatus := testVariables.testObjectStatus1.DeepCopy()
...@@ -273,7 +273,7 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) { ...@@ -273,7 +273,7 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) {
}) })
// a typed pointer set to nil // a typed pointer set to nil
var nilTestPtr *GitlabCredentialsStatus = nil var nilTestPtr *GitLabCredentialsStatus = nil
var val = nilTestPtr.DeepCopy() var val = nilTestPtr.DeepCopy()
if val != nil { if val != nil {
t.Errorf("got %s want %s", "not nil", "nil") t.Errorf("got %s want %s", "not nil", "nil")
...@@ -282,8 +282,8 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) { ...@@ -282,8 +282,8 @@ func TestDeepCopy_DeepCopyStatus_GitlabCredentials(t *testing.T) {
t.Log("Success") t.Log("Success")
} }
func TestDeepCopy_DeepCopyStatusInto_GitlabCredentials(t *testing.T) { func TestDeepCopy_DeepCopyStatusInto_GitLabCredentials(t *testing.T) {
testVariables := initVarsGitlabCredentials() testVariables := initVarsGitLabCredentials()
testVariables.testObjectStatus1.DeepCopyInto(&testVariables.testObjectStatus2) testVariables.testObjectStatus1.DeepCopyInto(&testVariables.testObjectStatus2)
......
...@@ -26,17 +26,17 @@ type GroupSpec struct { ...@@ -26,17 +26,17 @@ type GroupSpec struct {
// +kubebuilder:validation:required // +kubebuilder:validation:required
FullPath string `json:"path"` FullPath string `json:"path"`
// Name is the name of the Group and will be used as part of the URL in Gitlab // Name is the name of the Group and will be used as part of the URL in GitLab
// +kubebuilder:validation:Required // +kubebuilder:validation:Required
Name string `json:"name"` Name string `json:"name"`
// Description is the Gitlab Description for the group // Description is the GitLab Description for the group
// +kubebuilder:validation:optional // +kubebuilder:validation:optional
Description string `json:"description"` Description string `json:"description"`
// GitlabCredentialsName is the name of the object in this namespace that contains authentication // GitLabCredentialsName is the name of the object in this namespace that contains authentication
// information for logging into the // information for logging into the
GitlabCredentialsName string `json:"gitlabCredentialsName"` GitLabCredentialsName string `json:"gitlabCredentialsName"`
// KustomizeProductionPath is the relative path for the kustomization manifest for production use // KustomizeProductionPath is the relative path for the kustomization manifest for production use
// +kubebuilder:validation:required // +kubebuilder:validation:required
......
...@@ -69,12 +69,12 @@ func initVarsGroup() testVarsGroup { ...@@ -69,12 +69,12 @@ func initVarsGroup() testVarsGroup {
testVars.testObjectSpec1 = GroupSpec{ testVars.testObjectSpec1 = GroupSpec{
Name: "testGroup1", Name: "testGroup1",
GitlabCredentialsName: "nameOfTheCredentials", GitLabCredentialsName: "nameOfTheCredentials",
Description: "testDescription1", Description: "testDescription1",
} }
testVars.testObjectSpec2 = GroupSpec{ testVars.testObjectSpec2 = GroupSpec{
Name: "testGroup2", Name: "testGroup2",
GitlabCredentialsName: "nameOfCredentials2", GitLabCredentialsName: "nameOfCredentials2",
ProjectSpecs: nil, ProjectSpecs: nil,
Description: "testDescription2", Description: "testDescription2",
} }
......
...@@ -34,9 +34,9 @@ type ProjectSpec struct { ...@@ -34,9 +34,9 @@ type ProjectSpec struct {
// +kubebuilder:validation:required // +kubebuilder:validation:required
FullPath string `json:"path"` FullPath string `json:"path"`
// GitlabCredentialsName is the name of the object in this namespace that contains authentication // GitLabCredentialsName is the name of the object in this namespace that contains authentication
// information for logging into the // information for logging into the
GitlabCredentialsName string `json:"gitlabCredentialsName"` GitLabCredentialsName string `json:"gitlabCredentialsName"`
// ImpactLevel is the RMF Impact Level for this Project // ImpactLevel is the RMF Impact Level for this Project
// +kubebuilder:validation:Enum=2;4;5;6 // +kubebuilder:validation:Enum=2;4;5;6
...@@ -61,6 +61,10 @@ type ProjectSpec struct { ...@@ -61,6 +61,10 @@ type ProjectSpec struct {
// ManifestImage is the name of the DockerImage for the Project application // ManifestImage is the name of the DockerImage for the Project application
// +kubebuilder:validation:required // +kubebuilder:validation:required
ManifestImage string `json:"manifestImage"` 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 // ProjectStatus defines the observed state of Project
......
...@@ -214,7 +214,7 @@ func (in *DNSRepoMergeRequestStatus) DeepCopy() *DNSRepoMergeRequestStatus { ...@@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitlabCredentials) DeepCopyInto(out *GitlabCredentials) { func (in *GitLabCredentials) DeepCopyInto(out *GitLabCredentials) {
*out = *in *out = *in
out.TypeMeta = in.TypeMeta out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
...@@ -222,18 +222,18 @@ func (in *GitlabCredentials) DeepCopyInto(out *GitlabCredentials) { ...@@ -222,18 +222,18 @@ func (in *GitlabCredentials) DeepCopyInto(out *GitlabCredentials) {
in.Status.DeepCopyInto(&out.Status) in.Status.DeepCopyInto(&out.Status)
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabCredentials. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabCredentials.
func (in *GitlabCredentials) DeepCopy() *GitlabCredentials { func (in *GitLabCredentials) DeepCopy() *GitLabCredentials {
if in == nil { if in == nil {
return nil return nil
} }
out := new(GitlabCredentials) out := new(GitLabCredentials)
in.DeepCopyInto(out) in.DeepCopyInto(out)
return out return out
} }
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *GitlabCredentials) DeepCopyObject() runtime.Object { func (in *GitLabCredentials) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil { if c := in.DeepCopy(); c != nil {
return c return c
} }
...@@ -241,31 +241,31 @@ func (in *GitlabCredentials) DeepCopyObject() runtime.Object { ...@@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitlabCredentialsList) DeepCopyInto(out *GitlabCredentialsList) { func (in *GitLabCredentialsList) DeepCopyInto(out *GitLabCredentialsList) {
*out = *in *out = *in
out.TypeMeta = in.TypeMeta out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta) in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil { if in.Items != nil {
in, out := &in.Items, &out.Items in, out := &in.Items, &out.Items
*out = make([]GitlabCredentials, len(*in)) *out = make([]GitLabCredentials, len(*in))
for i := range *in { for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i]) (*in)[i].DeepCopyInto(&(*out)[i])
} }
} }
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabCredentialsList. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabCredentialsList.
func (in *GitlabCredentialsList) DeepCopy() *GitlabCredentialsList { func (in *GitLabCredentialsList) DeepCopy() *GitLabCredentialsList {
if in == nil { if in == nil {
return nil return nil
} }
out := new(GitlabCredentialsList) out := new(GitLabCredentialsList)
in.DeepCopyInto(out) in.DeepCopyInto(out)
return out return out
} }
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *GitlabCredentialsList) DeepCopyObject() runtime.Object { func (in *GitLabCredentialsList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil { if c := in.DeepCopy(); c != nil {
return c return c
} }
...@@ -273,33 +273,33 @@ func (in *GitlabCredentialsList) DeepCopyObject() runtime.Object { ...@@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitlabCredentialsSpec) DeepCopyInto(out *GitlabCredentialsSpec) { func (in *GitLabCredentialsSpec) DeepCopyInto(out *GitLabCredentialsSpec) {
*out = *in *out = *in
out.AccessToken = in.AccessToken out.AccessToken = in.AccessToken
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabCredentialsSpec. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabCredentialsSpec.
func (in *GitlabCredentialsSpec) DeepCopy() *GitlabCredentialsSpec { func (in *GitLabCredentialsSpec) DeepCopy() *GitLabCredentialsSpec {
if in == nil { if in == nil {
return nil return nil
} }
out := new(GitlabCredentialsSpec) out := new(GitLabCredentialsSpec)
in.DeepCopyInto(out) in.DeepCopyInto(out)
return out return out
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitlabCredentialsStatus) DeepCopyInto(out *GitlabCredentialsStatus) { func (in *GitLabCredentialsStatus) DeepCopyInto(out *GitLabCredentialsStatus) {
*out = *in *out = *in
in.LastUsedDate.DeepCopyInto(&out.LastUsedDate) in.LastUsedDate.DeepCopyInto(&out.LastUsedDate)
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitlabCredentialsStatus. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabCredentialsStatus.
func (in *GitlabCredentialsStatus) DeepCopy() *GitlabCredentialsStatus { func (in *GitLabCredentialsStatus) DeepCopy() *GitLabCredentialsStatus {
if in == nil { if in == nil {
return nil return nil
} }
out := new(GitlabCredentialsStatus) out := new(GitLabCredentialsStatus)
in.DeepCopyInto(out) in.DeepCopyInto(out)
return out return out
} }
......
This diff is collapsed.
...@@ -37,8 +37,8 @@ spec: ...@@ -37,8 +37,8 @@ spec:
description: DNSRepoCredentialSpec defines the desired state of DNSRepoCredential description: DNSRepoCredentialSpec defines the desired state of DNSRepoCredential
properties: properties:
gitlabProjectId: gitlabProjectId:
description: GitlabProjectID is the project ID of the DNS project description: GitLabProjectID is the project ID of the DNS project
in Gitlab in GitLab
type: integer type: integer
repoUrl: repoUrl:
description: 'RepoURL is the url for the DNS git repository. For example: description: 'RepoURL is the url for the DNS git repository. For example:
......
...@@ -10,8 +10,8 @@ metadata: ...@@ -10,8 +10,8 @@ metadata:
spec: spec:
group: gitlab.valkyrie.dso.mil group: gitlab.valkyrie.dso.mil
names: names:
kind: GitlabCredentials kind: GitLabCredentials
listKind: GitlabCredentialsList listKind: GitLabCredentialsList
plural: gitlabcredentials plural: gitlabcredentials
singular: gitlabcredentials singular: gitlabcredentials
scope: Namespaced scope: Namespaced
...@@ -19,7 +19,7 @@ spec: ...@@ -19,7 +19,7 @@ spec:
- name: v1alpha1 - name: v1alpha1
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: GitlabCredentials is the Schema for the gitlabcredentials API description: GitLabCredentials is the Schema for the gitlabcredentials API
properties: properties:
apiVersion: apiVersion:
description: 'APIVersion defines the versioned schema of this representation description: 'APIVersion defines the versioned schema of this representation
...@@ -34,13 +34,13 @@ spec: ...@@ -34,13 +34,13 @@ spec:
metadata: metadata:
type: object type: object
spec: spec:
description: GitlabCredentialsSpec defines the desired state of GitlabCredentials, description: GitLabCredentialsSpec defines the desired state of GitLabCredentials,
this stores a Gitlab username and Access Token for communicating with this stores a GitLab username and Access Token for communicating with
the Gitlab API. the GitLab API.
properties: properties:
accessToken: accessToken:
description: AccessToken is the SecretRef to the secret containing description: AccessToken is the SecretRef to the secret containing
the Gitlab Access Token for the user. the GitLab Access Token for the user.
properties: properties:
name: name:
description: Name is unique within a namespace to reference a description: Name is unique within a namespace to reference a
...@@ -53,20 +53,20 @@ spec: ...@@ -53,20 +53,20 @@ spec:
type: object type: object
accessTokenKey: accessTokenKey:
description: AccessTokenKey is the key of the secret data that contains description: AccessTokenKey is the key of the secret data that contains
the Gitlab Access Token for the user. the GitLab Access Token for the user.
type: string type: string
url: url:
description: URL is the url for the GitLab API that will be contacted. description: URL is the url for the GitLab API that will be contacted.
type: string type: string
username: username:
description: Username is the Gitlab username for the account that description: Username is the GitLab username for the account that
will be communicating with the Gitlab API will be communicating with the GitLab API
type: string type: string
required: required:
- accessTokenKey - accessTokenKey
type: object type: object
status: status:
description: GitlabCredentialsStatus defines the observed state of GitlabCredentials description: GitLabCredentialsStatus defines the observed state of GitLabCredentials
properties: properties:
lastUsedDate: lastUsedDate:
description: LastUsedTime is the time that this credential was last description: LastUsedTime is the time that this credential was last
......
...@@ -37,10 +37,10 @@ spec: ...@@ -37,10 +37,10 @@ spec:
description: GroupSpec defines the desired state of Group description: GroupSpec defines the desired state of Group
properties: properties:
description: description:
description: Description is the Gitlab Description for the group description: Description is the GitLab Description for the group
type: string type: string
gitlabCredentialsName: gitlabCredentialsName:
description: GitlabCredentialsName is the name of the object in this description: GitLabCredentialsName is the name of the object in this
namespace that contains authentication information for logging into namespace that contains authentication information for logging into
the the
type: string type: string
...@@ -58,7 +58,7 @@ spec: ...@@ -58,7 +58,7 @@ spec:
type: string type: string
name: name:
description: Name is the name of the Group and will be used as part description: Name is the name of the Group and will be used as part
of the URL in Gitlab of the URL in GitLab
type: string type: string
path: path:
description: FullPath is the gitlab path for this Project description: FullPath is the gitlab path for this Project
...@@ -70,8 +70,12 @@ spec: ...@@ -70,8 +70,12 @@ spec:
items: items:
description: ProjectSpec defines the desired state of Project description: ProjectSpec defines the desired state of Project
properties: properties:
ciConfigurationPath:
description: CiConfigurationPath is the GitLab path to the CI
configuration file in the CI/CD Settings of the project
type: string
gitlabCredentialsName: gitlabCredentialsName:
description: GitlabCredentialsName is the name of the object description: GitLabCredentialsName is the name of the object
in this namespace that contains authentication information in this namespace that contains authentication information
for logging into the for logging into the
type: string type: string
...@@ -118,6 +122,7 @@ spec: ...@@ -118,6 +122,7 @@ spec:
will be created for this Project will be created for this Project
type: string type: string
required: required:
- ciConfigurationPath
- gitlabCredentialsName - gitlabCredentialsName
- groupId - groupId
- impactLevel - impactLevel
......
...@@ -36,8 +36,12 @@ spec: ...@@ -36,8 +36,12 @@ spec:
spec: spec:
description: ProjectSpec defines the desired state of Project description: ProjectSpec defines the desired state of Project
properties: properties:
ciConfigurationPath:
description: CiConfigurationPath is the GitLab path to the CI configuration
file in the CI/CD Settings of the project
type: string
gitlabCredentialsName: gitlabCredentialsName:
description: GitlabCredentialsName is the name of the object in this description: GitLabCredentialsName is the name of the object in this
namespace that contains authentication information for logging into namespace that contains authentication information for logging into
the the
type: string type: string
...@@ -84,6 +88,7 @@ spec: ...@@ -84,6 +88,7 @@ spec:
be created for this Project be created for this Project
type: string type: string
required: required:
- ciConfigurationPath
- gitlabCredentialsName - gitlabCredentialsName
- groupId - groupId
- impactLevel - impactLevel
......
...@@ -7,7 +7,7 @@ data: ...@@ -7,7 +7,7 @@ data:
accesstoken: cGFzc3dvcmQ= accesstoken: cGFzc3dvcmQ=
--- ---
apiVersion: gitlab.valkyrie.dso.mil/v1alpha1 apiVersion: gitlab.valkyrie.dso.mil/v1alpha1
kind: GitlabCredentials kind: GitLabCredentials
metadata: metadata:
name: gitlab-credentials name: gitlab-credentials
namespace: default namespace: default
......
...@@ -105,10 +105,10 @@ func (r *DNSRepoMergeRequestReconciler) Reconcile(ctx context.Context, req ctrl. ...@@ -105,10 +105,10 @@ func (r *DNSRepoMergeRequestReconciler) Reconcile(ctx context.Context, req ctrl.
} }
repoURL := credential.Spec.RepoURL repoURL := credential.Spec.RepoURL
projectID := credential.Spec.GitlabProjectID projectID := credential.Spec.GitLabProjectID
//create Gitlab client for API calls //create GitLab client for API calls
gitlabAPIURL := getGitlabAPIURL(repoURL) gitlabAPIURL := getGitLabAPIURL(repoURL)
var gitlabClient gitlab.Client var gitlabClient gitlab.Client
if r.gitlabTestClient != nil { if r.gitlabTestClient != nil {
gitlabClient = r.gitlabTestClient gitlabClient = r.gitlabTestClient
...@@ -222,7 +222,7 @@ func cleanUpOldResources(dnsMergeRequest gitlabv1alpha1.DNSRepoMergeRequest, log ...@@ -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 input: https://code.il2.dso.mil/platform-one/products/valkyrie/dso-dns.git
//example output: https://code.il2.dso.mil/api/v4 //example output: https://code.il2.dso.mil/api/v4
func getGitlabAPIURL(repoURL string) string { func getGitLabAPIURL(repoURL string) string {
subs := strings.Split(repoURL, "/") subs := strings.Split(repoURL, "/")
return subs[0] + "/" + subs[1] + "/" + subs[2] + "/api/v4" return subs[0] + "/" + subs[1] + "/" + subs[2] + "/api/v4"
} }
......
...@@ -128,7 +128,7 @@ var _ = Describe("Reconcile", func() { ...@@ -128,7 +128,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta: metav1.ObjectMeta{}, ObjectMeta: metav1.ObjectMeta{},
Spec: gitlabv1alpha1.DNSRepoCredentialSpec{ Spec: gitlabv1alpha1.DNSRepoCredentialSpec{
RepoURL: "https://test", RepoURL: "https://test",
GitlabProjectID: 4148, GitLabProjectID: 4148,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secretName"}, LocalObjectReference: v1.LocalObjectReference{Name: "secretName"},
Key: "username", Key: "username",
...@@ -198,7 +198,7 @@ var _ = Describe("Reconcile", func() { ...@@ -198,7 +198,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta: metav1.ObjectMeta{}, ObjectMeta: metav1.ObjectMeta{},
Spec: gitlabv1alpha1.DNSRepoCredentialSpec{ Spec: gitlabv1alpha1.DNSRepoCredentialSpec{
RepoURL: "https://test", RepoURL: "https://test",
GitlabProjectID: 4148, GitLabProjectID: 4148,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secretName"}, LocalObjectReference: v1.LocalObjectReference{Name: "secretName"},
Key: "username", Key: "username",
...@@ -246,7 +246,7 @@ var _ = Describe("Reconcile", func() { ...@@ -246,7 +246,7 @@ var _ = Describe("Reconcile", func() {
Name: repoCred.Spec.UsernameSecRef.Name, Name: repoCred.Spec.UsernameSecRef.Name,
}] = &secret }] = &secret
sut.gitlabTestClient = &MockGitlabClient{ sut.gitlabTestClient = &MockGitLabClient{
getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) { getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) {
return &gitlab.MergeRequest{ return &gitlab.MergeRequest{
ProjectID: projectID, ProjectID: projectID,
...@@ -307,7 +307,7 @@ var _ = Describe("Reconcile", func() { ...@@ -307,7 +307,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta: metav1.ObjectMeta{}, ObjectMeta: metav1.ObjectMeta{},
Spec: gitlabv1alpha1.DNSRepoCredentialSpec{ Spec: gitlabv1alpha1.DNSRepoCredentialSpec{
RepoURL: "https://test", RepoURL: "https://test",
GitlabProjectID: 4148, GitLabProjectID: 4148,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secretName"}, LocalObjectReference: v1.LocalObjectReference{Name: "secretName"},
Key: "username", Key: "username",
...@@ -359,7 +359,7 @@ var _ = Describe("Reconcile", func() { ...@@ -359,7 +359,7 @@ var _ = Describe("Reconcile", func() {
Name: repoCred.Spec.UsernameSecRef.Name, Name: repoCred.Spec.UsernameSecRef.Name,
}] = &secret }] = &secret
sut.gitlabTestClient = &MockGitlabClient{ sut.gitlabTestClient = &MockGitLabClient{
getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) { getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) {
return &gitlab.MergeRequest{ return &gitlab.MergeRequest{
ProjectID: projectID, ProjectID: projectID,
...@@ -416,7 +416,7 @@ var _ = Describe("Reconcile", func() { ...@@ -416,7 +416,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta: metav1.ObjectMeta{}, ObjectMeta: metav1.ObjectMeta{},
Spec: gitlabv1alpha1.DNSRepoCredentialSpec{ Spec: gitlabv1alpha1.DNSRepoCredentialSpec{
RepoURL: "https://test", RepoURL: "https://test",
GitlabProjectID: 4148, GitLabProjectID: 4148,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secretName"}, LocalObjectReference: v1.LocalObjectReference{Name: "secretName"},
Key: "username", Key: "username",
...@@ -468,7 +468,7 @@ var _ = Describe("Reconcile", func() { ...@@ -468,7 +468,7 @@ var _ = Describe("Reconcile", func() {
Name: repoCred.Spec.UsernameSecRef.Name, Name: repoCred.Spec.UsernameSecRef.Name,
}] = &secret }] = &secret
sut.gitlabTestClient = &MockGitlabClient{ sut.gitlabTestClient = &MockGitLabClient{
getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) { getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) {
return &gitlab.MergeRequest{ return &gitlab.MergeRequest{
ProjectID: projectID, ProjectID: projectID,
...@@ -578,7 +578,7 @@ var _ = Describe("Reconcile", func() { ...@@ -578,7 +578,7 @@ var _ = Describe("Reconcile", func() {
ObjectMeta: metav1.ObjectMeta{}, ObjectMeta: metav1.ObjectMeta{},
Spec: gitlabv1alpha1.DNSRepoCredentialSpec{ Spec: gitlabv1alpha1.DNSRepoCredentialSpec{
RepoURL: "https://test", RepoURL: "https://test",
GitlabProjectID: 4148, GitLabProjectID: 4148,
UsernameSecRef: v1.SecretKeySelector{ UsernameSecRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{Name: "secretName"}, LocalObjectReference: v1.LocalObjectReference{Name: "secretName"},
Key: "username", Key: "username",
...@@ -630,7 +630,7 @@ var _ = Describe("Reconcile", func() { ...@@ -630,7 +630,7 @@ var _ = Describe("Reconcile", func() {
Name: repoCred.Spec.UsernameSecRef.Name, Name: repoCred.Spec.UsernameSecRef.Name,
}] = &secret }] = &secret
sut.gitlabTestClient = &MockGitlabClient{ sut.gitlabTestClient = &MockGitLabClient{
getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) { getMRByIDFunc: func(projectID int, mrID int) (*gitlab.MergeRequest, error) {
return &gitlab.MergeRequest{ return &gitlab.MergeRequest{
ProjectID: projectID, ProjectID: projectID,
......
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
gitlabv1alpha1 "valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1" gitlabv1alpha1 "valkyrie.dso.mil/valkyrie-api/apis/gitlab/v1alpha1"
) )
// CredentialsReconciler reconciles a GitlabCredentials object // CredentialsReconciler reconciles a GitLabCredentials object
type CredentialsReconciler struct { type CredentialsReconciler struct {
client.Client client.Client
Log logr.Logger Log logr.Logger
...@@ -52,6 +52,6 @@ func (r *CredentialsReconciler) Reconcile(ctx context.Context, req ctrl.Request) ...@@ -52,6 +52,6 @@ func (r *CredentialsReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// SetupWithManager sets up the controller with the Manager. // SetupWithManager sets up the controller with the Manager.
func (r *CredentialsReconciler) SetupWithManager(mgr ctrl.Manager) error { func (r *CredentialsReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr). return ctrl.NewControllerManagedBy(mgr).
For(&gitlabv1alpha1.GitlabCredentials{}). For(&gitlabv1alpha1.GitLabCredentials{}).
Complete(r) Complete(r)
} }
...@@ -41,7 +41,7 @@ var _ = Describe("gitlabcredentials_controller", func() { ...@@ -41,7 +41,7 @@ var _ = Describe("gitlabcredentials_controller", func() {
}) })
}) })
Describe("SetupWithManager", func() { Describe("SetupWithManager", func() {
gitlabv1alpha1.SchemeBuilder.Register(&gitlabv1alpha1.GitlabCredentials{}, &gitlabv1alpha1.GitlabCredentialsList{}) gitlabv1alpha1.SchemeBuilder.Register(&gitlabv1alpha1.GitLabCredentials{}, &gitlabv1alpha1.GitLabCredentialsList{})
sut := CredentialsReconciler{ sut := CredentialsReconciler{
Client: nil, Client: nil,
Log: nil, Log: nil,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment