UNCLASSIFIED

Commits (6)
...@@ -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,49 +21,49 @@ import ( ...@@ -21,49 +21,49 @@ 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"`
} }
//+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
...@@ -50,7 +50,7 @@ type GroupSpec struct { ...@@ -50,7 +50,7 @@ type GroupSpec struct {
// +kubebuilder:validation:required // +kubebuilder:validation:required
ManifestRepositoryURL string `json:"manifestRepositoryUrl"` ManifestRepositoryURL string `json:"manifestRepositoryUrl"`
// ProjectSpecs are for the GitLab projects managed by this Group. It's expected that Projects // ProjectSpecs are for the Gitlab projects managed by this Group. It's expected that Projects
// will be managed at the group level rather than be adjusted themselves. // will be managed at the group level rather than be adjusted themselves.
// +kubebuilder:validation:Required // +kubebuilder:validation:Required
ProjectSpecs []ProjectSpec `json:"projects,omitempty"` ProjectSpecs []ProjectSpec `json:"projects,omitempty"`
......
...@@ -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",
} }
......
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
// ProjectSpec defines the desired state of Project // ProjectSpec defines the desired state of Project
type ProjectSpec struct { type ProjectSpec struct {
// GroupID is the id of the GitLab Group id that owns this project // GroupID is the id of the Gitlab Group id that owns this project
// +kubebuilder:validation:Required // +kubebuilder:validation:Required
GroupID int `json:"groupId"` GroupID int `json:"groupId"`
...@@ -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
...@@ -62,14 +62,14 @@ type ProjectSpec struct { ...@@ -62,14 +62,14 @@ type ProjectSpec struct {
// +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 // CiConfigurationPath is the Gitlab path to the CI configuration file in the CI/CD Settings of the project
// +kubebuilder:validation:required // +kubebuilder:validation:required
CiConfigurationPath string `json:"ciConfigurationPath"` CiConfigurationPath string `json:"ciConfigurationPath"`
} }
// ProjectStatus defines the observed state of Project // ProjectStatus defines the observed state of Project
type ProjectStatus struct { type ProjectStatus struct {
// URL is the url for the project in GitLab // URL is the url for the project in Gitlab
URL string `json:"url"` URL string `json:"url"`
// State is the current state of the object // State is the current state of the object
......
...@@ -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,24 +53,24 @@ spec: ...@@ -53,24 +53,24 @@ 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
used to access a GitLab API used to access a Gitlab API
format: date-time format: date-time
type: string type: string
required: required:
......
...@@ -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,29 +58,29 @@ spec: ...@@ -58,29 +58,29 @@ 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
type: string type: string
projects: projects:
description: ProjectSpecs are for the GitLab projects managed by this description: ProjectSpecs are for the Gitlab projects managed by this
Group. It's expected that Projects will be managed at the group Group. It's expected that Projects will be managed at the group
level rather than be adjusted themselves. level rather than be adjusted themselves.
items: items:
description: ProjectSpec defines the desired state of Project description: ProjectSpec defines the desired state of Project
properties: properties:
ciConfigurationPath: ciConfigurationPath:
description: CiConfigurationPath is the GitLab path to the CI description: CiConfigurationPath is the Gitlab path to the CI
configuration file in the CI/CD Settings of the project configuration file in the CI/CD Settings of the project
type: string 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
groupId: groupId:
description: GroupID is the id of the GitLab Group id that owns description: GroupID is the id of the Gitlab Group id that owns
this project this project
type: integer type: integer
impactLevel: impactLevel:
......
...@@ -37,16 +37,16 @@ spec: ...@@ -37,16 +37,16 @@ spec:
description: ProjectSpec defines the desired state of Project description: ProjectSpec defines the desired state of Project
properties: properties:
ciConfigurationPath: ciConfigurationPath:
description: CiConfigurationPath is the GitLab path to the CI configuration description: CiConfigurationPath is the Gitlab path to the CI configuration
file in the CI/CD Settings of the project file in the CI/CD Settings of the project
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
groupId: groupId:
description: GroupID is the id of the GitLab Group id that owns this description: GroupID is the id of the Gitlab Group id that owns this
project project
type: integer type: integer
impactLevel: impactLevel:
...@@ -105,7 +105,7 @@ spec: ...@@ -105,7 +105,7 @@ spec:
description: State is the current state of the object description: State is the current state of the object
type: string type: string
url: url:
description: URL is the url for the project in GitLab description: URL is the url for the project in Gitlab
type: string type: string
required: required:
- state - state
......
...@@ -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
......
...@@ -58,7 +58,7 @@ var _ = Describe("fortifycredential_controller", func() { ...@@ -58,7 +58,7 @@ var _ = Describe("fortifycredential_controller", func() {
startWasCalled: false, startWasCalled: false,
} }
It("Should setup the GitLab Controller to be managed by the manager", func() { It("Should setup the Gitlab Controller to be managed by the manager", func() {
Expect(sut.SetupWithManager(&mgr)).To(BeNil()) Expect(sut.SetupWithManager(&mgr)).To(BeNil())
}) })
}) })
......
...@@ -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)
} }