Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove environment concept from web apis and piped model #3599

Merged
merged 2 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 2 additions & 17 deletions pkg/app/server/grpcapi/web_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type webApiPipedStore interface {
List(ctx context.Context, opts datastore.ListOptions) ([]*model.Piped, error)
AddKey(ctx context.Context, id, keyHash, creator string, createdAt time.Time) error
DeleteOldKeys(ctx context.Context, id string) error
UpdateInfo(ctx context.Context, id, name, desc string, envIds []string) error
UpdateInfo(ctx context.Context, id, name, desc string) error
EnablePiped(ctx context.Context, id string) error
DisablePiped(ctx context.Context, id string) error
UpdateDesiredVersion(ctx context.Context, id, version string) error
Expand Down Expand Up @@ -191,7 +191,6 @@ func (a *WebAPI) RegisterPiped(ctx context.Context, req *webservice.RegisterPipe
Name: req.Name,
Desc: req.Desc,
ProjectId: claims.Role.ProjectId,
EnvIds: req.EnvIds,
}
if err := piped.AddKey(keyHash, claims.Subject, time.Now()); err != nil {
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("Failed to create key: %v", err))
Expand All @@ -209,7 +208,7 @@ func (a *WebAPI) RegisterPiped(ctx context.Context, req *webservice.RegisterPipe

func (a *WebAPI) UpdatePiped(ctx context.Context, req *webservice.UpdatePipedRequest) (*webservice.UpdatePipedResponse, error) {
updater := func(ctx context.Context, pipedID string) error {
return a.pipedStore.UpdateInfo(ctx, req.PipedId, req.Name, req.Desc, req.EnvIds)
return a.pipedStore.UpdateInfo(ctx, req.PipedId, req.Name, req.Desc)
}
if err := a.updatePiped(ctx, req.PipedId, updater); err != nil {
return nil, err
Expand Down Expand Up @@ -604,13 +603,6 @@ func (a *WebAPI) ListApplications(ctx context.Context, req *webservice.ListAppli
Value: o.SyncStatuses[0],
})
}
if len(o.EnvIds) > 0 {
filters = append(filters, datastore.ListFilter{
Field: "EnvId",
Operator: datastore.OperatorEqual,
Value: o.EnvIds[0],
})
}
if o.Name != "" {
filters = append(filters, datastore.ListFilter{
Field: "Name",
Expand Down Expand Up @@ -811,13 +803,6 @@ func (a *WebAPI) ListDeployments(ctx context.Context, req *webservice.ListDeploy
Value: o.ApplicationIds[0],
})
}
if len(o.EnvIds) > 0 {
filters = append(filters, datastore.ListFilter{
Field: "EnvId",
Operator: datastore.OperatorEqual,
Value: o.EnvIds[0],
})
}
if o.ApplicationName != "" {
filters = append(filters, datastore.ListFilter{
Field: "ApplicationName",
Expand Down
1,882 changes: 911 additions & 971 deletions pkg/app/server/service/webservice/service.pb.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions pkg/app/server/service/webservice/service.pb.validate.go

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

18 changes: 12 additions & 6 deletions pkg/app/server/service/webservice/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ service WebService {
}

message RegisterPipedRequest {
reserved 3;

string name = 1;
string desc = 2;
repeated string env_ids = 3;
}

message RegisterPipedResponse {
Expand All @@ -118,10 +119,11 @@ message RegisterPipedResponse {
}

message UpdatePipedRequest {
reserved 4;

string piped_id = 1 [(validate.rules).string.min_len = 1];
string name = 2 [(validate.rules).string.min_len = 1];
string desc = 3;
repeated string env_ids = 4;
}

message UpdatePipedResponse {
Expand Down Expand Up @@ -186,8 +188,9 @@ message UpdatePipedDesiredVersionResponse {
}

message AddApplicationRequest {
reserved 2;

string name = 1 [(validate.rules).string.min_len = 1];
string env_id = 2 [deprecated = true];
string piped_id = 3 [(validate.rules).string.min_len = 1];
model.ApplicationGitPath git_path = 4 [(validate.rules).message.required = true];
model.ApplicationKind kind = 5 [(validate.rules).enum.defined_only = true];
Expand All @@ -201,9 +204,10 @@ message AddApplicationResponse {
}

message UpdateApplicationRequest {
reserved 3;

string application_id = 1 [(validate.rules).string.min_len = 1];
string name = 2 [(validate.rules).string.min_len = 1];
string env_id = 3 [deprecated = true];
string piped_id = 4 [(validate.rules).string.min_len = 1];
model.ApplicationKind kind = 6 [(validate.rules).enum.defined_only = true];
string cloud_provider = 7 [(validate.rules).string.min_len = 1];
Expand Down Expand Up @@ -236,10 +240,11 @@ message DeleteApplicationResponse {

message ListApplicationsRequest {
message Options {
reserved 4;

google.protobuf.BoolValue enabled = 1;
repeated model.ApplicationKind kinds = 2;
repeated model.ApplicationSyncStatus sync_statuses = 3;
repeated string env_ids = 4;
string name = 5;
map<string, string> labels = 6;
}
Expand Down Expand Up @@ -287,10 +292,11 @@ message ListUnregisteredApplicationsResponse {

message ListDeploymentsRequest {
message Options {
reserved 4;

repeated model.DeploymentStatus statuses = 1;
repeated model.ApplicationKind kinds = 2;
repeated string application_ids = 3;
repeated string env_ids = 4;
string application_name = 5;
map<string, string> labels = 6;
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/datastore/datastoretest/datastore.mock.go

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

5 changes: 2 additions & 3 deletions pkg/datastore/pipedstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type PipedStore interface {
Add(ctx context.Context, piped *model.Piped) error
Get(ctx context.Context, id string) (*model.Piped, error)
List(ctx context.Context, opts ListOptions) ([]*model.Piped, error)
UpdateInfo(ctx context.Context, id, name, desc string, envIds []string) error
UpdateInfo(ctx context.Context, id, name, desc string) error
EnablePiped(ctx context.Context, id string) error
DisablePiped(ctx context.Context, id string) error
UpdateDesiredVersion(ctx context.Context, id, version string) error
Expand Down Expand Up @@ -190,11 +190,10 @@ func (s *pipedStore) update(ctx context.Context, id string, updater func(piped *
})
}

func (s *pipedStore) UpdateInfo(ctx context.Context, id, name, desc string, envIds []string) error {
func (s *pipedStore) UpdateInfo(ctx context.Context, id, name, desc string) error {
return s.update(ctx, id, func(piped *model.Piped) error {
piped.Name = name
piped.Desc = desc
piped.EnvIds = envIds
return nil
})
}
Expand Down
Loading