UNCLASSIFIED

Commit d4b86680 authored by Jason van Brackel's avatar Jason van Brackel
Browse files

fix: jason's selfmade merge insanity and standardize Gitlab as name for variables

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