Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions cmd/clusters-service/api/capi_server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ service ClustersService {
get: "/v1/enterprise/version"
};
}
// GetProfiles returns a list of profiles
// from the cluster.
rpc GetProfiles(GetProfilesRequest)
returns (GetProfilesResponse){
option (google.api.http) = {
get: "/v1/profiles"
};
}
// GetProfileValues returns a list of values for
// a given version of a profile from the cluster.
rpc GetProfileValues(GetProfileValuesRequest)
returns (google.api.HttpBody){
option (google.api.http) = {
get: "/v1/profiles/{profile_name}/{profile_version}/values"
};
}
}

message ListTemplatesRequest { string provider = 1; }
Expand Down Expand Up @@ -128,8 +112,6 @@ message CreatePullRequestRequest {
string commit_message = 8;
// Credentials
Credential credentials = 9;
// The values for each profile that will be installed.
repeated ProfileValues values = 10;
}
message CreatePullRequestResponse {
// The url of the new pull request.
Expand Down Expand Up @@ -214,51 +196,3 @@ message GetEnterpriseVersionResponse {
// The version of WeGO Enterprise
string version = 1;
}

message Maintainer {
string name = 1;
string email = 2;
string url = 3;
}

message HelmRepository {
string name = 1;
string namespace = 2;
}

message Profile {
string name = 1;
string home = 2;
repeated string sources = 3;
string description = 4;
repeated string keywords = 5;
repeated Maintainer maintainers = 6;
string icon = 7;
map<string, string> annotations = 8;
string kube_version = 9;
HelmRepository helm_repository = 10;
repeated string available_versions = 11;
}

message GetProfilesRequest {
}

message GetProfilesResponse {
repeated Profile profiles = 1;
}

message GetProfileValuesRequest {
string profile_name = 1;
string profile_version = 2;
}
message GetProfileValuesResponse{
// The base64 encoded values file of the profile.
string values = 1;
}

message ProfileValues {
string name = 1;
string version = 2;
string values = 3;
string layer = 4;
}
181 changes: 2 additions & 179 deletions cmd/clusters-service/api/capi_server.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,66 +156,6 @@
]
}
},
"/v1/profiles": {
"get": {
"summary": "GetProfiles returns a list of profiles\nfrom the cluster.",
"operationId": "ClustersService_GetProfiles",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetProfilesResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"ClustersService"
]
}
},
"/v1/profiles/{profileName}/{profileVersion}/values": {
"get": {
"summary": "GetProfileValues returns a list of values for \na given version of a profile from the cluster.",
"operationId": "ClustersService_GetProfileValues",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiHttpBody"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "profileName",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "profileVersion",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"ClustersService"
]
}
},
"/v1/templates": {
"get": {
"operationId": "ClustersService_ListTemplates",
Expand Down Expand Up @@ -382,16 +322,12 @@
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"@type": {
"type": "string",
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
},
"value": {
"type": "string",
"format": "byte",
"description": "Must be a valid serialized protocol buffer of the above specified type."
}
},
"additionalProperties": {},
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
},
"rpcStatus": {
Expand Down Expand Up @@ -453,13 +389,6 @@
"credentials": {
"$ref": "#/definitions/v1Credential",
"title": "Credentials"
},
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/v1ProfileValues"
},
"description": "The values for each profile that will be installed."
}
}
},
Expand Down Expand Up @@ -550,17 +479,6 @@
}
}
},
"v1GetProfilesResponse": {
"type": "object",
"properties": {
"profiles": {
"type": "array",
"items": {
"$ref": "#/definitions/v1Profile"
}
}
}
},
"v1GetTemplateResponse": {
"type": "object",
"properties": {
Expand All @@ -569,17 +487,6 @@
}
}
},
"v1HelmRepository": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string"
}
}
},
"v1ListCredentialsResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -627,20 +534,6 @@
}
}
},
"v1Maintainer": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"url": {
"type": "string"
}
}
},
"v1Parameter": {
"type": "object",
"properties": {
Expand All @@ -661,76 +554,6 @@
}
}
},
"v1Profile": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"home": {
"type": "string"
},
"sources": {
"type": "array",
"items": {
"type": "string"
}
},
"description": {
"type": "string"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"maintainers": {
"type": "array",
"items": {
"$ref": "#/definitions/v1Maintainer"
}
},
"icon": {
"type": "string"
},
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"kubeVersion": {
"type": "string"
},
"helmRepository": {
"$ref": "#/definitions/v1HelmRepository"
},
"availableVersions": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v1ProfileValues": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"values": {
"type": "string"
},
"layer": {
"type": "string"
}
}
},
"v1RenderTemplateResponse": {
"type": "object",
"properties": {
Expand Down
22 changes: 16 additions & 6 deletions cmd/clusters-service/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package app
import (
"github.com/go-logr/logr"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/weaveworks/weave-gitops-enterprise/cmd/clusters-service/pkg/git"
"github.com/weaveworks/weave-gitops-enterprise/cmd/clusters-service/pkg/templates"
"github.com/weaveworks/weave-gitops/pkg/server"
"gorm.io/gorm"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops-enterprise/cmd/clusters-service/pkg/git"
"github.com/weaveworks/weave-gitops-enterprise/cmd/clusters-service/pkg/templates"
)

// Options specifies the options that can be set
Expand All @@ -21,6 +22,7 @@ type Options struct {
TemplateLibrary templates.Library
GitProvider git.Provider
ApplicationsConfig *server.ApplicationsConfig
ProfilesConfig server.ProfilesConfig
GrpcRuntimeOptions []runtime.ServeMuxOption
ProfileHelmRepository string
HelmRepositoryCacheDirectory string
Expand Down Expand Up @@ -84,11 +86,11 @@ func WithApplicationsConfig(appConfig *server.ApplicationsConfig) Option {
}
}

// WithGrpcRuntimeOptions is used to set an array of ServeMuxOption that
// will be used to configure the GRPC-Gateway.
func WithGrpcRuntimeOptions(grpcRuntimeOptions []runtime.ServeMuxOption) Option {
// WithProfilesConfig is used to set the configuration needed to work
// with Weave GitOps Core profiles
func WithProfilesConfig(profilesConfig server.ProfilesConfig) Option {
return func(o *Options) {
o.GrpcRuntimeOptions = grpcRuntimeOptions
o.ProfilesConfig = profilesConfig
}
}

Expand All @@ -101,6 +103,14 @@ func WithProfileHelmRepository(name string) Option {
}
}

// WithGrpcRuntimeOptions is used to set an array of ServeMuxOption that
// will be used to configure the GRPC-Gateway.
func WithGrpcRuntimeOptions(grpcRuntimeOptions []runtime.ServeMuxOption) Option {
return func(o *Options) {
o.GrpcRuntimeOptions = grpcRuntimeOptions
}
}

// WithCAPIClustersNamespace is used to set the namespace that will
// be monitored for new CAPI cluster CRs.
func WithCAPIClustersNamespace(namespace string) Option {
Expand Down
Loading