Skip to content

Conversation

@ffjlabo
Copy link
Member

@ffjlabo ffjlabo commented Mar 4, 2022

What this PR does / why we need it:

Add rich version info to KubernetesApp Deployment

Which issue(s) this PR fixes:

A part of #3303

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.44%. This pull request increases coverage by 0.06%.

File Function Base Head Diff
pkg/app/piped/planner/kubernetes/kubernetes.go determineVersions -- 88.24% +88.24%
pkg/app/piped/planner/kubernetes/kubernetes.go Planner.Plan 0.00% 0.00% +0.00%

in.Logger.Error("unable to determine versions", zap.Error(e))
out.Versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_CONTAINER_IMAGE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We can use this kind

Comment on lines 496 to 497
// determineVersions decide artifact versions of an application.
// For example, in case some containers are used in one application, those image version are retured
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// determineVersions decide artifact versions of an application.
// For example, in case some containers are used in one application, those image version are retured
// determineVersions decides artifact versions of an application.
// It finds all container images that are being specified in the workload manifests then returns their names, version numbers, and urls.

Comment on lines 501 to 521
for _, m := range manifests {
if !m.Key.IsDeployment() {
continue
}
data, err := m.MarshalJSON()
if err != nil {
return nil, err
}
var d resource.Deployment
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}

containers := d.Spec.Template.Spec.Containers
for _, c := range containers {
image := parseContainerImage(c.Image)
versions = append(versions, &model.ArtifactVersion{
Kind: model.ArtifactVersion_CONTAINER_IMAGE,
Version: image.tag,
Name: image.name,
Url: c.Image,
})
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same container images could be used in multiple manifests so I think we have to remove the duplicate ones.

@nghialv
Copy link
Member

nghialv commented Mar 4, 2022

@ffjlabo Great work! Love to see this.

I have just left some comments. Please check them.

Comment on lines 151 to 161
message ArtifactVersion {
enum Kind {
UNKNOWN = 0;
CONTAINER_IMAGE = 1;
}

Kind kind = 1 [(validate.rules).enum.defined_only = true];
string version = 2 [(validate.rules).string.min_len = 1];
string name = 3;
string url = 4;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use it in both application and deployment proto, should we move it to common.proto?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds nice! I'll fix it

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/planner/kubernetes/kubernetes.go
--- pkg/app/piped/planner/kubernetes/kubernetes.go.orig
+++ pkg/app/piped/planner/kubernetes/kubernetes.go
@@ -519,7 +519,7 @@
 		}
 	}
 
-	for i, _ := range imageMap {
+	for i := range imageMap {
 		image := parseContainerImage(i)
 		versions = append(versions, &model.ArtifactVersion{
 			Kind:    model.ArtifactVersion_CONTAINER_IMAGE,

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GO_LINTER

Some issues were detected while linting go source files in your changes.

}
}

for i, _ := range imageMap {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should omit 2nd value from range; this loop is equivalent to for i := range ...

Suggested change
for i, _ := range imageMap {
for i := range imageMap {

@ffjlabo
Copy link
Member Author

ffjlabo commented Mar 4, 2022

/golinter fmt

@pipecd-bot
Copy link
Collaborator

GO_LINTER

Unabled to format the unfmt-ed files. In response to this comment.

string version = 4;
string config_filename = 5;
repeated ArtifactVersion versions = 6;
repeated model.ArtifactVersion versions = 6;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
repeated model.ArtifactVersion versions = 6;
repeated ArtifactVersion versions = 6;

// It finds all container images that are being specified in the workload manifests then returns their names, version numbers, and urls.
func determineVersions(manifests []provider.Manifest) ([]*model.ArtifactVersion, error) {
versions := []*model.ArtifactVersion{}
imageMap := map[string]string{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have smaller size.

Suggested change
imageMap := map[string]string{}
imageMap := map[string]struct{}{}

containers := d.Spec.Template.Spec.Containers
// remove duplicate images on multiple manifests
for _, c := range containers {
imageMap[c.Image] = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
imageMap[c.Image] = ""
imageMap[c.Image] = struct{}

Comment on lines 532 to 539
if len(versions) == 0 {
return []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: versionUnknown,
},
}, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this part. An empty list is fine. It means that this application is not having any artifact version.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.45%. This pull request increases coverage by 0.06%.

File Function Base Head Diff
pkg/app/piped/planner/kubernetes/kubernetes.go determineVersions -- 88.89% +88.89%
pkg/app/piped/planner/kubernetes/kubernetes.go Planner.Plan 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for javascript is 78.09%. This pull request increases coverage by 0.03%.

File Base Head Diff
src/modules/commands/index.ts 90.62% 93.75% +3.12%

@ffjlabo ffjlabo force-pushed the add_artifact_versions_to_deployment branch from 9fbbd4e to 0930876 Compare March 4, 2022 10:13
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.45%. This pull request increases coverage by 0.06%.

File Function Base Head Diff
pkg/app/piped/planner/kubernetes/kubernetes.go determineVersions -- 88.89% +88.89%
pkg/app/piped/planner/kubernetes/kubernetes.go Planner.Plan 0.00% 0.00% +0.00%

// e.g. Update image from v1.5.0 to v1.6.0.
string summary = 22;
string version = 23;
repeated ArtifactVersion versions = 103;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
repeated ArtifactVersion versions = 103;
repeated ArtifactVersion versions = 24;

Comment on lines 499 to 522
versions := []*model.ArtifactVersion{}
imageMap := map[string]struct{}{}

for _, m := range manifests {
// TODO: Determine container image version from other workload kinds such as StatefulSet, Pod, Daemon, CronJob...
if !m.Key.IsDeployment() {
continue
}
data, err := m.MarshalJSON()
if err != nil {
return nil, err
}
var d resource.Deployment
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}

containers := d.Spec.Template.Spec.Containers
// remove duplicate images on multiple manifests
for _, c := range containers {
imageMap[c.Image] = struct{}{}
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move initialization versions slice to later to know its size.

Suggested change
versions := []*model.ArtifactVersion{}
imageMap := map[string]struct{}{}
for _, m := range manifests {
// TODO: Determine container image version from other workload kinds such as StatefulSet, Pod, Daemon, CronJob...
if !m.Key.IsDeployment() {
continue
}
data, err := m.MarshalJSON()
if err != nil {
return nil, err
}
var d resource.Deployment
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
containers := d.Spec.Template.Spec.Containers
// remove duplicate images on multiple manifests
for _, c := range containers {
imageMap[c.Image] = struct{}{}
}
}
imageMap := map[string]struct{}{}
for _, m := range manifests {
// TODO: Determine container image version from other workload kinds such as StatefulSet, Pod, Daemon, CronJob...
if !m.Key.IsDeployment() {
continue
}
data, err := m.MarshalJSON()
if err != nil {
return nil, err
}
var d resource.Deployment
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
containers := d.Spec.Template.Spec.Containers
// remove duplicate images on multiple manifests
for _, c := range containers {
imageMap[c.Image] = struct{}{}
}
}
versions := make([]*model.ArtifactVersion, 0, len(imageMap))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for suggestion!

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for javascript is 78.07%. This pull request decreases coverage by -0.03%.

File Base Head Diff
src/modules/commands/index.ts 93.75% 90.62% -3.12%

@nghialv
Copy link
Member

nghialv commented Mar 4, 2022

Look beautiful.
Just 2 nits.

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/helloworld/service/service_grpc.pb.go
--- pkg/app/helloworld/service/service_grpc.pb.go.orig
+++ pkg/app/helloworld/service/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/app/server/service/pipedservice/service_grpc.pb.go
--- pkg/app/server/service/pipedservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/pipedservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/apikey.pb.go
--- pkg/model/apikey.pb.go.orig
+++ pkg/model/apikey.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/common.pb.go
--- pkg/model/common.pb.go.orig
+++ pkg/model/common.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/notificationevent.pb.go
--- pkg/model/notificationevent.pb.go.orig
+++ pkg/model/notificationevent.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/piped_stat.pb.go
--- pkg/model/piped_stat.pb.go.orig
+++ pkg/model/piped_stat.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/user.pb.go
--- pkg/model/user.pb.go.orig
+++ pkg/model/user.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/server/service/apiservice/service_grpc.pb.go
--- pkg/app/server/service/apiservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/apiservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/application.pb.go
--- pkg/model/application.pb.go.orig
+++ pkg/model/application.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/command.pb.go
--- pkg/model/command.pb.go.orig
+++ pkg/model/command.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/planpreview.pb.go
--- pkg/model/planpreview.pb.go.orig
+++ pkg/model/planpreview.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/logblock.pb.go
--- pkg/model/logblock.pb.go.orig
+++ pkg/model/logblock.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/server/service/apiservice/service.pb.go
--- pkg/app/server/service/apiservice/service.pb.go.orig
+++ pkg/app/server/service/apiservice/service.pb.go
@@ -21,12 +21,14 @@
 package apiservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/app/server/service/pipedservice/service.pb.go
--- pkg/app/server/service/pipedservice/service.pb.go.orig
+++ pkg/app/server/service/pipedservice/service.pb.go
@@ -21,12 +21,14 @@
 package pipedservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/app/server/service/webservice/service.pb.go
--- pkg/app/server/service/webservice/service.pb.go.orig
+++ pkg/app/server/service/webservice/service.pb.go
@@ -21,13 +21,15 @@
 package webservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/app/server/service/webservice/service_grpc.pb.go
--- pkg/app/server/service/webservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/webservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/analysis_result.pb.go
--- pkg/model/analysis_result.pb.go.orig
+++ pkg/model/analysis_result.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/deployment.pb.go
--- pkg/model/deployment.pb.go.orig
+++ pkg/model/deployment.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/deployment_chain.pb.go
--- pkg/model/deployment_chain.pb.go.orig
+++ pkg/model/deployment_chain.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/piped.pb.go
--- pkg/model/piped.pb.go.orig
+++ pkg/model/piped.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/project.pb.go
--- pkg/model/project.pb.go.orig
+++ pkg/model/project.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/helloworld/service/service.pb.go
--- pkg/app/helloworld/service/service.pb.go.orig
+++ pkg/app/helloworld/service/service.pb.go
@@ -21,11 +21,12 @@
 package service
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/application_live_state.pb.go
--- pkg/model/application_live_state.pb.go.orig
+++ pkg/model/application_live_state.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/event.pb.go
--- pkg/model/event.pb.go.orig
+++ pkg/model/event.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/insight.pb.go
--- pkg/model/insight.pb.go.orig
+++ pkg/model/insight.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/role.pb.go
--- pkg/model/role.pb.go.orig
+++ pkg/model/role.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	descriptorpb "google.golang.org/protobuf/types/descriptorpb"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (

}

containers := d.Spec.Template.Spec.Containers
// remove duplicate images on multiple manifests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// remove duplicate images on multiple manifests
// Remove duplicate images on multiple manifests.

As our convention, comments start with a capital character and finish with a dot.

// e.g. Scale from 10 to 100 replicas.
// e.g. Update image from v1.5.0 to v1.6.0.
string summary = 22;
string version = 23;
Copy link
Member

@khanhtc1202 khanhtc1202 Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really related to this PR but please add a TODO to remind removing this version from the deployment object later

TODO: Remove version from deployment model.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for javascript is 78.09%. This pull request does not change code coverage.

@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Determine container image version from other workload kinds such as StatefulSet, Pod, Daemon, CronJob...

// TODO: Determine container image version from other workload kinds such as StatefulSet, Pod, Daemon, CronJob...
if !m.Key.IsDeployment() {
continue
}

This was created by todo plugin since "TODO:" was found in c23e18a when #3340 was merged. cc: @ffjlabo.

2. Remove version from deployment model.

// TODO: Remove version from deployment model.
string version = 23;
repeated ArtifactVersion versions = 24;

This was created by todo plugin since "TODO:" was found in c23e18a when #3340 was merged. cc: @ffjlabo.

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/server/service/apiservice/service.pb.go
--- pkg/app/server/service/apiservice/service.pb.go.orig
+++ pkg/app/server/service/apiservice/service.pb.go
@@ -21,12 +21,14 @@
 package apiservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/app/server/service/webservice/service_grpc.pb.go
--- pkg/app/server/service/webservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/webservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/deployment.pb.go
--- pkg/model/deployment.pb.go.orig
+++ pkg/model/deployment.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/deployment_chain.pb.go
--- pkg/model/deployment_chain.pb.go.orig
+++ pkg/model/deployment_chain.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/helloworld/service/service_grpc.pb.go
--- pkg/app/helloworld/service/service_grpc.pb.go.orig
+++ pkg/app/helloworld/service/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/application.pb.go
--- pkg/model/application.pb.go.orig
+++ pkg/model/application.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/event.pb.go
--- pkg/model/event.pb.go.orig
+++ pkg/model/event.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/logblock.pb.go
--- pkg/model/logblock.pb.go.orig
+++ pkg/model/logblock.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/server/service/apiservice/service_grpc.pb.go
--- pkg/app/server/service/apiservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/apiservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/app/server/service/pipedservice/service.pb.go
--- pkg/app/server/service/pipedservice/service.pb.go.orig
+++ pkg/app/server/service/pipedservice/service.pb.go
@@ -21,12 +21,14 @@
 package pipedservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/model/analysis_result.pb.go
--- pkg/model/analysis_result.pb.go.orig
+++ pkg/model/analysis_result.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/apikey.pb.go
--- pkg/model/apikey.pb.go.orig
+++ pkg/model/apikey.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/command.pb.go
--- pkg/model/command.pb.go.orig
+++ pkg/model/command.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/insight.pb.go
--- pkg/model/insight.pb.go.orig
+++ pkg/model/insight.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/piped.pb.go
--- pkg/model/piped.pb.go.orig
+++ pkg/model/piped.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/planpreview.pb.go
--- pkg/model/planpreview.pb.go.orig
+++ pkg/model/planpreview.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/helloworld/service/service.pb.go
--- pkg/app/helloworld/service/service.pb.go.orig
+++ pkg/app/helloworld/service/service.pb.go
@@ -21,11 +21,12 @@
 package service
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/server/service/webservice/service.pb.go
--- pkg/app/server/service/webservice/service.pb.go.orig
+++ pkg/app/server/service/webservice/service.pb.go
@@ -21,13 +21,15 @@
 package webservice
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
-	model "github.com/pipe-cd/pipecd/pkg/model"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
-	reflect "reflect"
-	sync "sync"
+
+	model "github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const (
pkg/model/application_live_state.pb.go
--- pkg/model/application_live_state.pb.go.orig
+++ pkg/model/application_live_state.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/common.pb.go
--- pkg/model/common.pb.go.orig
+++ pkg/model/common.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/notificationevent.pb.go
--- pkg/model/notificationevent.pb.go.orig
+++ pkg/model/notificationevent.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/piped_stat.pb.go
--- pkg/model/piped_stat.pb.go.orig
+++ pkg/model/piped_stat.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/project.pb.go
--- pkg/model/project.pb.go.orig
+++ pkg/model/project.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/model/role.pb.go
--- pkg/model/role.pb.go.orig
+++ pkg/model/role.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	descriptorpb "google.golang.org/protobuf/types/descriptorpb"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
pkg/app/server/service/pipedservice/service_grpc.pb.go
--- pkg/app/server/service/pipedservice/service_grpc.pb.go.orig
+++ pkg/app/server/service/pipedservice/service_grpc.pb.go
@@ -4,6 +4,7 @@
 
 import (
 	context "context"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
pkg/model/user.pb.go
--- pkg/model/user.pb.go.orig
+++ pkg/model/user.pb.go
@@ -21,11 +21,12 @@
 package model
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	_ "github.com/envoyproxy/protoc-gen-validate/validate"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.45%. This pull request increases coverage by 0.06%.

File Function Base Head Diff
pkg/app/piped/planner/kubernetes/kubernetes.go determineVersions -- 88.89% +88.89%
pkg/app/piped/planner/kubernetes/kubernetes.go Planner.Plan 0.00% 0.00% +0.00%

@khanhtc1202
Copy link
Member

Nice 👍
/lgtm

@pipecd-bot pipecd-bot added the lgtm label Mar 4, 2022
@nghialv
Copy link
Member

nghialv commented Mar 4, 2022

Great work.
/lgtm

@nghialv
Copy link
Member

nghialv commented Mar 4, 2022

/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nghialv.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants