diff --git a/go.mod b/go.mod index 319211371..61bc8e400 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( golang.org/x/term v0.16.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac google.golang.org/protobuf v1.32.0 + mvdan.cc/sh/v3 v3.7.0 ) require ( diff --git a/go.sum b/go.sum index 29ad75fb3..b1a2d269c 100644 --- a/go.sum +++ b/go.sum @@ -57,6 +57,8 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= +github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= @@ -312,3 +314,5 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg= +mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8= diff --git a/internal/api/runme/runner/v2alpha1/runner.proto b/internal/api/runme/runner/v2alpha1/runner.proto index ffa386732..11cb9c19a 100644 --- a/internal/api/runme/runner/v2alpha1/runner.proto +++ b/internal/api/runme/runner/v2alpha1/runner.proto @@ -154,11 +154,16 @@ message ResolveEnvRequest { // that will be injected to the executed program. repeated string env = 3; + // session_id indicates in which Session the program should execute. + // Executing in a Session might provide additional context like + // environment variables. + string session_id = 4; + // session_strategy is a strategy for selecting the session. - SessionStrategy session_strategy = 4; + SessionStrategy session_strategy = 5; // project used to load environment variables from .env files. - optional Project project = 5; + optional Project project = 6; message CommandList { // commands are commands to be executed by the program. @@ -168,34 +173,36 @@ message ResolveEnvRequest { } } -message ResolveEnvResponse { - // resolved_env is a list of resolved environment variables. - repeated ResolvedEnv resolved_env = 1; - - // unresolved_env is a list of environment variables - // that couldn't be resolved. - repeated UnresolvedEnv unresolved_env = 2; +message ResolveEnvResult { + oneof result { + ResolvedEnv resolved_env = 1; + UnresolvedEnv unresolved_env = 2; + } message ResolvedEnv { - string key = 1; + string name = 1; string original_value = 2; string resolved_value = 3; - Source source = 4; + ResolvedEnvSource source = 4; } message UnresolvedEnv { - string key = 1; + string name = 1; string original_value = 2; } - enum Source { - SOURCE_UNSPECIFIED = 0; - SOURCE_ENV = 1; - SOURCE_SESSION = 2; - SOURCE_PROJECT = 3; + enum ResolvedEnvSource { + RESOLVED_ENV_SOURCE_UNSPECIFIED = 0; + RESOLVED_ENV_SOURCE_ENV = 1; + RESOLVED_ENV_SOURCE_SESSION = 2; + RESOLVED_ENV_SOURCE_PROJECT = 3; } } +message ResolveEnvResponse { + repeated ResolveEnvResult items = 1; +} + service RunnerService { rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse) {} rpc GetSession(GetSessionRequest) returns (GetSessionResponse) {} diff --git a/internal/command/command.go b/internal/command/command.go index 2408f21c8..5a5793370 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -16,8 +16,6 @@ type NativeCommandOptions struct { Logger *zap.Logger } -func (o *NativeCommandOptions) GetEnv() []string { return o.Session.GetEnv() } - func NewNative(cfg *Config, options *NativeCommandOptions) (*NativeCommand, error) { if options == nil { options = &NativeCommandOptions{} @@ -39,8 +37,6 @@ type VirtualCommandOptions struct { Logger *zap.Logger } -func (o *VirtualCommandOptions) GetEnv() []string { return o.Session.GetEnv() } - func NewVirtual(cfg *Config, options *VirtualCommandOptions) (*VirtualCommand, error) { if options == nil { options = &VirtualCommandOptions{} diff --git a/internal/command/env_resolver.go b/internal/command/env_resolver.go new file mode 100644 index 000000000..7ba57ab2b --- /dev/null +++ b/internal/command/env_resolver.go @@ -0,0 +1,159 @@ +package command + +import ( + "io" + "strings" + + "mvdan.cc/sh/v3/syntax" + + runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" +) + +type ( + ResolveEnvResult = runnerv2alpha1.ResolveEnvResult +) + +type EnvResolverSource func() []string + +func EnvResolverSourceFunc(env []string) EnvResolverSource { + return func() []string { + return env + } +} + +// EnvResolver uses a list of EnvResolverSource to resolve environment variables +// found in a shell program. The result contains all found environment variables. +// If the env is in any source, it is considered resolved. Otherwise, it is makred +// as unresolved. +type EnvResolver struct { + sources []EnvResolverSource + envCache map[string]string +} + +func NewEnvResolver(sources ...EnvResolverSource) *EnvResolver { + return &EnvResolver{sources: sources, envCache: nil} +} + +func (r *EnvResolver) Resolve(reader io.Reader) ([]*ResolveEnvResult, error) { + decls, err := r.parse(reader) + if err != nil { + return nil, err + } + + var result []*ResolveEnvResult + + for _, decl := range decls { + if len(decl.Args) != 1 { + continue + } + + arg := decl.Args[0] + + name := arg.Name.Value + originalValue := r.findOriginalValue(decl) + + value, ok := r.findEnvValue(name) + if ok { + result = append(result, &ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv_{ + ResolvedEnv: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv{ + Name: name, + ResolvedValue: value, + OriginalValue: originalValue, + }, + }, + }) + } else { + result = append(result, &ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv_{ + UnresolvedEnv: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv{ + Name: name, + OriginalValue: originalValue, + }, + }, + }) + } + } + + return result, nil +} + +func (r *EnvResolver) findOriginalValue(decl *syntax.DeclClause) string { + if len(decl.Args) != 1 { + return "" + } + + arg := decl.Args[0] + + if arg.Value == nil { + return "" + } + + parts := arg.Value.Parts + + if len(parts) != 1 { + return "" + } + + switch part := parts[0].(type) { + case *syntax.Lit: + return part.Value + case *syntax.DblQuoted: + if len(part.Parts) == 1 { + return part.Parts[0].(*syntax.Lit).Value + } + case *syntax.SglQuoted: + return part.Value + case *syntax.ParamExp: + if part.Exp.Op == syntax.DefaultUnsetOrNull { + return part.Exp.Word.Lit() + } + } + + return "" +} + +func (r *EnvResolver) findEnvValue(name string) (string, bool) { + if r.envCache == nil { + r.envCache = make(map[string]string) + r.collectEnvFromSources() + } + val, ok := r.envCache[name] + return val, ok +} + +func (r *EnvResolver) collectEnvFromSources() { + for _, source := range r.sources { + env := source() + for _, e := range env { + parts := strings.SplitN(e, "=", 2) + if len(parts) == 2 { + r.envCache[parts[0]] = parts[1] + } + } + } +} + +func (r *EnvResolver) parse(reader io.Reader) ([]*syntax.DeclClause, error) { + f, err := syntax.NewParser().Parse(reader, "") + if err != nil { + return nil, err + } + + var result []*syntax.DeclClause + + syntax.Walk(f, func(node syntax.Node) bool { + switch x := node.(type) { + case *syntax.DeclClause: + if x.Variant.Value == "export" && len(x.Args) == 1 { + result = append(result, x) + return false + } + default: + // noop + } + return true + }) + + return result, nil +} diff --git a/internal/command/env_resolver_test.go b/internal/command/env_resolver_test.go new file mode 100644 index 000000000..8273ae90c --- /dev/null +++ b/internal/command/env_resolver_test.go @@ -0,0 +1,126 @@ +package command + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" +) + +func TestEnvResolver_Parsing(t *testing.T) { + createResultWithUnresolvedEnv := func(name string, originalValue string) *ResolveEnvResult { + return &ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv_{ + UnresolvedEnv: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv{ + Name: name, + OriginalValue: originalValue, + }, + }, + } + } + + testCases := []struct { + name string + data string + source []EnvResolverSource + result []*ResolveEnvResult + }{ + { + name: "no value", + data: `export TEST_NO_VALUE`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_NO_VALUE", ""), + }, + }, + { + name: "empty value", + data: `export TEST_EMPTY_VALUE=`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_EMPTY_VALUE", ""), + }, + }, + { + name: "string value", + data: `export TEST_STRING_VALUE=value`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_STRING_VALUE", "value"), + }, + }, + { + name: "string double quoted value empty", + data: `export TEST_STRING_DBL_QUOTED_VALUE_EMPTY=""`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_STRING_DBL_QUOTED_VALUE_EMPTY", ""), + }, + }, + { + name: "string double quoted value", + data: `export TEST_STRING_DBL_QUOTED_VALUE="value"`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_STRING_DBL_QUOTED_VALUE", "value"), + }, + }, + { + name: "string single quoted value empty", + data: `export TEST_STRING_SGL_QUOTED_VALUE_EMPTY=''`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_STRING_SGL_QUOTED_VALUE_EMPTY", ""), + }, + }, + { + name: "string single quoted value", + data: `export TEST_STRING_SGL_QUOTED_VALUE='value'`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_STRING_SGL_QUOTED_VALUE", "value"), + }, + }, + { + name: "value expression", + data: `export TEST_VALUE_EXPR=$(echo -n "value")`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_VALUE_EXPR", ""), + }, + }, + { + name: "default value", + data: `export TEST_DEFAULT_VALUE=${TEST_DEFAULT_VALUE:-value}`, + result: []*ResolveEnvResult{ + createResultWithUnresolvedEnv("TEST_DEFAULT_VALUE", "value"), + }, + }, + } + + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + r := NewEnvResolver(tc.source...) + result, err := r.Resolve(strings.NewReader(tc.data)) + assert.NoError(t, err) + assert.EqualValues(t, tc.result, result) + }) + } +} + +func TestEnvResolver(t *testing.T) { + createResultResolvedEnv := func(name, resolvedValue, originalValue string) *ResolveEnvResult { + return &ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv_{ + ResolvedEnv: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv{ + Name: name, + ResolvedValue: resolvedValue, + OriginalValue: originalValue, + }, + }, + } + } + + r := NewEnvResolver(EnvResolverSourceFunc([]string{"MY_ENV=resolved"})) + result, err := r.Resolve(strings.NewReader(`export MY_ENV=default`)) + require.NoError(t, err) + require.Len(t, result, 1) + require.EqualValues(t, createResultResolvedEnv("MY_ENV", "resolved", "default"), result[0]) +} diff --git a/internal/gen/proto/go/runme/runner/v2alpha1/runner.pb.go b/internal/gen/proto/go/runme/runner/v2alpha1/runner.pb.go index 2e83dbdc6..bab738030 100644 --- a/internal/gen/proto/go/runme/runner/v2alpha1/runner.pb.go +++ b/internal/gen/proto/go/runme/runner/v2alpha1/runner.pb.go @@ -122,55 +122,55 @@ func (SessionStrategy) EnumDescriptor() ([]byte, []int) { return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{1} } -type ResolveEnvResponse_Source int32 +type ResolveEnvResult_ResolvedEnvSource int32 const ( - ResolveEnvResponse_SOURCE_UNSPECIFIED ResolveEnvResponse_Source = 0 - ResolveEnvResponse_SOURCE_ENV ResolveEnvResponse_Source = 1 - ResolveEnvResponse_SOURCE_SESSION ResolveEnvResponse_Source = 2 - ResolveEnvResponse_SOURCE_PROJECT ResolveEnvResponse_Source = 3 + ResolveEnvResult_RESOLVED_ENV_SOURCE_UNSPECIFIED ResolveEnvResult_ResolvedEnvSource = 0 + ResolveEnvResult_RESOLVED_ENV_SOURCE_ENV ResolveEnvResult_ResolvedEnvSource = 1 + ResolveEnvResult_RESOLVED_ENV_SOURCE_SESSION ResolveEnvResult_ResolvedEnvSource = 2 + ResolveEnvResult_RESOLVED_ENV_SOURCE_PROJECT ResolveEnvResult_ResolvedEnvSource = 3 ) -// Enum value maps for ResolveEnvResponse_Source. +// Enum value maps for ResolveEnvResult_ResolvedEnvSource. var ( - ResolveEnvResponse_Source_name = map[int32]string{ - 0: "SOURCE_UNSPECIFIED", - 1: "SOURCE_ENV", - 2: "SOURCE_SESSION", - 3: "SOURCE_PROJECT", - } - ResolveEnvResponse_Source_value = map[string]int32{ - "SOURCE_UNSPECIFIED": 0, - "SOURCE_ENV": 1, - "SOURCE_SESSION": 2, - "SOURCE_PROJECT": 3, + ResolveEnvResult_ResolvedEnvSource_name = map[int32]string{ + 0: "RESOLVED_ENV_SOURCE_UNSPECIFIED", + 1: "RESOLVED_ENV_SOURCE_ENV", + 2: "RESOLVED_ENV_SOURCE_SESSION", + 3: "RESOLVED_ENV_SOURCE_PROJECT", + } + ResolveEnvResult_ResolvedEnvSource_value = map[string]int32{ + "RESOLVED_ENV_SOURCE_UNSPECIFIED": 0, + "RESOLVED_ENV_SOURCE_ENV": 1, + "RESOLVED_ENV_SOURCE_SESSION": 2, + "RESOLVED_ENV_SOURCE_PROJECT": 3, } ) -func (x ResolveEnvResponse_Source) Enum() *ResolveEnvResponse_Source { - p := new(ResolveEnvResponse_Source) +func (x ResolveEnvResult_ResolvedEnvSource) Enum() *ResolveEnvResult_ResolvedEnvSource { + p := new(ResolveEnvResult_ResolvedEnvSource) *p = x return p } -func (x ResolveEnvResponse_Source) String() string { +func (x ResolveEnvResult_ResolvedEnvSource) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ResolveEnvResponse_Source) Descriptor() protoreflect.EnumDescriptor { +func (ResolveEnvResult_ResolvedEnvSource) Descriptor() protoreflect.EnumDescriptor { return file_runme_runner_v2alpha1_runner_proto_enumTypes[2].Descriptor() } -func (ResolveEnvResponse_Source) Type() protoreflect.EnumType { +func (ResolveEnvResult_ResolvedEnvSource) Type() protoreflect.EnumType { return &file_runme_runner_v2alpha1_runner_proto_enumTypes[2] } -func (x ResolveEnvResponse_Source) Number() protoreflect.EnumNumber { +func (x ResolveEnvResult_ResolvedEnvSource) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use ResolveEnvResponse_Source.Descriptor instead. -func (ResolveEnvResponse_Source) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use ResolveEnvResult_ResolvedEnvSource.Descriptor instead. +func (ResolveEnvResult_ResolvedEnvSource) EnumDescriptor() ([]byte, []int) { return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{14, 0} } @@ -958,10 +958,14 @@ type ResolveEnvRequest struct { // env is a list of additional environment variables // that will be injected to the executed program. Env []string `protobuf:"bytes,3,rep,name=env,proto3" json:"env,omitempty"` + // session_id indicates in which Session the program should execute. + // Executing in a Session might provide additional context like + // environment variables. + SessionId string `protobuf:"bytes,4,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // session_strategy is a strategy for selecting the session. - SessionStrategy SessionStrategy `protobuf:"varint,4,opt,name=session_strategy,json=sessionStrategy,proto3,enum=runme.runner.v2alpha1.SessionStrategy" json:"session_strategy,omitempty"` + SessionStrategy SessionStrategy `protobuf:"varint,5,opt,name=session_strategy,json=sessionStrategy,proto3,enum=runme.runner.v2alpha1.SessionStrategy" json:"session_strategy,omitempty"` // project used to load environment variables from .env files. - Project *Project `protobuf:"bytes,5,opt,name=project,proto3,oneof" json:"project,omitempty"` + Project *Project `protobuf:"bytes,6,opt,name=project,proto3,oneof" json:"project,omitempty"` } func (x *ResolveEnvRequest) Reset() { @@ -1024,6 +1028,13 @@ func (x *ResolveEnvRequest) GetEnv() []string { return nil } +func (x *ResolveEnvRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + func (x *ResolveEnvRequest) GetSessionStrategy() SessionStrategy { if x != nil { return x.SessionStrategy @@ -1058,20 +1069,20 @@ func (*ResolveEnvRequest_Commands) isResolveEnvRequest_Source() {} func (*ResolveEnvRequest_Script) isResolveEnvRequest_Source() {} -type ResolveEnvResponse struct { +type ResolveEnvResult struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // resolved_env is a list of resolved environment variables. - ResolvedEnv []*ResolveEnvResponse_ResolvedEnv `protobuf:"bytes,1,rep,name=resolved_env,json=resolvedEnv,proto3" json:"resolved_env,omitempty"` - // unresolved_env is a list of environment variables - // that couldn't be resolved. - UnresolvedEnv []*ResolveEnvResponse_UnresolvedEnv `protobuf:"bytes,2,rep,name=unresolved_env,json=unresolvedEnv,proto3" json:"unresolved_env,omitempty"` + // Types that are assignable to Result: + // + // *ResolveEnvResult_ResolvedEnv_ + // *ResolveEnvResult_UnresolvedEnv_ + Result isResolveEnvResult_Result `protobuf_oneof:"result"` } -func (x *ResolveEnvResponse) Reset() { - *x = ResolveEnvResponse{} +func (x *ResolveEnvResult) Reset() { + *x = ResolveEnvResult{} if protoimpl.UnsafeEnabled { mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1079,13 +1090,13 @@ func (x *ResolveEnvResponse) Reset() { } } -func (x *ResolveEnvResponse) String() string { +func (x *ResolveEnvResult) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ResolveEnvResponse) ProtoMessage() {} +func (*ResolveEnvResult) ProtoMessage() {} -func (x *ResolveEnvResponse) ProtoReflect() protoreflect.Message { +func (x *ResolveEnvResult) ProtoReflect() protoreflect.Message { mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1097,25 +1108,95 @@ func (x *ResolveEnvResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ResolveEnvResponse.ProtoReflect.Descriptor instead. -func (*ResolveEnvResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ResolveEnvResult.ProtoReflect.Descriptor instead. +func (*ResolveEnvResult) Descriptor() ([]byte, []int) { return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{14} } -func (x *ResolveEnvResponse) GetResolvedEnv() []*ResolveEnvResponse_ResolvedEnv { - if x != nil { +func (m *ResolveEnvResult) GetResult() isResolveEnvResult_Result { + if m != nil { + return m.Result + } + return nil +} + +func (x *ResolveEnvResult) GetResolvedEnv() *ResolveEnvResult_ResolvedEnv { + if x, ok := x.GetResult().(*ResolveEnvResult_ResolvedEnv_); ok { return x.ResolvedEnv } return nil } -func (x *ResolveEnvResponse) GetUnresolvedEnv() []*ResolveEnvResponse_UnresolvedEnv { - if x != nil { +func (x *ResolveEnvResult) GetUnresolvedEnv() *ResolveEnvResult_UnresolvedEnv { + if x, ok := x.GetResult().(*ResolveEnvResult_UnresolvedEnv_); ok { return x.UnresolvedEnv } return nil } +type isResolveEnvResult_Result interface { + isResolveEnvResult_Result() +} + +type ResolveEnvResult_ResolvedEnv_ struct { + ResolvedEnv *ResolveEnvResult_ResolvedEnv `protobuf:"bytes,1,opt,name=resolved_env,json=resolvedEnv,proto3,oneof"` +} + +type ResolveEnvResult_UnresolvedEnv_ struct { + UnresolvedEnv *ResolveEnvResult_UnresolvedEnv `protobuf:"bytes,2,opt,name=unresolved_env,json=unresolvedEnv,proto3,oneof"` +} + +func (*ResolveEnvResult_ResolvedEnv_) isResolveEnvResult_Result() {} + +func (*ResolveEnvResult_UnresolvedEnv_) isResolveEnvResult_Result() {} + +type ResolveEnvResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*ResolveEnvResult `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *ResolveEnvResponse) Reset() { + *x = ResolveEnvResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResolveEnvResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResolveEnvResponse) ProtoMessage() {} + +func (x *ResolveEnvResponse) ProtoReflect() protoreflect.Message { + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResolveEnvResponse.ProtoReflect.Descriptor instead. +func (*ResolveEnvResponse) Descriptor() ([]byte, []int) { + return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{15} +} + +func (x *ResolveEnvResponse) GetItems() []*ResolveEnvResult { + if x != nil { + return x.Items + } + return nil +} + type ResolveEnvRequest_CommandList struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1130,7 +1211,7 @@ type ResolveEnvRequest_CommandList struct { func (x *ResolveEnvRequest_CommandList) Reset() { *x = ResolveEnvRequest_CommandList{} if protoimpl.UnsafeEnabled { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[17] + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1143,7 +1224,7 @@ func (x *ResolveEnvRequest_CommandList) String() string { func (*ResolveEnvRequest_CommandList) ProtoMessage() {} func (x *ResolveEnvRequest_CommandList) ProtoReflect() protoreflect.Message { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[17] + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1166,34 +1247,34 @@ func (x *ResolveEnvRequest_CommandList) GetItems() []string { return nil } -type ResolveEnvResponse_ResolvedEnv struct { +type ResolveEnvResult_ResolvedEnv struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - OriginalValue string `protobuf:"bytes,2,opt,name=original_value,json=originalValue,proto3" json:"original_value,omitempty"` - ResolvedValue string `protobuf:"bytes,3,opt,name=resolved_value,json=resolvedValue,proto3" json:"resolved_value,omitempty"` - Source ResolveEnvResponse_Source `protobuf:"varint,4,opt,name=source,proto3,enum=runme.runner.v2alpha1.ResolveEnvResponse_Source" json:"source,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + OriginalValue string `protobuf:"bytes,2,opt,name=original_value,json=originalValue,proto3" json:"original_value,omitempty"` + ResolvedValue string `protobuf:"bytes,3,opt,name=resolved_value,json=resolvedValue,proto3" json:"resolved_value,omitempty"` + Source ResolveEnvResult_ResolvedEnvSource `protobuf:"varint,4,opt,name=source,proto3,enum=runme.runner.v2alpha1.ResolveEnvResult_ResolvedEnvSource" json:"source,omitempty"` } -func (x *ResolveEnvResponse_ResolvedEnv) Reset() { - *x = ResolveEnvResponse_ResolvedEnv{} +func (x *ResolveEnvResult_ResolvedEnv) Reset() { + *x = ResolveEnvResult_ResolvedEnv{} if protoimpl.UnsafeEnabled { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[18] + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ResolveEnvResponse_ResolvedEnv) String() string { +func (x *ResolveEnvResult_ResolvedEnv) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ResolveEnvResponse_ResolvedEnv) ProtoMessage() {} +func (*ResolveEnvResult_ResolvedEnv) ProtoMessage() {} -func (x *ResolveEnvResponse_ResolvedEnv) ProtoReflect() protoreflect.Message { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[18] +func (x *ResolveEnvResult_ResolvedEnv) ProtoReflect() protoreflect.Message { + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1204,65 +1285,65 @@ func (x *ResolveEnvResponse_ResolvedEnv) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ResolveEnvResponse_ResolvedEnv.ProtoReflect.Descriptor instead. -func (*ResolveEnvResponse_ResolvedEnv) Descriptor() ([]byte, []int) { +// Deprecated: Use ResolveEnvResult_ResolvedEnv.ProtoReflect.Descriptor instead. +func (*ResolveEnvResult_ResolvedEnv) Descriptor() ([]byte, []int) { return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{14, 0} } -func (x *ResolveEnvResponse_ResolvedEnv) GetKey() string { +func (x *ResolveEnvResult_ResolvedEnv) GetName() string { if x != nil { - return x.Key + return x.Name } return "" } -func (x *ResolveEnvResponse_ResolvedEnv) GetOriginalValue() string { +func (x *ResolveEnvResult_ResolvedEnv) GetOriginalValue() string { if x != nil { return x.OriginalValue } return "" } -func (x *ResolveEnvResponse_ResolvedEnv) GetResolvedValue() string { +func (x *ResolveEnvResult_ResolvedEnv) GetResolvedValue() string { if x != nil { return x.ResolvedValue } return "" } -func (x *ResolveEnvResponse_ResolvedEnv) GetSource() ResolveEnvResponse_Source { +func (x *ResolveEnvResult_ResolvedEnv) GetSource() ResolveEnvResult_ResolvedEnvSource { if x != nil { return x.Source } - return ResolveEnvResponse_SOURCE_UNSPECIFIED + return ResolveEnvResult_RESOLVED_ENV_SOURCE_UNSPECIFIED } -type ResolveEnvResponse_UnresolvedEnv struct { +type ResolveEnvResult_UnresolvedEnv struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` OriginalValue string `protobuf:"bytes,2,opt,name=original_value,json=originalValue,proto3" json:"original_value,omitempty"` } -func (x *ResolveEnvResponse_UnresolvedEnv) Reset() { - *x = ResolveEnvResponse_UnresolvedEnv{} +func (x *ResolveEnvResult_UnresolvedEnv) Reset() { + *x = ResolveEnvResult_UnresolvedEnv{} if protoimpl.UnsafeEnabled { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[19] + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ResolveEnvResponse_UnresolvedEnv) String() string { +func (x *ResolveEnvResult_UnresolvedEnv) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ResolveEnvResponse_UnresolvedEnv) ProtoMessage() {} +func (*ResolveEnvResult_UnresolvedEnv) ProtoMessage() {} -func (x *ResolveEnvResponse_UnresolvedEnv) ProtoReflect() protoreflect.Message { - mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[19] +func (x *ResolveEnvResult_UnresolvedEnv) ProtoReflect() protoreflect.Message { + mi := &file_runme_runner_v2alpha1_runner_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1273,19 +1354,19 @@ func (x *ResolveEnvResponse_UnresolvedEnv) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ResolveEnvResponse_UnresolvedEnv.ProtoReflect.Descriptor instead. -func (*ResolveEnvResponse_UnresolvedEnv) Descriptor() ([]byte, []int) { +// Deprecated: Use ResolveEnvResult_UnresolvedEnv.ProtoReflect.Descriptor instead. +func (*ResolveEnvResult_UnresolvedEnv) Descriptor() ([]byte, []int) { return file_runme_runner_v2alpha1_runner_proto_rawDescGZIP(), []int{14, 1} } -func (x *ResolveEnvResponse_UnresolvedEnv) GetKey() string { +func (x *ResolveEnvResult_UnresolvedEnv) GetName() string { if x != nil { - return x.Key + return x.Name } return "" } -func (x *ResolveEnvResponse_UnresolvedEnv) GetOriginalValue() string { +func (x *ResolveEnvResult_UnresolvedEnv) GetOriginalValue() string { if x != nil { return x.OriginalValue } @@ -1405,7 +1486,7 @@ var file_runme_runner_v2alpha1_runner_proto_rawDesc = []byte{ 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x03, - 0x70, 0x69, 0x64, 0x22, 0xe0, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, + 0x70, 0x69, 0x64, 0x22, 0xff, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, @@ -1414,112 +1495,124 @@ var file_runme_runner_v2alpha1_runner_proto_rawDesc = []byte{ 0x74, 0x48, 0x00, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x18, 0x0a, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x51, 0x0a, 0x10, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, - 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0f, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x3d, 0x0a, 0x07, - 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x48, 0x01, 0x52, - 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x88, 0x01, 0x01, 0x1a, 0x23, 0x0a, 0x0b, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, - 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, - 0x42, 0x08, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0xac, 0x04, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, 0x6c, - 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, - 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x76, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, - 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, - 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x12, 0x5e, 0x0a, 0x0e, 0x75, 0x6e, 0x72, 0x65, 0x73, - 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x76, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x37, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, - 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, - 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x73, - 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x52, 0x0d, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x6f, - 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x1a, 0xb7, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x6f, - 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x6f, 0x72, 0x69, - 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, - 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x48, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, - 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x1a, 0x48, 0x0a, 0x0d, 0x55, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x45, - 0x6e, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6f, 0x72, - 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x58, 0x0a, 0x06, 0x53, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, - 0x0a, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x45, 0x4e, 0x56, 0x10, 0x01, 0x12, 0x12, 0x0a, - 0x0e, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, - 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x50, 0x52, 0x4f, 0x4a, - 0x45, 0x43, 0x54, 0x10, 0x03, 0x2a, 0x5e, 0x0a, 0x0b, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, - 0x53, 0x74, 0x6f, 0x70, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x5f, - 0x53, 0x54, 0x4f, 0x50, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, - 0x4f, 0x50, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x52, 0x55, 0x50, 0x54, 0x10, 0x01, 0x12, 0x15, - 0x0a, 0x11, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x5f, 0x4b, - 0x49, 0x4c, 0x4c, 0x10, 0x02, 0x2a, 0x55, 0x0a, 0x0f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x20, 0x0a, 0x1c, 0x53, 0x45, 0x53, 0x53, - 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x52, 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x55, 0x4e, 0x53, - 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x53, 0x45, - 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x52, 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x4d, - 0x4f, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x43, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x32, 0x80, 0x05, 0x0a, - 0x0d, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, - 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x2b, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, - 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x72, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x51, 0x0a, 0x10, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, + 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x3d, 0x0a, 0x07, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x0a, - 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x72, 0x75, 0x6e, - 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, - 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x69, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x2a, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, - 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, - 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6c, 0x0a, 0x0d, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x48, 0x01, 0x52, 0x07, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x88, 0x01, 0x01, 0x1a, 0x23, 0x0a, 0x0b, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x42, + 0x08, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x81, 0x05, 0x0a, 0x10, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x58, 0x0a, 0x0c, 0x72, 0x65, + 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x76, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x33, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, + 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x64, 0x45, 0x6e, 0x76, 0x48, 0x00, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x64, 0x45, 0x6e, 0x76, 0x12, 0x5e, 0x0a, 0x0e, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x76, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x72, + 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, + 0x45, 0x6e, 0x76, 0x48, 0x00, 0x52, 0x0d, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x64, 0x45, 0x6e, 0x76, 0x1a, 0xc2, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x64, 0x45, 0x6e, 0x76, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, + 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x51, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x39, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, + 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, + 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x53, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x4a, 0x0a, 0x0d, 0x55, 0x6e, 0x72, + 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x45, 0x6e, 0x76, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x97, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x64, 0x45, 0x6e, 0x76, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x1f, 0x52, + 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x45, 0x4e, 0x56, 0x5f, 0x53, 0x4f, 0x55, 0x52, + 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x45, 0x4e, 0x56, + 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x45, 0x4e, 0x56, 0x10, 0x01, 0x12, 0x1f, 0x0a, + 0x1b, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x45, 0x4e, 0x56, 0x5f, 0x53, 0x4f, + 0x55, 0x52, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x1f, + 0x0a, 0x1b, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x45, 0x4e, 0x56, 0x5f, 0x53, + 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x03, 0x42, + 0x08, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x53, 0x0a, 0x12, 0x52, 0x65, 0x73, + 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3d, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, + 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, + 0x76, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x2a, 0x5e, + 0x0a, 0x0b, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x1c, 0x0a, + 0x18, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x45, + 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x5f, 0x49, 0x4e, 0x54, 0x45, + 0x52, 0x52, 0x55, 0x50, 0x54, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x58, 0x45, 0x43, 0x55, + 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x5f, 0x4b, 0x49, 0x4c, 0x4c, 0x10, 0x02, 0x2a, 0x55, + 0x0a, 0x0f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x12, 0x20, 0x0a, 0x1c, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x52, + 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x53, + 0x54, 0x52, 0x41, 0x54, 0x45, 0x47, 0x59, 0x5f, 0x4d, 0x4f, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x43, + 0x45, 0x4e, 0x54, 0x10, 0x01, 0x32, 0x80, 0x05, 0x0a, 0x0d, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, + 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, + 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, + 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x72, 0x75, 0x6e, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x69, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x07, 0x45, 0x78, - 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x25, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, + 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, + 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6c, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, + 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, + 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x25, + 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x78, - 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x72, - 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x63, 0x0a, 0x0a, 0x52, 0x65, - 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x12, 0x28, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, - 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, - 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, - 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x66, 0x75, 0x6c, 0x2f, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x67, 0x6f, 0x2f, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2f, - 0x76, 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, + 0x01, 0x30, 0x01, 0x12, 0x63, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, + 0x76, 0x12, 0x28, 0x2e, 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, + 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, 0x75, + 0x6e, 0x6d, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x45, 0x6e, 0x76, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x66, 0x75, 0x6c, 0x2f, + 0x72, 0x75, 0x6e, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x72, 0x75, 0x6e, 0x6d, + 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x6e, + 0x65, 0x72, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1535,71 +1628,73 @@ func file_runme_runner_v2alpha1_runner_proto_rawDescGZIP() []byte { } var file_runme_runner_v2alpha1_runner_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_runme_runner_v2alpha1_runner_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_runme_runner_v2alpha1_runner_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_runme_runner_v2alpha1_runner_proto_goTypes = []interface{}{ - (ExecuteStop)(0), // 0: runme.runner.v2alpha1.ExecuteStop - (SessionStrategy)(0), // 1: runme.runner.v2alpha1.SessionStrategy - (ResolveEnvResponse_Source)(0), // 2: runme.runner.v2alpha1.ResolveEnvResponse.Source - (*Project)(nil), // 3: runme.runner.v2alpha1.Project - (*Session)(nil), // 4: runme.runner.v2alpha1.Session - (*CreateSessionRequest)(nil), // 5: runme.runner.v2alpha1.CreateSessionRequest - (*CreateSessionResponse)(nil), // 6: runme.runner.v2alpha1.CreateSessionResponse - (*GetSessionRequest)(nil), // 7: runme.runner.v2alpha1.GetSessionRequest - (*GetSessionResponse)(nil), // 8: runme.runner.v2alpha1.GetSessionResponse - (*ListSessionsRequest)(nil), // 9: runme.runner.v2alpha1.ListSessionsRequest - (*ListSessionsResponse)(nil), // 10: runme.runner.v2alpha1.ListSessionsResponse - (*DeleteSessionRequest)(nil), // 11: runme.runner.v2alpha1.DeleteSessionRequest - (*DeleteSessionResponse)(nil), // 12: runme.runner.v2alpha1.DeleteSessionResponse - (*Winsize)(nil), // 13: runme.runner.v2alpha1.Winsize - (*ExecuteRequest)(nil), // 14: runme.runner.v2alpha1.ExecuteRequest - (*ExecuteResponse)(nil), // 15: runme.runner.v2alpha1.ExecuteResponse - (*ResolveEnvRequest)(nil), // 16: runme.runner.v2alpha1.ResolveEnvRequest - (*ResolveEnvResponse)(nil), // 17: runme.runner.v2alpha1.ResolveEnvResponse - nil, // 18: runme.runner.v2alpha1.Session.MetadataEntry - nil, // 19: runme.runner.v2alpha1.CreateSessionRequest.MetadataEntry - (*ResolveEnvRequest_CommandList)(nil), // 20: runme.runner.v2alpha1.ResolveEnvRequest.CommandList - (*ResolveEnvResponse_ResolvedEnv)(nil), // 21: runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv - (*ResolveEnvResponse_UnresolvedEnv)(nil), // 22: runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv - (*ProgramConfig)(nil), // 23: runme.runner.v2alpha1.ProgramConfig - (*wrapperspb.UInt32Value)(nil), // 24: google.protobuf.UInt32Value + (ExecuteStop)(0), // 0: runme.runner.v2alpha1.ExecuteStop + (SessionStrategy)(0), // 1: runme.runner.v2alpha1.SessionStrategy + (ResolveEnvResult_ResolvedEnvSource)(0), // 2: runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource + (*Project)(nil), // 3: runme.runner.v2alpha1.Project + (*Session)(nil), // 4: runme.runner.v2alpha1.Session + (*CreateSessionRequest)(nil), // 5: runme.runner.v2alpha1.CreateSessionRequest + (*CreateSessionResponse)(nil), // 6: runme.runner.v2alpha1.CreateSessionResponse + (*GetSessionRequest)(nil), // 7: runme.runner.v2alpha1.GetSessionRequest + (*GetSessionResponse)(nil), // 8: runme.runner.v2alpha1.GetSessionResponse + (*ListSessionsRequest)(nil), // 9: runme.runner.v2alpha1.ListSessionsRequest + (*ListSessionsResponse)(nil), // 10: runme.runner.v2alpha1.ListSessionsResponse + (*DeleteSessionRequest)(nil), // 11: runme.runner.v2alpha1.DeleteSessionRequest + (*DeleteSessionResponse)(nil), // 12: runme.runner.v2alpha1.DeleteSessionResponse + (*Winsize)(nil), // 13: runme.runner.v2alpha1.Winsize + (*ExecuteRequest)(nil), // 14: runme.runner.v2alpha1.ExecuteRequest + (*ExecuteResponse)(nil), // 15: runme.runner.v2alpha1.ExecuteResponse + (*ResolveEnvRequest)(nil), // 16: runme.runner.v2alpha1.ResolveEnvRequest + (*ResolveEnvResult)(nil), // 17: runme.runner.v2alpha1.ResolveEnvResult + (*ResolveEnvResponse)(nil), // 18: runme.runner.v2alpha1.ResolveEnvResponse + nil, // 19: runme.runner.v2alpha1.Session.MetadataEntry + nil, // 20: runme.runner.v2alpha1.CreateSessionRequest.MetadataEntry + (*ResolveEnvRequest_CommandList)(nil), // 21: runme.runner.v2alpha1.ResolveEnvRequest.CommandList + (*ResolveEnvResult_ResolvedEnv)(nil), // 22: runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv + (*ResolveEnvResult_UnresolvedEnv)(nil), // 23: runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv + (*ProgramConfig)(nil), // 24: runme.runner.v2alpha1.ProgramConfig + (*wrapperspb.UInt32Value)(nil), // 25: google.protobuf.UInt32Value } var file_runme_runner_v2alpha1_runner_proto_depIdxs = []int32{ - 18, // 0: runme.runner.v2alpha1.Session.metadata:type_name -> runme.runner.v2alpha1.Session.MetadataEntry - 19, // 1: runme.runner.v2alpha1.CreateSessionRequest.metadata:type_name -> runme.runner.v2alpha1.CreateSessionRequest.MetadataEntry + 19, // 0: runme.runner.v2alpha1.Session.metadata:type_name -> runme.runner.v2alpha1.Session.MetadataEntry + 20, // 1: runme.runner.v2alpha1.CreateSessionRequest.metadata:type_name -> runme.runner.v2alpha1.CreateSessionRequest.MetadataEntry 3, // 2: runme.runner.v2alpha1.CreateSessionRequest.project:type_name -> runme.runner.v2alpha1.Project 4, // 3: runme.runner.v2alpha1.CreateSessionResponse.session:type_name -> runme.runner.v2alpha1.Session 4, // 4: runme.runner.v2alpha1.GetSessionResponse.session:type_name -> runme.runner.v2alpha1.Session 4, // 5: runme.runner.v2alpha1.ListSessionsResponse.sessions:type_name -> runme.runner.v2alpha1.Session - 23, // 6: runme.runner.v2alpha1.ExecuteRequest.config:type_name -> runme.runner.v2alpha1.ProgramConfig + 24, // 6: runme.runner.v2alpha1.ExecuteRequest.config:type_name -> runme.runner.v2alpha1.ProgramConfig 0, // 7: runme.runner.v2alpha1.ExecuteRequest.stop:type_name -> runme.runner.v2alpha1.ExecuteStop 13, // 8: runme.runner.v2alpha1.ExecuteRequest.winsize:type_name -> runme.runner.v2alpha1.Winsize 1, // 9: runme.runner.v2alpha1.ExecuteRequest.session_strategy:type_name -> runme.runner.v2alpha1.SessionStrategy 3, // 10: runme.runner.v2alpha1.ExecuteRequest.project:type_name -> runme.runner.v2alpha1.Project - 24, // 11: runme.runner.v2alpha1.ExecuteResponse.exit_code:type_name -> google.protobuf.UInt32Value - 24, // 12: runme.runner.v2alpha1.ExecuteResponse.pid:type_name -> google.protobuf.UInt32Value - 20, // 13: runme.runner.v2alpha1.ResolveEnvRequest.commands:type_name -> runme.runner.v2alpha1.ResolveEnvRequest.CommandList + 25, // 11: runme.runner.v2alpha1.ExecuteResponse.exit_code:type_name -> google.protobuf.UInt32Value + 25, // 12: runme.runner.v2alpha1.ExecuteResponse.pid:type_name -> google.protobuf.UInt32Value + 21, // 13: runme.runner.v2alpha1.ResolveEnvRequest.commands:type_name -> runme.runner.v2alpha1.ResolveEnvRequest.CommandList 1, // 14: runme.runner.v2alpha1.ResolveEnvRequest.session_strategy:type_name -> runme.runner.v2alpha1.SessionStrategy 3, // 15: runme.runner.v2alpha1.ResolveEnvRequest.project:type_name -> runme.runner.v2alpha1.Project - 21, // 16: runme.runner.v2alpha1.ResolveEnvResponse.resolved_env:type_name -> runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv - 22, // 17: runme.runner.v2alpha1.ResolveEnvResponse.unresolved_env:type_name -> runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv - 2, // 18: runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv.source:type_name -> runme.runner.v2alpha1.ResolveEnvResponse.Source - 5, // 19: runme.runner.v2alpha1.RunnerService.CreateSession:input_type -> runme.runner.v2alpha1.CreateSessionRequest - 7, // 20: runme.runner.v2alpha1.RunnerService.GetSession:input_type -> runme.runner.v2alpha1.GetSessionRequest - 9, // 21: runme.runner.v2alpha1.RunnerService.ListSessions:input_type -> runme.runner.v2alpha1.ListSessionsRequest - 11, // 22: runme.runner.v2alpha1.RunnerService.DeleteSession:input_type -> runme.runner.v2alpha1.DeleteSessionRequest - 14, // 23: runme.runner.v2alpha1.RunnerService.Execute:input_type -> runme.runner.v2alpha1.ExecuteRequest - 16, // 24: runme.runner.v2alpha1.RunnerService.ResolveEnv:input_type -> runme.runner.v2alpha1.ResolveEnvRequest - 6, // 25: runme.runner.v2alpha1.RunnerService.CreateSession:output_type -> runme.runner.v2alpha1.CreateSessionResponse - 8, // 26: runme.runner.v2alpha1.RunnerService.GetSession:output_type -> runme.runner.v2alpha1.GetSessionResponse - 10, // 27: runme.runner.v2alpha1.RunnerService.ListSessions:output_type -> runme.runner.v2alpha1.ListSessionsResponse - 12, // 28: runme.runner.v2alpha1.RunnerService.DeleteSession:output_type -> runme.runner.v2alpha1.DeleteSessionResponse - 15, // 29: runme.runner.v2alpha1.RunnerService.Execute:output_type -> runme.runner.v2alpha1.ExecuteResponse - 17, // 30: runme.runner.v2alpha1.RunnerService.ResolveEnv:output_type -> runme.runner.v2alpha1.ResolveEnvResponse - 25, // [25:31] is the sub-list for method output_type - 19, // [19:25] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 22, // 16: runme.runner.v2alpha1.ResolveEnvResult.resolved_env:type_name -> runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv + 23, // 17: runme.runner.v2alpha1.ResolveEnvResult.unresolved_env:type_name -> runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv + 17, // 18: runme.runner.v2alpha1.ResolveEnvResponse.items:type_name -> runme.runner.v2alpha1.ResolveEnvResult + 2, // 19: runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv.source:type_name -> runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource + 5, // 20: runme.runner.v2alpha1.RunnerService.CreateSession:input_type -> runme.runner.v2alpha1.CreateSessionRequest + 7, // 21: runme.runner.v2alpha1.RunnerService.GetSession:input_type -> runme.runner.v2alpha1.GetSessionRequest + 9, // 22: runme.runner.v2alpha1.RunnerService.ListSessions:input_type -> runme.runner.v2alpha1.ListSessionsRequest + 11, // 23: runme.runner.v2alpha1.RunnerService.DeleteSession:input_type -> runme.runner.v2alpha1.DeleteSessionRequest + 14, // 24: runme.runner.v2alpha1.RunnerService.Execute:input_type -> runme.runner.v2alpha1.ExecuteRequest + 16, // 25: runme.runner.v2alpha1.RunnerService.ResolveEnv:input_type -> runme.runner.v2alpha1.ResolveEnvRequest + 6, // 26: runme.runner.v2alpha1.RunnerService.CreateSession:output_type -> runme.runner.v2alpha1.CreateSessionResponse + 8, // 27: runme.runner.v2alpha1.RunnerService.GetSession:output_type -> runme.runner.v2alpha1.GetSessionResponse + 10, // 28: runme.runner.v2alpha1.RunnerService.ListSessions:output_type -> runme.runner.v2alpha1.ListSessionsResponse + 12, // 29: runme.runner.v2alpha1.RunnerService.DeleteSession:output_type -> runme.runner.v2alpha1.DeleteSessionResponse + 15, // 30: runme.runner.v2alpha1.RunnerService.Execute:output_type -> runme.runner.v2alpha1.ExecuteResponse + 18, // 31: runme.runner.v2alpha1.RunnerService.ResolveEnv:output_type -> runme.runner.v2alpha1.ResolveEnvResponse + 26, // [26:32] is the sub-list for method output_type + 20, // [20:26] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_runme_runner_v2alpha1_runner_proto_init() } @@ -1778,7 +1873,7 @@ func file_runme_runner_v2alpha1_runner_proto_init() { } } file_runme_runner_v2alpha1_runner_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolveEnvResponse); i { + switch v := v.(*ResolveEnvResult); i { case 0: return &v.state case 1: @@ -1789,8 +1884,8 @@ func file_runme_runner_v2alpha1_runner_proto_init() { return nil } } - file_runme_runner_v2alpha1_runner_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolveEnvRequest_CommandList); i { + file_runme_runner_v2alpha1_runner_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResolveEnvResponse); i { case 0: return &v.state case 1: @@ -1802,7 +1897,7 @@ func file_runme_runner_v2alpha1_runner_proto_init() { } } file_runme_runner_v2alpha1_runner_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolveEnvResponse_ResolvedEnv); i { + switch v := v.(*ResolveEnvRequest_CommandList); i { case 0: return &v.state case 1: @@ -1814,7 +1909,19 @@ func file_runme_runner_v2alpha1_runner_proto_init() { } } file_runme_runner_v2alpha1_runner_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolveEnvResponse_UnresolvedEnv); i { + switch v := v.(*ResolveEnvResult_ResolvedEnv); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_runme_runner_v2alpha1_runner_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResolveEnvResult_UnresolvedEnv); i { case 0: return &v.state case 1: @@ -1832,13 +1939,17 @@ func file_runme_runner_v2alpha1_runner_proto_init() { (*ResolveEnvRequest_Commands)(nil), (*ResolveEnvRequest_Script)(nil), } + file_runme_runner_v2alpha1_runner_proto_msgTypes[14].OneofWrappers = []interface{}{ + (*ResolveEnvResult_ResolvedEnv_)(nil), + (*ResolveEnvResult_UnresolvedEnv_)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_runme_runner_v2alpha1_runner_proto_rawDesc, NumEnums: 3, - NumMessages: 20, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.d.ts b/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.d.ts index 0e29b29bf..e3b61d7e1 100644 --- a/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.d.ts +++ b/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.d.ts @@ -278,16 +278,24 @@ export interface ResolveEnvRequest { * @generated from protobuf field: repeated string env = 3; */ env: string[]; + /** + * session_id indicates in which Session the program should execute. + * Executing in a Session might provide additional context like + * environment variables. + * + * @generated from protobuf field: string session_id = 4; + */ + sessionId: string; /** * session_strategy is a strategy for selecting the session. * - * @generated from protobuf field: runme.runner.v2alpha1.SessionStrategy session_strategy = 4; + * @generated from protobuf field: runme.runner.v2alpha1.SessionStrategy session_strategy = 5; */ sessionStrategy: SessionStrategy; /** * project used to load environment variables from .env files. * - * @generated from protobuf field: optional runme.runner.v2alpha1.Project project = 5; + * @generated from protobuf field: optional runme.runner.v2alpha1.Project project = 6; */ project?: Project; } @@ -305,31 +313,36 @@ export interface ResolveEnvRequest_CommandList { items: string[]; } /** - * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResponse + * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResult */ -export interface ResolveEnvResponse { +export interface ResolveEnvResult { /** - * resolved_env is a list of resolved environment variables. - * - * @generated from protobuf field: repeated runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv resolved_env = 1; + * @generated from protobuf oneof: result */ - resolvedEnv: ResolveEnvResponse_ResolvedEnv[]; - /** - * unresolved_env is a list of environment variables - * that couldn't be resolved. - * - * @generated from protobuf field: repeated runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv unresolved_env = 2; - */ - unresolvedEnv: ResolveEnvResponse_UnresolvedEnv[]; + result: { + oneofKind: "resolvedEnv"; + /** + * @generated from protobuf field: runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv resolved_env = 1; + */ + resolvedEnv: ResolveEnvResult_ResolvedEnv; + } | { + oneofKind: "unresolvedEnv"; + /** + * @generated from protobuf field: runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv unresolved_env = 2; + */ + unresolvedEnv: ResolveEnvResult_UnresolvedEnv; + } | { + oneofKind: undefined; + }; } /** - * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv + * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv */ -export interface ResolveEnvResponse_ResolvedEnv { +export interface ResolveEnvResult_ResolvedEnv { /** - * @generated from protobuf field: string key = 1; + * @generated from protobuf field: string name = 1; */ - key: string; + name: string; /** * @generated from protobuf field: string original_value = 2; */ @@ -339,44 +352,53 @@ export interface ResolveEnvResponse_ResolvedEnv { */ resolvedValue: string; /** - * @generated from protobuf field: runme.runner.v2alpha1.ResolveEnvResponse.Source source = 4; + * @generated from protobuf field: runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource source = 4; */ - source: ResolveEnvResponse_Source; + source: ResolveEnvResult_ResolvedEnvSource; } /** - * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv + * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv */ -export interface ResolveEnvResponse_UnresolvedEnv { +export interface ResolveEnvResult_UnresolvedEnv { /** - * @generated from protobuf field: string key = 1; + * @generated from protobuf field: string name = 1; */ - key: string; + name: string; /** * @generated from protobuf field: string original_value = 2; */ originalValue: string; } /** - * @generated from protobuf enum runme.runner.v2alpha1.ResolveEnvResponse.Source + * @generated from protobuf enum runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource */ -export declare enum ResolveEnvResponse_Source { +export declare enum ResolveEnvResult_ResolvedEnvSource { /** - * @generated from protobuf enum value: SOURCE_UNSPECIFIED = 0; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_UNSPECIFIED = 0; */ UNSPECIFIED = 0, /** - * @generated from protobuf enum value: SOURCE_ENV = 1; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_ENV = 1; */ ENV = 1, /** - * @generated from protobuf enum value: SOURCE_SESSION = 2; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_SESSION = 2; */ SESSION = 2, /** - * @generated from protobuf enum value: SOURCE_PROJECT = 3; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_PROJECT = 3; */ PROJECT = 3 } +/** + * @generated from protobuf message runme.runner.v2alpha1.ResolveEnvResponse + */ +export interface ResolveEnvResponse { + /** + * @generated from protobuf field: repeated runme.runner.v2alpha1.ResolveEnvResult items = 1; + */ + items: ResolveEnvResult[]; +} /** * @generated from protobuf enum runme.runner.v2alpha1.ExecuteStop */ @@ -521,27 +543,34 @@ declare class ResolveEnvRequest_CommandList$Type extends MessageType { +declare class ResolveEnvResult$Type extends MessageType { constructor(); } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult */ -export declare const ResolveEnvResponse: ResolveEnvResponse$Type; -declare class ResolveEnvResponse_ResolvedEnv$Type extends MessageType { +export declare const ResolveEnvResult: ResolveEnvResult$Type; +declare class ResolveEnvResult_ResolvedEnv$Type extends MessageType { constructor(); } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv */ -export declare const ResolveEnvResponse_ResolvedEnv: ResolveEnvResponse_ResolvedEnv$Type; -declare class ResolveEnvResponse_UnresolvedEnv$Type extends MessageType { +export declare const ResolveEnvResult_ResolvedEnv: ResolveEnvResult_ResolvedEnv$Type; +declare class ResolveEnvResult_UnresolvedEnv$Type extends MessageType { constructor(); } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv */ -export declare const ResolveEnvResponse_UnresolvedEnv: ResolveEnvResponse_UnresolvedEnv$Type; +export declare const ResolveEnvResult_UnresolvedEnv: ResolveEnvResult_UnresolvedEnv$Type; +declare class ResolveEnvResponse$Type extends MessageType { + constructor(); +} +/** + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse + */ +export declare const ResolveEnvResponse: ResolveEnvResponse$Type; /** * @generated ServiceType for protobuf service runme.runner.v2alpha1.RunnerService */ diff --git a/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.js b/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.js index 440d82b2c..68636b545 100644 --- a/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.js +++ b/internal/gen/proto/ts/runme/runner/v2alpha1/runner_pb.js @@ -13,27 +13,27 @@ import { MessageType } from "@protobuf-ts/runtime"; import { UInt32Value } from "../../../google/protobuf/wrappers_pb"; import { ProgramConfig } from "./config_pb"; /** - * @generated from protobuf enum runme.runner.v2alpha1.ResolveEnvResponse.Source + * @generated from protobuf enum runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource */ -export var ResolveEnvResponse_Source; -(function (ResolveEnvResponse_Source) { +export var ResolveEnvResult_ResolvedEnvSource; +(function (ResolveEnvResult_ResolvedEnvSource) { /** - * @generated from protobuf enum value: SOURCE_UNSPECIFIED = 0; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_UNSPECIFIED = 0; */ - ResolveEnvResponse_Source[ResolveEnvResponse_Source["UNSPECIFIED"] = 0] = "UNSPECIFIED"; + ResolveEnvResult_ResolvedEnvSource[ResolveEnvResult_ResolvedEnvSource["UNSPECIFIED"] = 0] = "UNSPECIFIED"; /** - * @generated from protobuf enum value: SOURCE_ENV = 1; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_ENV = 1; */ - ResolveEnvResponse_Source[ResolveEnvResponse_Source["ENV"] = 1] = "ENV"; + ResolveEnvResult_ResolvedEnvSource[ResolveEnvResult_ResolvedEnvSource["ENV"] = 1] = "ENV"; /** - * @generated from protobuf enum value: SOURCE_SESSION = 2; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_SESSION = 2; */ - ResolveEnvResponse_Source[ResolveEnvResponse_Source["SESSION"] = 2] = "SESSION"; + ResolveEnvResult_ResolvedEnvSource[ResolveEnvResult_ResolvedEnvSource["SESSION"] = 2] = "SESSION"; /** - * @generated from protobuf enum value: SOURCE_PROJECT = 3; + * @generated from protobuf enum value: RESOLVED_ENV_SOURCE_PROJECT = 3; */ - ResolveEnvResponse_Source[ResolveEnvResponse_Source["PROJECT"] = 3] = "PROJECT"; -})(ResolveEnvResponse_Source || (ResolveEnvResponse_Source = {})); + ResolveEnvResult_ResolvedEnvSource[ResolveEnvResult_ResolvedEnvSource["PROJECT"] = 3] = "PROJECT"; +})(ResolveEnvResult_ResolvedEnvSource || (ResolveEnvResult_ResolvedEnvSource = {})); /** * @generated from protobuf enum runme.runner.v2alpha1.ExecuteStop */ @@ -252,8 +252,9 @@ class ResolveEnvRequest$Type extends MessageType { { no: 1, name: "commands", kind: "message", oneof: "source", T: () => ResolveEnvRequest_CommandList }, { no: 2, name: "script", kind: "scalar", oneof: "source", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "env", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ }, - { no: 4, name: "session_strategy", kind: "enum", T: () => ["runme.runner.v2alpha1.SessionStrategy", SessionStrategy, "SESSION_STRATEGY_"] }, - { no: 5, name: "project", kind: "message", T: () => Project } + { no: 4, name: "session_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 5, name: "session_strategy", kind: "enum", T: () => ["runme.runner.v2alpha1.SessionStrategy", SessionStrategy, "SESSION_STRATEGY_"] }, + { no: 6, name: "project", kind: "message", T: () => Project } ]); } } @@ -274,46 +275,58 @@ class ResolveEnvRequest_CommandList$Type extends MessageType { */ export const ResolveEnvRequest_CommandList = new ResolveEnvRequest_CommandList$Type(); // @generated message type with reflection information, may provide speed optimized methods -class ResolveEnvResponse$Type extends MessageType { +class ResolveEnvResult$Type extends MessageType { constructor() { - super("runme.runner.v2alpha1.ResolveEnvResponse", [ - { no: 1, name: "resolved_env", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => ResolveEnvResponse_ResolvedEnv }, - { no: 2, name: "unresolved_env", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => ResolveEnvResponse_UnresolvedEnv } + super("runme.runner.v2alpha1.ResolveEnvResult", [ + { no: 1, name: "resolved_env", kind: "message", oneof: "result", T: () => ResolveEnvResult_ResolvedEnv }, + { no: 2, name: "unresolved_env", kind: "message", oneof: "result", T: () => ResolveEnvResult_UnresolvedEnv } ]); } } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult */ -export const ResolveEnvResponse = new ResolveEnvResponse$Type(); +export const ResolveEnvResult = new ResolveEnvResult$Type(); // @generated message type with reflection information, may provide speed optimized methods -class ResolveEnvResponse_ResolvedEnv$Type extends MessageType { +class ResolveEnvResult_ResolvedEnv$Type extends MessageType { constructor() { - super("runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv", [ - { no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + super("runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv", [ + { no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "original_value", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "resolved_value", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, - { no: 4, name: "source", kind: "enum", T: () => ["runme.runner.v2alpha1.ResolveEnvResponse.Source", ResolveEnvResponse_Source, "SOURCE_"] } + { no: 4, name: "source", kind: "enum", T: () => ["runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnvSource", ResolveEnvResult_ResolvedEnvSource, "RESOLVED_ENV_SOURCE_"] } ]); } } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse.ResolvedEnv + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult.ResolvedEnv */ -export const ResolveEnvResponse_ResolvedEnv = new ResolveEnvResponse_ResolvedEnv$Type(); +export const ResolveEnvResult_ResolvedEnv = new ResolveEnvResult_ResolvedEnv$Type(); // @generated message type with reflection information, may provide speed optimized methods -class ResolveEnvResponse_UnresolvedEnv$Type extends MessageType { +class ResolveEnvResult_UnresolvedEnv$Type extends MessageType { constructor() { - super("runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv", [ - { no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + super("runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv", [ + { no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "original_value", kind: "scalar", T: 9 /*ScalarType.STRING*/ } ]); } } /** - * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse.UnresolvedEnv + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResult.UnresolvedEnv */ -export const ResolveEnvResponse_UnresolvedEnv = new ResolveEnvResponse_UnresolvedEnv$Type(); +export const ResolveEnvResult_UnresolvedEnv = new ResolveEnvResult_UnresolvedEnv$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class ResolveEnvResponse$Type extends MessageType { + constructor() { + super("runme.runner.v2alpha1.ResolveEnvResponse", [ + { no: 1, name: "items", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => ResolveEnvResult } + ]); + } +} +/** + * @generated MessageType for protobuf message runme.runner.v2alpha1.ResolveEnvResponse + */ +export const ResolveEnvResponse = new ResolveEnvResponse$Type(); /** * @generated ServiceType for protobuf service runme.runner.v2alpha1.RunnerService */ diff --git a/internal/runnerv2service/service.go b/internal/runnerv2service/service.go index a5cfd1a27..1ef9cceea 100644 --- a/internal/runnerv2service/service.go +++ b/internal/runnerv2service/service.go @@ -2,6 +2,8 @@ package runnerv2service import ( "go.uber.org/zap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/stateful/runme/internal/command" runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" @@ -28,3 +30,55 @@ func newRunnerService(logger *zap.Logger) (*runnerService, error) { logger: logger, }, nil } + +type requestWithSession interface { + GetSessionId() string + GetSessionStrategy() runnerv2alpha1.SessionStrategy +} + +func (r runnerService) getSessionFromRequest(req requestWithSession) (*command.Session, bool, error) { + var ( + session *command.Session + found bool + ) + + switch req.GetSessionStrategy() { + case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_UNSPECIFIED: + if req.GetSessionId() != "" { + session, found = r.sessions.Get(req.GetSessionId()) + if !found { + return nil, false, status.Errorf(codes.NotFound, "session %q not found", req.GetSessionId()) + } + } + case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_MOST_RECENT: + session, found = r.sessions.Newest() + } + + return session, found, nil +} + +func (r *runnerService) getOrCreateSessionFromRequest(req requestWithSession) (_ *command.Session, exists bool, _ error) { + var ( + session *command.Session + found bool + ) + + switch req.GetSessionStrategy() { + case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_UNSPECIFIED: + if req.GetSessionId() != "" { + session, found = r.sessions.Get(req.GetSessionId()) + if !found { + return nil, false, status.Errorf(codes.NotFound, "session %q not found", req.GetSessionId()) + } + } else { + session = command.NewSession() + } + case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_MOST_RECENT: + session, found = r.sessions.Newest() + if !found { + session = command.NewSession() + } + } + + return session, found, nil +} diff --git a/internal/runnerv2service/service_execute.go b/internal/runnerv2service/service_execute.go index df7dbce25..58ebbebd1 100644 --- a/internal/runnerv2service/service_execute.go +++ b/internal/runnerv2service/service_execute.go @@ -10,7 +10,6 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/wrapperspb" - "github.com/stateful/runme/internal/command" runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" "github.com/stateful/runme/internal/ulid" ) @@ -34,10 +33,19 @@ func (r *runnerService) Execute(srv runnerv2alpha1.RunnerService_ExecuteServer) } logger.Info("received initial request", zap.Any("req", req)) - session, err := r.getOrCreateSessionFromExecuteRequest(req) + // Manage the session. + session, existed, err := r.getOrCreateSessionFromRequest(req) if err != nil { return err } + if err := session.SetEnv(req.Config.Env...); err != nil { + return err + } + if !existed { + r.sessions.Add(session) + } + + // TODO: extend session with the project, if present. exec, err := newExecution( id, @@ -122,37 +130,3 @@ func (r *runnerService) Execute(srv runnerv2alpha1.RunnerService_ExecuteServer) return waitErr } - -func (r *runnerService) getOrCreateSessionFromExecuteRequest(req *runnerv2alpha1.ExecuteRequest) (*command.Session, error) { - var ( - session *command.Session - ok bool - ) - - switch req.SessionStrategy { - case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_UNSPECIFIED: - if req.SessionId != "" { - session, ok = r.sessions.Get(req.SessionId) - if !ok { - return nil, status.Errorf(codes.NotFound, "session %q not found", req.SessionId) - } - } else { - session = command.NewSession() - } - case runnerv2alpha1.SessionStrategy_SESSION_STRATEGY_MOST_RECENT: - session, ok = r.sessions.Newest() - if !ok { - session = command.NewSession() - } - } - - if err := session.SetEnv(req.Config.Env...); err != nil { - return nil, err - } - - if !ok { - r.sessions.Add(session) - } - - return session, nil -} diff --git a/internal/runnerv2service/service_resolve_env.go b/internal/runnerv2service/service_resolve_env.go new file mode 100644 index 000000000..56942f337 --- /dev/null +++ b/internal/runnerv2service/service_resolve_env.go @@ -0,0 +1,70 @@ +package runnerv2service + +import ( + "context" + "slices" + "strings" + + "github.com/stateful/runme/internal/command" + runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" + "go.uber.org/zap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (r *runnerService) ResolveEnv(ctx context.Context, req *runnerv2alpha1.ResolveEnvRequest) (*runnerv2alpha1.ResolveEnvResponse, error) { + sources := []command.EnvResolverSource{ + command.EnvResolverSourceFunc(req.Env), + } + + // Load project envs. + proj, err := convertProtoProjectToProject(req.GetProject()) + if err != nil { + return nil, err + } + if proj != nil { + projEnvs, err := proj.LoadEnvs() + if err != nil { + r.logger.Info("failed to load envs for project", zap.Error(err)) + } else { + sources = append(sources, command.EnvResolverSourceFunc(projEnvs)) + } + } + + // Load session envs. + session, found, err := r.getSessionFromRequest(req) + if err != nil { + return nil, err + } + if found { + sources = append(sources, command.EnvResolverSourceFunc(session.GetEnv())) + } + + resolver := command.NewEnvResolver(sources...) + + var result []*runnerv2alpha1.ResolveEnvResult + + if script := req.GetScript(); script != "" { + result, err = resolver.Resolve(strings.NewReader(script)) + } else if commands := req.GetCommands(); commands != nil && len(commands.Items) > 0 { + result, err = resolver.Resolve(strings.NewReader(strings.Join(commands.Items, "\n"))) + } else { + err = status.Error(codes.InvalidArgument, "either script or commands must be provided") + } + if err != nil { + return nil, err + } + + slices.SortStableFunc(result, func(a, b *runnerv2alpha1.ResolveEnvResult) int { + aResolved, bResolved := a.GetResolvedEnv(), b.GetResolvedEnv() + if aResolved != nil && bResolved != nil { + return strings.Compare(aResolved.Name, bResolved.Name) + } + if aResolved != nil { + return -1 + } + return 1 + }) + + return &runnerv2alpha1.ResolveEnvResponse{Items: result}, nil +} diff --git a/internal/runnerv2service/service_resolve_env_test.go b/internal/runnerv2service/service_resolve_env_test.go new file mode 100644 index 000000000..284f7ad19 --- /dev/null +++ b/internal/runnerv2service/service_resolve_env_test.go @@ -0,0 +1,81 @@ +package runnerv2service + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" +) + +func TestRunnerServiceResolveEnv(t *testing.T) { + lis, stop := testStartRunnerServiceServer(t) + t.Cleanup(stop) + _, client := testCreateRunnerServiceClient(t, lis) + + testCases := []struct { + name string + request *runnerv2alpha1.ResolveEnvRequest + }{ + { + name: "WithScript", + request: &runnerv2alpha1.ResolveEnvRequest{ + Env: []string{"TEST_RESOLVED=value"}, + Source: &runnerv2alpha1.ResolveEnvRequest_Script{ + Script: "export TEST_RESOLVED=default\nexport TEST_UNRESOLVED", + }, + }, + }, + { + name: "WithCommands", + request: &runnerv2alpha1.ResolveEnvRequest{ + Env: []string{"TEST_RESOLVED=value"}, + Source: &runnerv2alpha1.ResolveEnvRequest_Commands{ + Commands: &runnerv2alpha1.ResolveEnvRequest_CommandList{ + Items: []string{"export TEST_RESOLVED=default", "export TEST_UNRESOLVED"}, + }, + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + resp, err := client.ResolveEnv(context.Background(), &runnerv2alpha1.ResolveEnvRequest{ + Env: []string{"TEST_RESOLVED=value"}, + Source: &runnerv2alpha1.ResolveEnvRequest_Script{ + Script: "export TEST_RESOLVED=default\nexport TEST_UNRESOLVED", + }, + }) + require.NoError(t, err) + require.Len(t, resp.Items, 2) + require.EqualValues( + t, + &runnerv2alpha1.ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv_{ + ResolvedEnv: &runnerv2alpha1.ResolveEnvResult_ResolvedEnv{ + Name: "TEST_RESOLVED", + OriginalValue: "default", + ResolvedValue: "value", + }, + }, + }, + resp.Items[0], + ) + require.EqualValues( + t, + &runnerv2alpha1.ResolveEnvResult{ + Result: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv_{ + UnresolvedEnv: &runnerv2alpha1.ResolveEnvResult_UnresolvedEnv{ + Name: "TEST_UNRESOLVED", + }, + }, + }, + resp.Items[1], + ) + }) + } +} diff --git a/internal/runnerv2service/service_sessions.go b/internal/runnerv2service/service_sessions.go index a238c21cf..8655f3d51 100644 --- a/internal/runnerv2service/service_sessions.go +++ b/internal/runnerv2service/service_sessions.go @@ -19,6 +19,7 @@ func toRunnerv2alpha1Session(sess *command.Session) *runnerv2alpha1.Session { } } +// TODO(adamb): this function should not return nil project and nil error at the same time. func convertProtoProjectToProject(runnerProj *runnerv2alpha1.Project) (*project.Project, error) { if runnerProj == nil { return nil, nil