Skip to content

Commit

Permalink
use git providers
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu McCloskey <[email protected]>
  • Loading branch information
nabuskey committed Apr 22, 2024
1 parent a822dbd commit aa120a5
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 223 deletions.
24 changes: 18 additions & 6 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
GitProviderGitea = "gitea"
GitProviderGitHub = "github"
)

type GitRepositorySpec struct {
// +kubebuilder:validation:Optional
Customization PackageCustomization `json:"customization,omitempty"`
// GitURL is the base URL of Git server used for API calls.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^https?:\/\/.+$`
GitURL string `json:"gitURL"`
// InternalGitURL is the base URL of Git server accessible within the cluster only.
InternalGitURL string `json:"internalGitURL"`
// SecretRef is the reference to secret that contain Git server credentials
// +kubebuilder:validation:Optional
SecretRef SecretReference `json:"secretRef"`
Source GitRepositorySource `json:"source,omitempty"`
Provider Provider `json:"provider"`
}

type GitRepositorySource struct {
Expand All @@ -33,6 +33,18 @@ type GitRepositorySource struct {
Type string `json:"type"`
}

type Provider struct {
// +kubebuilder:validation:Enum:=gitea;github
// +kubebuilder:validation:Required
Name string `json:"name"`
// GitURL is the base URL of Git server used for API calls.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^https?:\/\/.+$`
GitURL string `json:"gitURL"`
// InternalGitURL is the base URL of Git server accessible within the cluster only.
InternalGitURL string `json:"internalGitURL"`
}

type SecretReference struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/go-git/go-git/v5 v5.10.0
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v61 v61.0.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.9.0
k8s.io/api v0.29.1
Expand Down Expand Up @@ -57,6 +58,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
github.com/google/uuid v1.4.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,16 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/create/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func create(cmd *cobra.Command, args []string) error {

fmt.Print("\n\n########################### Finished Creating IDP Successfully! ############################\n\n\n")
fmt.Printf("Can Access ArgoCD at https://argocd.cnoe.localtest.me:%s/\nUsername: admin\n", port)
fmt.Print(`Password can be retrieved by running: kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d`, "\n")
fmt.Print("Password can be retrieved by running: idpbuilder get secrets \n")

return nil
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/controllers/custompackage/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ func (r *Reconciler) reconcileGitRepo(ctx context.Context, resource *v1alpha1.Cu
Type: "local",
Path: absPath,
},
GitURL: resource.Spec.GitServerURL,
InternalGitURL: resource.Spec.InternalGitServeURL,
SecretRef: resource.Spec.GitServerAuthSecretRef,
Provider: v1alpha1.Provider{
Name: v1alpha1.GitProviderGitea,
GitURL: resource.Spec.GitServerURL,
InternalGitURL: resource.Spec.InternalGitServeURL,
},
SecretRef: resource.Spec.GitServerAuthSecretRef,
}

return nil
Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/custompackage/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ func TestReconcileCustomPkg(t *testing.T) {
Type: "local",
Path: p,
},
GitURL: "https://cnoe.io",
InternalGitURL: "http://internal.cnoe.io",
Provider: v1alpha1.Provider{
Name: v1alpha1.GitProviderGitea,
GitURL: "https://cnoe.io",
InternalGitURL: "http://internal.cnoe.io",
},
},
}
ok := reflect.DeepEqual(repo.Spec, expectedRepo.Spec)
Expand Down
Loading

0 comments on commit aa120a5

Please sign in to comment.