diff --git a/pkg/build/buildkit/autodiscovery/k8s.go b/pkg/build/buildkit/autodiscovery/k8s.go index 6d2260f..1bef2ee 100644 --- a/pkg/build/buildkit/autodiscovery/k8s.go +++ b/pkg/build/buildkit/autodiscovery/k8s.go @@ -242,8 +242,6 @@ func watchBuildKitPods(ctx context.Context, cs kubernetes.Interface, opts Kubern continue } - fmt.Println("****", e.Object) - pod := e.Object.(*corev1.Pod) if isPodReady(pod) { pods <- pod @@ -325,11 +323,11 @@ func setTsuruAppLabelOnBuildKitPod(ctx context.Context, cs kubernetes.Interface, }, } - if app.Team != nil { + if app.Team != "" { changes = append(changes, map[string]any{ "op": "replace", "path": fmt.Sprintf("/metadata/labels/%s", normalizeAppLabelForJSONPatch(metadata.TsuruAppTeamLabelKey)), - "value": *app.Team, + "value": app.Team, }) } diff --git a/pkg/build/buildkit/autodiscovery/k8s_test.go b/pkg/build/buildkit/autodiscovery/k8s_test.go new file mode 100644 index 0000000..fdcf877 --- /dev/null +++ b/pkg/build/buildkit/autodiscovery/k8s_test.go @@ -0,0 +1,96 @@ +// Copyright 2024 tsuru authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package autodiscovery + +import ( + "context" + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/tsuru/deploy-agent/pkg/build/grpc_build_v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + fakeDynamic "k8s.io/client-go/dynamic/fake" + "k8s.io/client-go/kubernetes/fake" + kuberntesTesting "k8s.io/client-go/testing" +) + +func TestK8sDiscoverer_Discover(t *testing.T) { + buildKitPod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-app", + Namespace: "tsuru", + Labels: map[string]string{ + "app": "test-app", + }, + Annotations: map[string]string{ + "foo": "bar", + }, + }, + Status: corev1.PodStatus{ + Phase: corev1.PodRunning, + PodIP: "127.0.0.1", + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodReady, + Status: corev1.ConditionTrue, + }, + }, + }, + } + fakeClient := fake.NewSimpleClientset(buildKitPod) + + fakeClient.PrependWatchReactor("*", func(action kuberntesTesting.Action) (handled bool, ret watch.Interface, err error) { + watcher := watch.NewFake() + + go func() { + time.Sleep(time.Millisecond * 100) + watcher.Add(buildKitPod) + }() + return true, watcher, nil + }) + + fakeDynamicClient := fakeDynamic.NewSimpleDynamicClient(runtime.NewScheme()) + + discoverer := K8sDiscoverer{ + KubernetesInterface: fakeClient, + DynamicInterface: fakeDynamicClient, + } + + _, _, err := discoverer.Discover( + context.TODO(), + KubernertesDiscoveryOptions{ + PodSelector: "app=test-app", + Namespace: "tsuru", + Timeout: time.Second * 2, + SetTsuruAppLabel: true, + }, + &grpc_build_v1.BuildRequest{ + App: &grpc_build_v1.TsuruApp{ + Name: "test-app", + Team: "test-team", + }, + }, + os.Stdout, + ) + assert.NoError(t, err) + + existingPod, err := fakeClient.CoreV1().Pods("tsuru").Get(context.TODO(), "test-app", metav1.GetOptions{}) + assert.NoError(t, err) + + assert.Equal(t, map[string]string{ + "app": "test-app", + "tsuru.io/app-name": "test-app", + "tsuru.io/app-team": "test-team", + "tsuru.io/is-build": "true", + }, existingPod.Labels) + + assert.Equal(t, "", existingPod.Annotations["deploy-agent.tsuru.io/last-build-ending-time"]) + assert.NotEqual(t, "", existingPod.Annotations["deploy-agent.tsuru.io/last-build-starting-time"]) +} diff --git a/pkg/build/grpc_build_v1/build_service.pb.go b/pkg/build/grpc_build_v1/build_service.pb.go index 0bbb654..bbb1ed7 100644 --- a/pkg/build/grpc_build_v1/build_service.pb.go +++ b/pkg/build/grpc_build_v1/build_service.pb.go @@ -328,7 +328,7 @@ type TsuruApp struct { // EnvVars are the enviroment variables set on app. EnvVars map[string]string `protobuf:"bytes,3,rep,name=env_vars,json=envVars,proto3" json:"env_vars,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Team is the Tsuru team name, optional just for compatibility with old tsuru-api versions. - Team *string `protobuf:"bytes,4,opt,name=team,proto3,oneof" json:"team,omitempty"` + Team string `protobuf:"bytes,4,opt,name=team,proto3" json:"team,omitempty"` } func (x *TsuruApp) Reset() { @@ -378,8 +378,8 @@ func (x *TsuruApp) GetEnvVars() map[string]string { } func (x *TsuruApp) GetTeam() string { - if x != nil && x.Team != nil { - return *x.Team + if x != nil { + return x.Team } return "" } @@ -394,7 +394,7 @@ type TsuruJob struct { // EnvVars are the enviroment variables set on the job. EnvVars map[string]string `protobuf:"bytes,3,rep,name=env_vars,json=envVars,proto3" json:"env_vars,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Team is the Tsuru team name, optional just for compatibility with old tsuru-api versions. - Team *string `protobuf:"bytes,4,opt,name=team,proto3,oneof" json:"team,omitempty"` + Team string `protobuf:"bytes,4,opt,name=team,proto3" json:"team,omitempty"` } func (x *TsuruJob) Reset() { @@ -444,8 +444,8 @@ func (x *TsuruJob) GetEnvVars() map[string]string { } func (x *TsuruJob) GetTeam() string { - if x != nil && x.Team != nil { - return *x.Team + if x != nil { + return x.Team } return "" } @@ -731,101 +731,99 @@ var file_pkg_build_grpc_build_v1_build_service_proto_rawDesc = []byte{ 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x54, 0x73, 0x75, 0x72, 0x75, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x73, 0x75, 0x72, 0x75, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xbd, 0x01, 0x0a, 0x08, 0x54, + 0x69, 0x67, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xaf, 0x01, 0x0a, 0x08, 0x54, 0x73, 0x75, 0x72, 0x75, 0x41, 0x70, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x54, 0x73, 0x75, 0x72, 0x75, 0x41, 0x70, 0x70, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x17, 0x0a, 0x04, - 0x74, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x74, 0x65, - 0x61, 0x6d, 0x88, 0x01, 0x01, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x65, 0x61, 0x6d, 0x22, 0xbd, 0x01, 0x0a, 0x08, 0x54, - 0x73, 0x75, 0x72, 0x75, 0x4a, 0x6f, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x08, 0x65, - 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x54, 0x73, - 0x75, 0x72, 0x75, 0x4a, 0x6f, 0x62, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x17, 0x0a, 0x04, - 0x74, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x74, 0x65, - 0x61, 0x6d, 0x88, 0x01, 0x01, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x65, 0x61, 0x6d, 0x22, 0x23, 0x0a, 0x0d, 0x54, 0x73, - 0x75, 0x72, 0x75, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x54, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, - 0x0a, 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x69, 0x6e, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x10, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x22, 0x8e, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, - 0x0a, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x10, - 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, - 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, - 0x50, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, - 0x5f, 0x64, 0x69, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x6f, 0x72, 0x6b, - 0x69, 0x6e, 0x67, 0x44, 0x69, 0x72, 0x22, 0x90, 0x01, 0x0a, 0x0b, 0x54, 0x73, 0x75, 0x72, 0x75, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x63, 0x66, 0x69, - 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x63, 0x66, 0x69, - 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x73, 0x75, 0x72, 0x75, 0x5f, 0x79, 0x61, 0x6d, 0x6c, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x73, 0x75, 0x72, 0x75, 0x59, 0x61, 0x6d, - 0x6c, 0x12, 0x46, 0x0a, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0b, 0x69, 0x6d, - 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2a, 0xac, 0x04, 0x0a, 0x09, 0x42, 0x75, - 0x69, 0x6c, 0x64, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x42, 0x55, 0x49, 0x4c, 0x44, - 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x2b, 0x0a, 0x27, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, - 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, - 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x4c, 0x4f, 0x41, 0x44, 0x10, 0x01, - 0x12, 0x2c, 0x0a, 0x28, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, - 0x50, 0x50, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x53, - 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x4c, 0x4f, 0x41, 0x44, 0x10, 0x01, 0x12, 0x2d, - 0x0a, 0x29, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, - 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, - 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x02, 0x12, 0x2e, 0x0a, - 0x2a, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, - 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, - 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x02, 0x12, 0x2c, 0x0a, - 0x28, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, - 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, - 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x03, 0x12, 0x2d, 0x0a, 0x29, 0x42, - 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, 0x44, 0x45, - 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, - 0x4e, 0x45, 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x03, 0x12, 0x2c, 0x0a, 0x28, 0x42, 0x55, - 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, - 0x4d, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, - 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x05, 0x12, 0x2b, 0x0a, 0x27, 0x42, 0x55, 0x49, 0x4c, - 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, - 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x46, - 0x49, 0x4c, 0x45, 0x10, 0x06, 0x12, 0x2e, 0x0a, 0x2a, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, - 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x5f, 0x57, - 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, - 0x41, 0x47, 0x45, 0x10, 0x07, 0x12, 0x2e, 0x0a, 0x2a, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, - 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, - 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, - 0x41, 0x47, 0x45, 0x10, 0x07, 0x12, 0x2d, 0x0a, 0x29, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, - 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, - 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x46, 0x49, - 0x4c, 0x45, 0x10, 0x08, 0x1a, 0x02, 0x10, 0x01, 0x32, 0x4f, 0x0a, 0x05, 0x42, 0x75, 0x69, 0x6c, - 0x64, 0x12, 0x46, 0x0a, 0x05, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x1b, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x73, 0x75, 0x72, 0x75, 0x2f, 0x64, 0x65, - 0x70, 0x6c, 0x6f, 0x79, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, - 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x61, 0x6d, + 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xaf, 0x01, 0x0a, + 0x08, 0x54, 0x73, 0x75, 0x72, 0x75, 0x4a, 0x6f, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, + 0x08, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, + 0x54, 0x73, 0x75, 0x72, 0x75, 0x4a, 0x6f, 0x62, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, + 0x61, 0x6d, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x23, + 0x0a, 0x0d, 0x54, 0x73, 0x75, 0x72, 0x75, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2b, 0x0a, 0x11, + 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x22, 0x8e, 0x01, 0x0a, 0x14, 0x43, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x03, 0x63, 0x6d, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x64, 0x5f, + 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x70, + 0x6f, 0x73, 0x65, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x6f, 0x72, + 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x72, 0x22, 0x90, 0x01, 0x0a, 0x0b, 0x54, + 0x73, 0x75, 0x72, 0x75, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, + 0x6f, 0x63, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, + 0x6f, 0x63, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x73, 0x75, 0x72, 0x75, 0x5f, + 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x73, 0x75, 0x72, + 0x75, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x46, 0x0a, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2a, 0xac, 0x04, + 0x0a, 0x09, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x42, + 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x2b, 0x0a, 0x27, 0x42, 0x55, 0x49, 0x4c, 0x44, + 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, + 0x57, 0x49, 0x54, 0x48, 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x4c, 0x4f, + 0x41, 0x44, 0x10, 0x01, 0x12, 0x2c, 0x0a, 0x28, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, + 0x4e, 0x44, 0x5f, 0x41, 0x50, 0x50, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, + 0x54, 0x48, 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x4c, 0x4f, 0x41, 0x44, + 0x10, 0x01, 0x12, 0x2d, 0x0a, 0x29, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, + 0x5f, 0x41, 0x50, 0x50, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, + 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, + 0x02, 0x12, 0x2e, 0x0a, 0x2a, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, + 0x41, 0x50, 0x50, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, + 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, + 0x02, 0x12, 0x2c, 0x0a, 0x28, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, + 0x41, 0x50, 0x50, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, + 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x03, 0x12, + 0x2d, 0x0a, 0x29, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x50, + 0x50, 0x5f, 0x44, 0x45, 0x50, 0x4c, 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, + 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x03, 0x12, 0x2c, + 0x0a, 0x28, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x4c, 0x41, + 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, + 0x49, 0x4e, 0x45, 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x05, 0x12, 0x2b, 0x0a, 0x27, + 0x42, 0x55, 0x49, 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, + 0x4f, 0x52, 0x4d, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, + 0x45, 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x06, 0x12, 0x2e, 0x0a, 0x2a, 0x42, 0x55, 0x49, + 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, + 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x07, 0x12, 0x2e, 0x0a, 0x2a, 0x42, 0x55, 0x49, + 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x44, 0x45, 0x50, 0x4c, + 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, + 0x52, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x10, 0x07, 0x12, 0x2d, 0x0a, 0x29, 0x42, 0x55, 0x49, + 0x4c, 0x44, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x4a, 0x4f, 0x42, 0x5f, 0x44, 0x45, 0x50, 0x4c, + 0x4f, 0x59, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, + 0x52, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x08, 0x1a, 0x02, 0x10, 0x01, 0x32, 0x4f, 0x0a, 0x05, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x46, 0x0a, 0x05, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x1b, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x37, 0x5a, + 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x73, 0x75, 0x72, + 0x75, 0x2f, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -981,8 +979,6 @@ func file_pkg_build_grpc_build_v1_build_service_proto_init() { (*BuildResponse_Output)(nil), (*BuildResponse_TsuruConfig)(nil), } - file_pkg_build_grpc_build_v1_build_service_proto_msgTypes[2].OneofWrappers = []any{} - file_pkg_build_grpc_build_v1_build_service_proto_msgTypes[3].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/build/grpc_build_v1/build_service.proto b/pkg/build/grpc_build_v1/build_service.proto index a6fb66e..1c66daa 100644 --- a/pkg/build/grpc_build_v1/build_service.proto +++ b/pkg/build/grpc_build_v1/build_service.proto @@ -92,7 +92,7 @@ message TsuruApp { map env_vars = 3; // Team is the Tsuru team name, optional just for compatibility with old tsuru-api versions. - optional string team = 4; + string team = 4; } message TsuruJob { @@ -102,7 +102,7 @@ message TsuruJob { map env_vars = 3; // Team is the Tsuru team name, optional just for compatibility with old tsuru-api versions. - optional string team = 4; + string team = 4; } message TsuruPlatform { diff --git a/pkg/build/grpc_build_v1/build_service_grpc.pb.go b/pkg/build/grpc_build_v1/build_service_grpc.pb.go index a263b57..fb5532a 100644 --- a/pkg/build/grpc_build_v1/build_service_grpc.pb.go +++ b/pkg/build/grpc_build_v1/build_service_grpc.pb.go @@ -1,3 +1,7 @@ +// Copyright 2024 tsuru authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0