Skip to content

Conversation

@khanhtc1202
Copy link
Member

@khanhtc1202 khanhtc1202 commented Jan 5, 2021

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

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.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

@khanhtc1202 khanhtc1202 marked this pull request as ready for review January 6, 2021 06:22
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

Comment on lines +317 to +327
// The Amazon Resource Name (ARN) of the function's execution role.
Role string `json:"role"`
// Path to the shared credentials file.
//
// Piped attempts to retrieve credentials in the following order:
// 1. from the environment variables. Available environment variables are:
// - AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY
// - AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY
// 2. from the given credentials file.
// 3. from the EC2 Instance Role
CredentialsFile string `json:"credentialsFile"`
Copy link
Member Author

@khanhtc1202 khanhtc1202 Jan 6, 2021

Choose a reason for hiding this comment

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

[rfc] not sure this Role configuration should be part of CloudProviderLambdaConfig or FunctionManifest. In my opinion, one lambda cloud provider should strict Role and CredentialsFile config at the same place (since they both for authorization purpose) 👀 What do you think? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

FunctionManifest means the configuration of kind: LambdaFunction in the config-repo?
If so, I think it should keep in the PiepdConfig as is because this should be configured by a Piped operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

FunctionManifest means the configuration of kind: LambdaFunction in the config-repo?

Yes, it is 👍

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

return FunctionManifest{}, err
}

imageURI, ok, err := unstructured.NestedString(obj.Object, "spec", "template", "spec", "image")
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why we should still use this unstructured package to parse the manifest.
We can parse it directly from the YAML by updating the manifest struct to be like

https://github.com/kubernetes/api/blob/master/apps/v1/types.go#L254-L262

Copy link
Member Author

Choose a reason for hiding this comment

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

In case of keep nested struct as the current sample function.yaml we need to define all sub struct to be able to unmarshal yaml content into FunctionManifest struct, I think it the cons 😅
Should we simplify the current LambdaFunction manifest 👀

apiVersion: pipecd.dev/v1beta1
kind: LambdaFunction
metadata:
  name: SimpleFunction
spec:
  template:
    metadata:
      tags:
        app: simple
    spec:
      image: ecr.ap-northeast-1.amazonaws.com/lambda-test:v0.0.1

Copy link
Member

@nghialv nghialv Jan 6, 2021

Choose a reason for hiding this comment

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

Yes. I think we can simplify it. (Just follow our convention in the config package, not Kubernetes')

apiVersion: pipecd.dev/v1beta1
kind: LambdaFunction
spec:
   name: SimpleFunction
   image: ecr.ap-northeast-1.amazonaws.com/lambda-test:v0.0.1
   tags:
        app: simple

Copy link
Member Author

Choose a reason for hiding this comment

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

got it, thank you 👍

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.

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.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 34.01%. This pull request does not change code coverage.


const (
versionV1Beta1 = "pipecd.dev/v1beta1"
FunctionManifestKind = "LambdaFunction"
Copy link
Member

Choose a reason for hiding this comment

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

nit: Do we need to expose this variable?

return nil
}

func loadFunctionManifest(path string) (FunctionManifest, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some tests for this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry I forgot to commit that 🙏 actually, I wrote tests for the parseFunctionManifest instead 👀

@pipecd-bot pipecd-bot added size/XL and removed size/L labels Jan 6, 2021
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.85%. This pull request decreases coverage by -0.16%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go newClient -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.Apply -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/function.go FunctionManifest.validate -- 71.43% +71.43%
pkg/app/piped/cloudprovider/lambda/function.go FunctionManifestSpec.validate -- 80.00% +80.00%
pkg/app/piped/cloudprovider/lambda/function.go loadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/function.go parseFunctionManifest -- 83.33% +83.33%
pkg/app/piped/cloudprovider/lambda/function.go DecideRevisionName -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/function.go FindImageTag -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/function.go parseContainerImage -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/lambda.go LoadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/lambda.go registry.Client -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/lambda.go DefaultRegistry -- 0.00% +0.00%

// FunctionManifestSpec contains configuration for LambdaFunction.
type FunctionManifestSpec struct {
Name string `json:"name"`
ImageURI string `json:"image"`
Copy link
Member

Choose a reason for hiding this comment

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

It may be more appropriate to replace it with ImageRef that clearly represents a specific image that has a unique digest. But it's up to you.

Copy link
Member Author

@khanhtc1202 khanhtc1202 Jan 7, 2021

Choose a reason for hiding this comment

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

I think that name may confuse ( overlap with #1358 ImageRef struct ), besides this name specific exactly what I want to be given from here ( the URI to image on ecr registry ) so I think it's good for me 😅

Copy link
Member

Choose a reason for hiding this comment

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

Okay, no objection to that 👍

@nakabonne
Copy link
Member

/lgtm

@pipecd-bot pipecd-bot added the lgtm label Jan 7, 2021
@nghialv
Copy link
Member

nghialv commented Jan 7, 2021

/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.

@pipecd-bot pipecd-bot merged commit 3f3c888 into master Jan 7, 2021
@pipecd-bot pipecd-bot deleted the lambda-cloud-provider branch January 7, 2021 03:15
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.

5 participants