-
Notifications
You must be signed in to change notification settings - Fork 204
Determine artifact version for Cloud Run #3368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following files are not gofmt-ed. By commenting 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 = `
|
|
Code coverage for golang is
|
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/pipe-cd/pipecd/pkg/model" |
There was a problem hiding this comment.
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.
|
Code coverage for golang is
|
| if tc.wantErr { | ||
| require.Error(t, err) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| require.Equal(t, tc.want, got) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
| 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) |
| 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", | ||
| }, | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
| 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} | |
|
Code coverage for golang is
|
|
Build & Test on github actions failed but it seems to be experimental. |
|
/rebase |
|
@khanhtc1202: Rebased this pull request in response to this comment. |
171fc04 to
321c0a2
Compare
| return | ||
| } | ||
|
|
||
| func FindArtifactVersion(sm ServiceManifest) (*model.ArtifactVersion, error) { |
There was a problem hiding this comment.
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.
| func FindArtifactVersion(sm ServiceManifest) (*model.ArtifactVersion, error) { | |
| func FindArtifactVersions(sm ServiceManifest) ([]model.ArtifactVersion, error) { |
There was a problem hiding this comment.
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.
|
Code coverage for golang is
|
…:pipe-cd/pipecd into introduce_artifact_version_for_cloud_run
|
Code coverage for golang is
|
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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", | |
| }, | |
| } | |
| } |
|
Code coverage for golang is
|
|
Great. Thank you. |
|
Nice work |
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?: