Skip to content

Commit

Permalink
Fetch source and automation data for a given application (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpellizzari committed Jul 26, 2021
1 parent 3517c79 commit 5cec865
Show file tree
Hide file tree
Showing 14 changed files with 504 additions and 116 deletions.
18 changes: 15 additions & 3 deletions api/applications/applications.proto
Expand Up @@ -38,10 +38,22 @@ service Applications {
}
}

// This object represents a single condition for a Kubernetes object.
// It roughly matches the Kubernetes type defined here: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition
message Condition {
string type = 1;
string status = 2;
string reason = 3;
string message = 4;
int32 timestamp = 5;
}

message Application {
string name = 1; // The name of the application
string path = 2; // The file path where the k8s yaml files for this application are stored.
string url = 3; // The git repository URL for this application
string name = 1; // The name of the application
string path = 2; // The file path where the k8s yaml files for this application are stored.
string url = 3; // The git repository URL for this application
repeated Condition source_conditions = 4; // A list of conditions for the Source related to this Application
repeated Condition deployment_conditions = 5; // A list of conditions for the Kustomization or HelmRelease for this application
}

message ListApplicationsRequest {
Expand Down
34 changes: 34 additions & 0 deletions api/applications/applications.swagger.json
Expand Up @@ -128,9 +128,43 @@
},
"url": {
"type": "string"
},
"sourceConditions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1Condition"
}
},
"deploymentConditions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1Condition"
}
}
}
},
"v1Condition": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"status": {
"type": "string"
},
"reason": {
"type": "string"
},
"message": {
"type": "string"
},
"timestamp": {
"type": "integer",
"format": "int32"
}
},
"title": "This object represents a single condition for a Kubernetes object.\nIt roughly matches the Kubernetes type defined here: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition"
},
"v1GetApplicationResponse": {
"type": "object",
"properties": {
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/application_types.go
Expand Up @@ -43,9 +43,19 @@ type ApplicationSpec struct {
// +kubebuilder:validation:Enum=helm;kustomize
type DeploymentType string

const (
DeploymentTypeHelm DeploymentType = "helm"
DeploymentTypeKustomize DeploymentType = "kustomize"
)

// +kubebuilder:validation:Enum=helm;git
type SourceType string

const (
SourceTypeGit SourceType = "git"
SourceTypeHelm SourceType = "helm"
)

// ApplicationStatus defines the observed state of Application
type ApplicationStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down
8 changes: 6 additions & 2 deletions cmd/wego-server/main.go
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/cobra"
pb "github.com/weaveworks/weave-gitops/pkg/api/applications"
"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/runner"
"github.com/weaveworks/weave-gitops/pkg/server"
)

Expand Down Expand Up @@ -61,7 +60,12 @@ func StartServer() error {
func RunInProcessGateway(ctx context.Context, addr string, opts ...runtime.ServeMuxOption) error {
mux := runtime.NewServeMux(opts...)

if err := pb.RegisterApplicationsHandlerServer(ctx, mux, server.NewApplicationsServer(kube.New(&runner.CLIRunner{}))); err != nil {
kubeClient, err := kube.NewKubeHTTPClient()
if err != nil {
return fmt.Errorf("could not create kube http client: %w", err)
}

if err := pb.RegisterApplicationsHandlerServer(ctx, mux, server.NewApplicationsServer(kubeClient)); err != nil {
return fmt.Errorf("could not register application: %w", err)
}
s := &http.Server{
Expand Down
1 change: 1 addition & 0 deletions cmd/wego/app/add/cmd.go
Expand Up @@ -56,6 +56,7 @@ func init() {
Cmd.Flags().StringVar(&params.Path, "path", "./", "Path of files within git repository")
Cmd.Flags().StringVar(&params.Branch, "branch", "main", "Branch to watch within git repository")
Cmd.Flags().StringVar(&params.DeploymentType, "deployment-type", "kustomize", "deployment type [kustomize, helm]")
Cmd.Flags().StringVar(&params.SourceType, "source-type", "git", "source type [git, helm]")
Cmd.Flags().StringVar(&params.Chart, "chart", "", "Specify chart for helm source")
Cmd.Flags().StringVar(&params.PrivateKey, "private-key", "", "Private key to access git repository over ssh")
Cmd.Flags().StringVar(&params.AppConfigUrl, "app-config-url", "", "URL of external repository (if any) which will hold automation manifests; NONE to store only in the cluster")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -37,7 +37,7 @@ require (
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
sigs.k8s.io/controller-runtime v0.9.1
sigs.k8s.io/controller-tools v0.4.1 // indirect
sigs.k8s.io/controller-tools v0.4.1
sigs.k8s.io/yaml v1.2.0

)
Expand Down

0 comments on commit 5cec865

Please sign in to comment.