Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu Mccloskey <[email protected]>
  • Loading branch information
nabuskey committed Nov 24, 2023
1 parent 09608f0 commit 9d00824
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 30 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ type GitRepositoryStatus struct {
// ExternalGitRepositoryUrl is the url for the in-cluster repository accessible from local machine.
// +kubebuilder:validation:Optional
ExternalGitRepositoryUrl string `json:"externalGitRepositoryUrl"`
// GitRepositoryUrl is the url for the in-cluster repository accessible within the cluster.
// InternalGitRepositoryUrl is the url for the in-cluster repository accessible within the cluster.
// +kubebuilder:validation:Optional
GitRepositoryUrl string `json:"gitRepositoryUrl"`
InternalGitRepositoryUrl string `json:"internalGitRepositoryUrl"`
// Path is the path within the repository that contains the files.
// +kubebuilder:validation:Optional
Path string `json:"path"`
Expand Down
20 changes: 13 additions & 7 deletions api/v1alpha1/localbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,10 @@ type LocalbuildSpec struct {
type LocalbuildStatus struct {
// ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

GitServerAvailable bool `json:"gitServerAvailable,omitempty"`
ArgoAvailable bool `json:"argoAvailable,omitempty"`
NginxAvailable bool `json:"nginxAvailable,omitempty"`
ArgoAppsCreated bool `json:"argoAppsCreated,omitempty"`
Gitea GiteaStatus `json:"giteaStatus,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
ArgoCD ArgoCDStatus `json:"ArgoCD,omitempty"`
Nginx NginxStatus `json:"nginx,omitempty"`
Gitea GiteaStatus `json:"gitea,omitempty"`
}

type GiteaStatus struct {
Expand All @@ -56,6 +53,15 @@ type GiteaStatus struct {
AdminUserSecretNamespace string `json:"adminUserSecretNamespace,omitempty"`
}

type ArgoCDStatus struct {
Available bool `json:"available,omitempty"`
AppsCreated bool `json:"appsCreated,omitempty"`
}

type NginxStatus struct {
Available bool `json:"available,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=localbuilds,scope=Cluster
Expand Down
32 changes: 32 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.

3 changes: 1 addition & 2 deletions pkg/controllers/gitrepository/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
giteaAdminPasswordKey = "password"
requeueTime = time.Second * 30
gitCommitAuthorName = "git-reconciler"
gitCommitAuthorEmail = "invalid@cnoe.io"
gitCommitAuthorEmail = "idpbuilder-agent@cnoe.io"
)

type GiteaClientFunc func(url string, options ...gitea.ClientOption) (GiteaClient, error)
Expand Down Expand Up @@ -235,7 +235,6 @@ func reconcileRepo(giteaClient GiteaClient, repo *v1alpha1.GitRepository) (*gite
if CErr != nil {
return &gitea.Repository{}, fmt.Errorf("failed to create git repository: %w", CErr)
}
repo.Status.ExternalGitRepositoryUrl = createResp.CloneURL
return createResp, nil
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/gitrepository/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func setUpLocalRepo() (string, string, error) {
fileObject.SetType(plumbing.BlobObject)
w, _ := fileObject.Writer()

file, err := os.ReadFile("resources/file1")
file, err := os.ReadFile("test/resources/file1")
if err != nil {
return "", "", fmt.Errorf("reading file from resources dir: %w", err)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func setupDir() (string, error) {
return "", fmt.Errorf("creating temporary directory: %w", err)
}

file, err := os.ReadFile("resources/file1")
file, err := os.ReadFile("test/resources/file1")
if err != nil {
return "", fmt.Errorf("reading file from resources dir: %w", err)
}
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestGitRepositoryReconcile(t *testing.T) {
if err != nil {
t.Fatalf("failed setting up local git repo: %v", err)
}
resourcePath, err := filepath.Abs("./resources")
resourcePath, err := filepath.Abs("./test/resources")
if err != nil {
t.Fatalf("failed to get absolute path: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/localbuild/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ func (r *LocalbuildReconciler) ReconcileArgo(ctx context.Context, req ctrl.Reque
return result, err
}

resource.Status.ArgoAvailable = true
resource.Status.ArgoCD.Available = true
return ctrl.Result{}, nil
}
4 changes: 2 additions & 2 deletions pkg/controllers/localbuild/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (r *LocalbuildReconciler) ReconcileEmbeddedGitServer(ctx context.Context, r
log := log.FromContext(ctx)

// Bail if argo is not yet available
if !resource.Status.ArgoAvailable {
if !resource.Status.ArgoCD.Available {
log.Info("argo not yet available, not installing embedded git server")
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func (r *LocalbuildReconciler) ReconcileArgoAppsWithGitServer(ctx context.Contex
}
}

resource.Status.ArgoAppsCreated = true
resource.Status.ArgoCD.AppsCreated = true
r.shouldShutdown = true

return ctrl.Result{}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/localbuild/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ func (r *LocalbuildReconciler) ReconcileNginx(ctx context.Context, req ctrl.Requ
return result, err
}

resource.Status.NginxAvailable = true
resource.Status.Nginx.Available = true
return ctrl.Result{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ spec:
description: ExternalGitRepositoryUrl is the url for the in-cluster
repository accessible from local machine.
type: string
gitRepositoryUrl:
description: GitRepositoryUrl is the url for the in-cluster repository
accessible within the cluster.
internalGitRepositoryUrl:
description: InternalGitRepositoryUrl is the url for the in-cluster
repository accessible within the cluster.
type: string
path:
description: Path is the path within the repository that contains
Expand Down
22 changes: 13 additions & 9 deletions pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ spec:
type: object
status:
properties:
argoAppsCreated:
type: boolean
argoAvailable:
type: boolean
gitServerAvailable:
type: boolean
giteaStatus:
ArgoCD:
properties:
appsCreated:
type: boolean
available:
type: boolean
type: object
gitea:
properties:
adminUserSecretNameecret:
type: string
Expand All @@ -83,8 +84,11 @@ spec:
internalURL:
type: string
type: object
nginxAvailable:
type: boolean
nginx:
properties:
available:
type: boolean
type: object
observedGeneration:
description: ObservedGeneration is the 'Generation' of the Service
that was last processed by the controller.
Expand Down

0 comments on commit 9d00824

Please sign in to comment.