Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions cmd/docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package main

import (
"io/ioutil"
"io"
"log"
"os"

Expand All @@ -14,7 +14,7 @@ import (
)

func main() {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)

cmd := rootcommand.GetRootCommand()

Expand Down
4 changes: 2 additions & 2 deletions cmd/kp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
package main

import (
"io/ioutil"
"io"
"log"
"os"

"github.com/vmware-tanzu/kpack-cli/pkg/rootcommand"
)

func main() {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)

cmd := rootcommand.GetRootCommand()
err := cmd.Execute()
Expand Down
61 changes: 32 additions & 29 deletions docs/kp_image_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The flags for this command determine how the build will retrieve source code:
"--local-path" to use source code from the local machine

Local source code will be pushed to the same registry provided for the image resource tag.
--local-path-destination-image can be used to specify the repository of the source code image.
If not specified, the source code image will be pushed to the <image-tag-repo>-source repo.
Therefore, you must have credentials to access the registry on your machine.
--registry-ca-cert-path and --registry-verify-certs are only used for local source type.

Expand Down Expand Up @@ -47,35 +49,36 @@ kp image create my-image --tag my-registry.com/my-repo --blob https://my-blob-ho
### Options

```
--additional-tag stringArray additional tags to push the OCI image to
--blob string source code blob url
-b, --builder string builder name
--cache-size string cache size as a kubernetes quantity (default "2G")
-c, --cluster-builder string cluster builder name
--dry-run perform validation with no side-effects; no objects are sent to the server.
The --dry-run flag can be used in combination with the --output flag to
view the Kubernetes resource(s) without sending anything to the server.
--dry-run-with-image-upload similar to --dry-run, but with container image uploads allowed.
This flag is provided as a convenience for kp commands that can output Kubernetes
resource with generated container image references. A "kubectl apply -f" of the
resource from --output without image uploads will result in a reconcile failure.
-e, --env stringArray build time environment variables
--git string git repository url
--git-revision string git revision such as commit, tag, or branch (default "main")
-h, --help help for create
--local-path string path to local source code
-n, --namespace string kubernetes namespace
--output string print Kubernetes resources in the specified format; supported formats are: yaml, json.
The output can be used with the "kubectl apply -f" command. To allow this, the command
updates are redirected to stderr and only the Kubernetes resource(s) are written to stdout.
The APIVersion of the outputted resources will always be the latest APIVersion known to kp (currently: v1alpha2).
--registry-ca-cert-path string add CA certificate for registry API (format: /tmp/ca.crt)
--registry-verify-certs set whether to verify server's certificate chain and host name (default true)
--service-account string service account name to use (default "default")
-s, --service-binding stringArray build time service bindings
--sub-path string build code at the sub path located within the source code directory
-t, --tag string registry location where the OCI image will be created
-w, --wait wait for image create to be reconciled and tail resulting build logs
--additional-tag stringArray additional tags to push the OCI image to
--blob string source code blob url
-b, --builder string builder name
--cache-size string cache size as a kubernetes quantity (default "2G")
-c, --cluster-builder string cluster builder name
--dry-run perform validation with no side-effects; no objects are sent to the server.
The --dry-run flag can be used in combination with the --output flag to
view the Kubernetes resource(s) without sending anything to the server.
--dry-run-with-image-upload similar to --dry-run, but with container image uploads allowed.
This flag is provided as a convenience for kp commands that can output Kubernetes
resource with generated container image references. A "kubectl apply -f" of the
resource from --output without image uploads will result in a reconcile failure.
-e, --env stringArray build time environment variables
--git string git repository url
--git-revision string git revision such as commit, tag, or branch (default "main")
-h, --help help for create
--local-path string path to local source code
--local-path-destination-image string registry location of local source image
-n, --namespace string kubernetes namespace
--output string print Kubernetes resources in the specified format; supported formats are: yaml, json.
The output can be used with the "kubectl apply -f" command. To allow this, the command
updates are redirected to stderr and only the Kubernetes resource(s) are written to stdout.
The APIVersion of the outputted resources will always be the latest APIVersion known to kp (currently: v1alpha2).
--registry-ca-cert-path string add CA certificate for registry API (format: /tmp/ca.crt)
--registry-verify-certs set whether to verify server's certificate chain and host name (default true)
--service-account string service account name to use (default "default")
-s, --service-binding stringArray build time service bindings
--sub-path string build code at the sub path located within the source code directory
-t, --tag string registry location where the OCI image will be created
-w, --wait wait for image create to be reconciled and tail resulting build logs
```

### SEE ALSO
Expand Down
67 changes: 35 additions & 32 deletions docs/kp_image_save.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The flags for this command determine how the build will retrieve source code:
"--local-path" to use source code from the local machine

Local source code will be pushed to the same registry provided for the image resource tag.
--local-path-destination-image can be used to specify the repository of the source code image.
If not specified, the source code image will be pushed to the <image-tag-repo>-source repo.
Therefore, you must have credentials to access the registry on your machine.

Environment variables may be provided by using the "--env" flag or deleted by using the "--delete-env" flag.
Expand Down Expand Up @@ -50,38 +52,39 @@ kp image save my-image --tag my-registry.com/my-repo --blob https://my-blob-host
### Options

```
--additional-tag stringArray additional tags to push the OCI image to
--blob string source code blob url
-b, --builder string builder name
--cache-size string cache size as a kubernetes quantity (default "2G")
-c, --cluster-builder string cluster builder name
--delete-additional-tag stringArray additional tags to remove
-d, --delete-env stringArray build time environment variables to remove
--delete-service-binding stringArray build time service bindings to remove
--dry-run perform validation with no side-effects; no objects are sent to the server.
The --dry-run flag can be used in combination with the --output flag to
view the Kubernetes resource(s) without sending anything to the server.
--dry-run-with-image-upload similar to --dry-run, but with container image uploads allowed.
This flag is provided as a convenience for kp commands that can output Kubernetes
resource with generated container image references. A "kubectl apply -f" of the
resource from --output without image uploads will result in a reconcile failure.
-e, --env stringArray build time environment variables
--git string git repository url
--git-revision string git revision such as commit, tag, or branch (default "main")
-h, --help help for save
--local-path string path to local source code
-n, --namespace string kubernetes namespace
--output string print Kubernetes resources in the specified format; supported formats are: yaml, json.
The output can be used with the "kubectl apply -f" command. To allow this, the command
updates are redirected to stderr and only the Kubernetes resource(s) are written to stdout.
The APIVersion of the outputted resources will always be the latest APIVersion known to kp (currently: v1alpha2).
--registry-ca-cert-path string add CA certificate for registry API (format: /tmp/ca.crt)
--registry-verify-certs set whether to verify server's certificate chain and host name (default true)
--service-account string service account name to use
-s, --service-binding stringArray build time service bindings to add/replace
--sub-path string build code at the sub path located within the source code directory
-t, --tag string registry location where the image will be created
-w, --wait wait for image create to be reconciled and tail resulting build logs
--additional-tag stringArray additional tags to push the OCI image to
--blob string source code blob url
-b, --builder string builder name
--cache-size string cache size as a kubernetes quantity (default "2G")
-c, --cluster-builder string cluster builder name
--delete-additional-tag stringArray additional tags to remove
-d, --delete-env stringArray build time environment variables to remove
--delete-service-binding stringArray build time service bindings to remove
--dry-run perform validation with no side-effects; no objects are sent to the server.
The --dry-run flag can be used in combination with the --output flag to
view the Kubernetes resource(s) without sending anything to the server.
--dry-run-with-image-upload similar to --dry-run, but with container image uploads allowed.
This flag is provided as a convenience for kp commands that can output Kubernetes
resource with generated container image references. A "kubectl apply -f" of the
resource from --output without image uploads will result in a reconcile failure.
-e, --env stringArray build time environment variables
--git string git repository url
--git-revision string git revision such as commit, tag, or branch (default "main")
-h, --help help for save
--local-path string path to local source code
--local-path-destination-image string registry location of source image
-n, --namespace string kubernetes namespace
--output string print Kubernetes resources in the specified format; supported formats are: yaml, json.
The output can be used with the "kubectl apply -f" command. To allow this, the command
updates are redirected to stderr and only the Kubernetes resource(s) are written to stdout.
The APIVersion of the outputted resources will always be the latest APIVersion known to kp (currently: v1alpha2).
--registry-ca-cert-path string add CA certificate for registry API (format: /tmp/ca.crt)
--registry-verify-certs set whether to verify server's certificate chain and host name (default true)
--service-account string service account name to use
-s, --service-binding stringArray build time service bindings to add/replace
--sub-path string build code at the sub path located within the source code directory
-t, --tag string registry location where the image will be created
-w, --wait wait for image create to be reconciled and tail resulting build logs
```

### SEE ALSO
Expand Down
3 changes: 3 additions & 0 deletions pkg/commands/image/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The flags for this command determine how the build will retrieve source code:
"--local-path" to use source code from the local machine

Local source code will be pushed to the same registry provided for the image resource tag.
--local-path-destination-image can be used to specify the repository of the source code image.
If not specified, the source code image will be pushed to the <image-tag-repo>-source repo.
Therefore, you must have credentials to access the registry on your machine.
--registry-ca-cert-path and --registry-verify-certs are only used for local source type.

Expand Down Expand Up @@ -99,6 +101,7 @@ kp image create my-image --tag my-registry.com/my-repo --blob https://my-blob-ho
cmd.Flags().StringVar(&factory.GitRevision, "git-revision", "", "git revision such as commit, tag, or branch (default \"main\")")
cmd.Flags().StringVar(&factory.Blob, "blob", "", "source code blob url")
cmd.Flags().StringVar(&factory.LocalPath, "local-path", "", "path to local source code")
cmd.Flags().StringVar(&factory.LocalPathDestinationImage, "local-path-destination-image", "", "registry location of local source image")
Comment thread
chenbh marked this conversation as resolved.
Outdated
cmd.Flags().StringVar(&subPath, "sub-path", "", "build code at the sub path located within the source code directory")
cmd.Flags().StringVarP(&factory.Builder, "builder", "b", "", "builder name")
cmd.Flags().StringVarP(&factory.ClusterBuilder, "cluster-builder", "c", "", "cluster builder name")
Expand Down
19 changes: 9 additions & 10 deletions pkg/commands/image/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,8 @@ status: {}
})
})

when("cache size is not provided", func() {
it("does not set an empty field on the image", func() {
//note: this is to allow for defaults to be set by kpack webhook

when("local-source and local—path-destination-image is provided", func() {
it("sets the repository source path on the image", func() {
Comment thread
chenbh marked this conversation as resolved.
Outdated
expectedImage := &v1alpha2.Image{
TypeMeta: metav1.TypeMeta{
Kind: "Image",
Expand All @@ -923,9 +921,8 @@ status: {}
},
ServiceAccountName: "default",
Source: corev1alpha1.SourceConfig{
Git: &corev1alpha1.Git{
URL: "some-git-url",
Revision: "some-git-rev",
Registry: &corev1alpha1.Registry{
Image: "some-registry.io/some-repo-testing:source-id",
},
SubPath: "some-sub-path",
},
Expand All @@ -946,19 +943,21 @@ status: {}
},
},
}

require.NoError(t, setLastAppliedAnnotation(expectedImage))

testhelpers.CommandTest{
Args: []string{
"some-image",
"--tag", "some-registry.io/some-repo",
"--git", "some-git-url",
"--git-revision", "some-git-rev",
"--local-path", "some-local-path",
"--local-path-destination-image", "some-registry.io/some-repo-testing",
"--sub-path", "some-sub-path",
"--env", "some-key=some-val",
"--service-binding", "SomeResource:v1:some-binding",
},
ExpectedOutput: `Creating Image Resource...
Uploading to 'some-registry.io/some-repo-testing'...
Uploading 'some-registry.io/some-repo-testing:source-id'
Image Resource "some-image" created
`,
ExpectCreates: []runtime.Object{
Expand Down
3 changes: 3 additions & 0 deletions pkg/commands/image/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The flags for this command determine how the build will retrieve source code:
"--local-path" to use source code from the local machine

Local source code will be pushed to the same registry provided for the image resource tag.
--local-path-destination-image can be used to specify the repository of the source code image.
If not specified, the source code image will be pushed to the <image-tag-repo>-source repo.
Therefore, you must have credentials to access the registry on your machine.

Environment variables may be provided by using the "--env" flag or deleted by using the "--delete-env" flag.
Expand Down Expand Up @@ -124,6 +126,7 @@ kp image save my-image --tag my-registry.com/my-repo --blob https://my-blob-host
cmd.Flags().StringVar(&factory.GitRevision, "git-revision", "", "git revision such as commit, tag, or branch (default \"main\")")
cmd.Flags().StringVar(&factory.Blob, "blob", "", "source code blob url")
cmd.Flags().StringVar(&factory.LocalPath, "local-path", "", "path to local source code")
cmd.Flags().StringVar(&factory.LocalPathDestinationImage, "local-path-destination-image", "", "registry location of source image")
cmd.Flags().StringVar(&subPath, "sub-path", "", "build code at the sub path located within the source code directory")
cmd.Flags().StringVar(&factory.CacheSize, "cache-size", "", "cache size as a kubernetes quantity (default \"2G\")")
cmd.Flags().StringVarP(&factory.Builder, "builder", "b", "", "builder name")
Expand Down
Loading