Skip to content

Conversation

@ffjlabo
Copy link
Member

@ffjlabo ffjlabo commented Mar 9, 2022

What this PR does / why we need it:

Add rich version info for Cloud Run

Which issue(s) this PR fixes:

A part of #3303

Does this PR introduce a user-facing change?:

NONE

@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/cloudprovider/cloudrun/servicemanifest.go
--- pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go.orig
+++ pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go
@@ -19,11 +19,12 @@
 	"os"
 	"strings"
 
-	"github.com/pipe-cd/pipecd/pkg/model"
 	"google.golang.org/api/run/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime"
 	"sigs.k8s.io/yaml"
+
+	"github.com/pipe-cd/pipecd/pkg/model"
 )
 
 type ServiceManifest struct {
pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go
--- pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go.orig
+++ pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go
@@ -17,9 +17,10 @@
 import (
 	"testing"
 
-	"github.com/pipe-cd/pipecd/pkg/model"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
+
+	"github.com/pipe-cd/pipecd/pkg/model"
 )
 
 const serviceManifest = `

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersion -- 80.00% +80.00%

"os"
"strings"

"github.com/pipe-cd/pipecd/pkg/model"
Copy link
Member

@khanhtc1202 khanhtc1202 Mar 9, 2022

Choose a reason for hiding this comment

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

nits, lint error. Please refer to other files for importing conventions.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersion -- 80.00% +80.00%

Comment on lines 413 to 414
if tc.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, tc.want, got)
Copy link
Member

Choose a reason for hiding this comment

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

nits

Suggested change
if tc.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, tc.want, got)
assert.Equal(t, tc.wantErr, err != nil)
assert.Equal(t, tc.want, got)

Comment on lines 65 to 74
if av, e := p.determineArtifactVersion(ds.AppDir, cfg.Input.ServiceManifestFile); e == nil {
out.Versions = []*model.ArtifactVersion{av}
} else {
in.Logger.Warn("unable to determine target versions", zap.Error(e))
out.Versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
},
}
}

Copy link
Member

@knanao knanao Mar 9, 2022

Choose a reason for hiding this comment

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

nits

Suggested change
if av, e := p.determineArtifactVersion(ds.AppDir, cfg.Input.ServiceManifestFile); e == nil {
out.Versions = []*model.ArtifactVersion{av}
} else {
in.Logger.Warn("unable to determine target versions", zap.Error(e))
out.Versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
},
}
}
av, err := p.determineArtifactVersion(ds.AppDir, cfg.Input.ServiceManifestFile)
if err != nil {
in.Logger.Warn("unable to determine target versions", zap.Error(e))
av = &model.ArtifactVersion{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
}
}
out.Versions = []*model.ArtifactVersion{av}

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersion -- 80.00% +80.00%

@ffjlabo
Copy link
Member Author

ffjlabo commented Mar 9, 2022

Build & Test on github actions failed but it seems to be experimental.

@khanhtc1202
Copy link
Member

/rebase

@pipecd-bot
Copy link
Collaborator

REBASE

@khanhtc1202: Rebased this pull request in response to this comment.

@pipecd-bot pipecd-bot force-pushed the introduce_artifact_version_for_cloud_run branch from 171fc04 to 321c0a2 Compare March 9, 2022 06:07
return
}

func FindArtifactVersion(sm ServiceManifest) (*model.ArtifactVersion, error) {
Copy link
Member

Choose a reason for hiding this comment

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

To be unified let's how about returning a list of version.

Suggested change
func FindArtifactVersion(sm ServiceManifest) (*model.ArtifactVersion, error) {
func FindArtifactVersions(sm ServiceManifest) ([]model.ArtifactVersion, error) {

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds nice!
I did because Cloud Run can use only one image in one app.
So I'll fix to change returning a list of version and insert comment about that.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersion -- 80.00% +80.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersions -- 80.00% +80.00%

Comment on lines 65 to 75
versions, err := p.determineVersions(ds.AppDir, cfg.Input.ServiceManifestFile)
if err != nil {
in.Logger.Warn("unable to determine target versions", zap.Error(err))
versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
},
}
}
out.Versions = versions
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
versions, err := p.determineVersions(ds.AppDir, cfg.Input.ServiceManifestFile)
if err != nil {
in.Logger.Warn("unable to determine target versions", zap.Error(err))
versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
},
}
}
out.Versions = versions
out.Versions, err = p.determineVersions(ds.AppDir, cfg.Input.ServiceManifestFile)
if err != nil {
in.Logger.Warn("unable to determine target versions", zap.Error(err))
out.Versions = []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_UNKNOWN,
Version: "unknown",
},
}
}

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/cloudrun/servicemanifest.go FindArtifactVersions -- 80.00% +80.00%

@nghialv
Copy link
Member

nghialv commented Mar 9, 2022

Great. Thank you.
/lgtm

@pipecd-bot pipecd-bot added the lgtm label Mar 9, 2022
@khanhtc1202
Copy link
Member

Nice work
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

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.

6 participants