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

fix: the instill-auth-type header was missing when request the pipeline #174

Merged
merged 1 commit into from
Jan 30, 2024
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
1 change: 1 addition & 0 deletions pkg/service/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
)

func InjectOwnerToContext(ctx context.Context, owner *mgmtPB.User) context.Context {
ctx = metadata.AppendToOutgoingContext(ctx, "instill-auth-type", "user")
ctx = metadata.AppendToOutgoingContext(ctx, "instill-user-uid", owner.GetUid())
return ctx
}
Expand Down
58 changes: 0 additions & 58 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/redis/go-redis/v9"
"go.einride.tech/aip/filtering"
"golang.org/x/crypto/bcrypt"
"google.golang.org/grpc/metadata"

"github.com/instill-ai/mgmt-backend/internal/resource"
"github.com/instill-ai/mgmt-backend/pkg/acl"
Expand Down Expand Up @@ -65,8 +64,6 @@ type Service interface {
CheckUserPassword(ctx context.Context, uid uuid.UUID, password string) error
UpdateUserPassword(ctx context.Context, uid uuid.UUID, newPassword string) error

ListUserPipelines(ctx context.Context, id string) ([]*pipelinePB.Pipeline, error)
ListOrganizationPipelines(ctx context.Context, id string) ([]*pipelinePB.Pipeline, error)
ListPipelineTriggerRecords(ctx context.Context, owner *mgmtPB.User, pageSize int64, pageToken string, filter filtering.Filter) ([]*mgmtPB.PipelineTriggerRecord, int64, string, error)
ListPipelineTriggerTableRecords(ctx context.Context, owner *mgmtPB.User, pageSize int64, pageToken string, filter filtering.Filter) ([]*mgmtPB.PipelineTriggerTableRecord, int64, string, error)
ListPipelineTriggerChartRecords(ctx context.Context, owner *mgmtPB.User, aggregationWindow int64, filter filtering.Filter) ([]*mgmtPB.PipelineTriggerChartRecord, error)
Expand Down Expand Up @@ -987,58 +984,3 @@ func (s *service) DeleteOrganizationMembership(ctx context.Context, ctxUserUID u
}
return nil
}
func (s *service) ListUserPipelines(ctx context.Context, id string) ([]*pipelinePB.Pipeline, error) {

pageToken := ""
pageSize := int32(100)

pipelines := []*pipelinePB.Pipeline{}
for {
resp, err := s.pipelinePublicServiceClient.ListUserPipelines(
metadata.AppendToOutgoingContext(ctx, "instill-user-uid", resource.GetRequestSingleHeader(ctx, constant.HeaderUserUIDKey)),
&pipelinePB.ListUserPipelinesRequest{
PageSize: &pageSize,
PageToken: &pageToken,
Parent: fmt.Sprintf("users/%s", id),
},
)
if err != nil {
return nil, err
}
pipelines = append(pipelines, resp.Pipelines...)
pageToken = resp.NextPageToken
if pageToken == "" {
break
}
}

return pipelines, nil
}

func (s *service) ListOrganizationPipelines(ctx context.Context, id string) ([]*pipelinePB.Pipeline, error) {

pageToken := ""
pageSize := int32(100)

pipelines := []*pipelinePB.Pipeline{}
for {
resp, err := s.pipelinePublicServiceClient.ListOrganizationPipelines(
metadata.AppendToOutgoingContext(ctx, "instill-user-uid", resource.GetRequestSingleHeader(ctx, constant.HeaderUserUIDKey)),
&pipelinePB.ListOrganizationPipelinesRequest{
PageSize: &pageSize,
PageToken: &pageToken,
Parent: fmt.Sprintf("organizations/%s", id),
},
)
if err != nil {
return nil, err
}
pipelines = append(pipelines, resp.Pipelines...)
pageToken = resp.NextPageToken
if pageToken == "" {
break
}
}

return pipelines, nil
}
Loading