-
Notifications
You must be signed in to change notification settings - Fork 208
Add pipectl command to push image reference #1366
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
|
||
| go_library( | ||
| name = "go_default_library", | ||
| srcs = [ | ||
| "image.go", | ||
| "pushreference.go", | ||
| ], | ||
| importpath = "github.com/pipe-cd/pipe/pkg/app/pipectl/cmd/image", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//pkg/app/api/service/apiservice:go_default_library", | ||
| "//pkg/app/pipectl/client:go_default_library", | ||
| "//pkg/cli:go_default_library", | ||
| "@com_github_spf13_cobra//:go_default_library", | ||
| ], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright 2021 The PipeCD Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package image | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/pipe-cd/pipe/pkg/app/pipectl/client" | ||
| ) | ||
|
|
||
| type command struct { | ||
| clientOptions *client.Options | ||
| } | ||
|
|
||
| func NewCommand() *cobra.Command { | ||
| c := &command{ | ||
| clientOptions: &client.Options{}, | ||
| } | ||
| cmd := &cobra.Command{ | ||
| Use: "image", | ||
| Short: "Manage image resources.", | ||
| } | ||
|
|
||
| cmd.AddCommand( | ||
| newPushReferenceCommand(c), | ||
| ) | ||
|
|
||
| c.clientOptions.RegisterPersistentFlags(cmd) | ||
|
|
||
| return cmd | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright 2021 The PipeCD Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package image | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/pipe-cd/pipe/pkg/app/api/service/apiservice" | ||
| "github.com/pipe-cd/pipe/pkg/cli" | ||
| ) | ||
|
|
||
| type pushReference struct { | ||
| root *command | ||
|
|
||
| repoName string | ||
| tags []string | ||
| digest string | ||
| } | ||
|
|
||
| func newPushReferenceCommand(root *command) *cobra.Command { | ||
| c := &pushReference{ | ||
| root: root, | ||
| } | ||
| cmd := &cobra.Command{ | ||
| Use: "push-reference", | ||
| Short: "Push a container image reference.", | ||
| RunE: cli.WithContext(c.run), | ||
| } | ||
|
|
||
| cmd.Flags().StringVar(&c.repoName, "repo-name", c.repoName, "The repository name of container image. e.g. gcr.io/pipecd/pipecd, envoyproxy/envoy-alpine...") | ||
| cmd.Flags().StringSliceVar(&c.tags, "tag", c.tags, "The image tag; Can be used multiple times to set multiple tags.") | ||
| cmd.Flags().StringVar(&c.digest, "digest", c.digest, "The image digest.") | ||
|
|
||
| cmd.MarkFlagRequired("repo-name") | ||
| cmd.MarkFlagRequired("tag") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| func (c *pushReference) run(ctx context.Context, t cli.Telemetry) error { | ||
| cli, err := c.root.clientOptions.NewClient(ctx) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to initialize client: %w", err) | ||
| } | ||
| defer cli.Close() | ||
|
|
||
| req := &apiservice.PushImageReferenceRequest{ | ||
| RepoName: c.repoName, | ||
| Tags: c.tags, | ||
| Digest: c.digest, | ||
| } | ||
|
|
||
| if _, err := cli.PushImageReference(ctx, req); err != nil { | ||
| return fmt.Errorf("failed to push image reference: %w", err) | ||
| } | ||
|
|
||
| t.Logger.Info("Successfully pushed image reference") | ||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,21 +4,21 @@ go_library( | |
| name = "go_default_library", | ||
| srcs = [ | ||
| "client.go", | ||
| "lambda.go", | ||
| "function.go", | ||
| "lambda.go", | ||
| ], | ||
| importpath = "github.com/pipe-cd/pipe/pkg/app/piped/cloudprovider/lambda", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//pkg/config:go_default_library", | ||
| "@io_k8s_sigs_yaml//:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws/awserr:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws/credentials:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws/credentials/ec2rolecreds:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws/ec2metadata:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//aws/session:go_default_library", | ||
| "@com_github_aws_aws_sdk_go//service/lambda:go_default_library", | ||
| "@io_k8s_sigs_yaml//:go_default_library", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I couldn't figure out why does this file be changed 😂
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, thank you 👍 |
||
| "@org_golang_x_sync//singleflight:go_default_library", | ||
| "@org_uber_go_zap//:go_default_library", | ||
| ], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.