Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/pipectl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_library(
deps = [
"//pkg/app/pipectl/cmd/application:go_default_library",
"//pkg/app/pipectl/cmd/deployment:go_default_library",
"//pkg/app/pipectl/cmd/image:go_default_library",
"//pkg/cli:go_default_library",
],
)
Expand Down
2 changes: 2 additions & 0 deletions cmd/pipectl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/pipe-cd/pipe/pkg/app/pipectl/cmd/application"
"github.com/pipe-cd/pipe/pkg/app/pipectl/cmd/deployment"
"github.com/pipe-cd/pipe/pkg/app/pipectl/cmd/image"
"github.com/pipe-cd/pipe/pkg/cli"
)

Expand All @@ -32,6 +33,7 @@ func main() {
app.AddCommands(
application.NewCommand(),
deployment.NewCommand(),
image.NewCommand(),
)

if err := app.Run(); err != nil {
Expand Down
14 changes: 13 additions & 1 deletion docs/content/en/docs/user-guide/command-line-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You can use pipectl to add and sync applications, wait for a deployment status.
1. Download the appropriate version for your platform from [PipeCD Releases](https://github.com/pipe-cd/pipe/releases).

We recommend using the latest version of pipectl to avoid unforeseen issues.
Please set `${VERSION}` to the same format like `v0.9.2`.
Please set `${VERSION}` to the same format like `v0.9.4`.

``` console
curl -Lo ./pipectl https://github.com/pipe-cd/pipe/releases/download/${VERSION}/pipectl_${VERSION}_darwin_amd64
Expand Down Expand Up @@ -186,6 +186,18 @@ pipectl deployment wait-status \
--status=DEPLOYMENT_SUCCESS
```

### Pushing an image reference

Push a new container image reference that can be used by ImageWatcher.

``` console
pipectl image push-reference \
--address=CONTROL_PLANE_API_ADDRESS \
--api-key=API_KEY \
--repo-name=gcr.io/pipecd/example \
--tag=v0.1.0
```

### You want more?

We always want to add more needed commands into pipectl. Please let us know what command do you want to add by creating issues in the [pipe-cd/pipe ](https://github.com/pipe-cd/pipe/issues) repository. We also welcome your pull request to add the command.
17 changes: 17 additions & 0 deletions pkg/app/pipectl/cmd/image/BUILD.bazel
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",
],
)
43 changes: 43 additions & 0 deletions pkg/app/pipectl/cmd/image/image.go
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
}
74 changes: 74 additions & 0 deletions pkg/app/pipectl/cmd/image/pushreference.go
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
}
4 changes: 2 additions & 2 deletions pkg/app/piped/cloudprovider/lambda/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member

Choose a reason for hiding this comment

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

nit: I couldn't figure out why does this file be changed 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

make gazelle does it. Basically, It adds missing ones and orders them in its convention.

Copy link
Member

Choose a reason for hiding this comment

The 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",
],
Expand Down