diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c70236f2e..8d283060e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -80,3 +80,4 @@ and we will add you. **All** contributors belong here. 💯 * [James Blair](https://github.com/jmhbnz) * [Chengwei Guo](https://github.com/cw-Guo) * [Sarah Christoff](https://github.com/hypernovasunnix) +* [Aleksey Barabanov](https://github.com/alekseybb197) diff --git a/cmd/porter/bundle.go b/cmd/porter/bundle.go index 85906f4ac..faa12275d 100644 --- a/cmd/porter/bundle.go +++ b/cmd/porter/bundle.go @@ -146,6 +146,7 @@ Note: if overrides for registry/tag/reference are provided, this command only re porter bundle publish --archive /tmp/mybuns.tgz --reference myrepo/my-buns:0.1.0 porter bundle publish --tag latest porter bundle publish --registry myregistry.com/myorg + porter bundle publish --autobuild-disabled `, PreRunE: func(cmd *cobra.Command, args []string) error { return opts.Validate(p.Config) @@ -169,6 +170,7 @@ Note: if overrides for registry/tag/reference are provided, this command only re cmd.Flag("force").Annotations = map[string][]string{ "viper-key": {"force-overwrite"}, } + f.BoolVar(&opts.AutoBuildDisabled, "autobuild-disabled", false, "Do not automatically build the bundle from source when the last build is out-of-date.") return &cmd } diff --git a/docs/content/cli/publish.md b/docs/content/cli/publish.md index 4e7d2bfe8..27e0fa8a2 100644 --- a/docs/content/cli/publish.md +++ b/docs/content/cli/publish.md @@ -26,21 +26,23 @@ porter publish [flags] porter publish --archive /tmp/mybuns.tgz --reference myrepo/my-buns:0.1.0 porter publish --tag latest porter publish --registry myregistry.com/myorg + porter publish --autobuild-disabled ``` ### Options ``` - -a, --archive string Path to the bundle archive in .tgz format - -d, --dir string Path to the build context directory where all bundle assets are located. - -f, --file porter.yaml Path to the Porter manifest. Defaults to porter.yaml in the current directory. - --force Force push the bundle to overwrite the previously published bundle - -h, --help help for publish - --insecure-registry Don't require TLS for the registry - -r, --reference string Use a bundle in an OCI registry specified by the given reference. - --registry string Override the registry portion of the bundle reference, e.g. docker.io, myregistry.com/myorg - --tag string Override the Docker tag portion of the bundle reference, e.g. latest, v0.1.1 + -a, --archive string Path to the bundle archive in .tgz format + --autobuild-disabled Do not automatically build the bundle from source when the last build is out-of-date. + -d, --dir string Path to the build context directory where all bundle assets are located. + -f, --file porter.yaml Path to the Porter manifest. Defaults to porter.yaml in the current directory. + --force Force push the bundle to overwrite the previously published bundle + -h, --help help for publish + --insecure-registry Don't require TLS for the registry + -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --registry string Override the registry portion of the bundle reference, e.g. docker.io, myregistry.com/myorg + --tag string Override the Docker tag portion of the bundle reference, e.g. latest, v0.1.1 ``` ### Options inherited from parent commands diff --git a/tests/integration/publish_test.go b/tests/integration/publish_test.go index bf1fc8d66..14c84400d 100644 --- a/tests/integration/publish_test.go +++ b/tests/integration/publish_test.go @@ -4,8 +4,10 @@ package integration import ( "fmt" + "path" "testing" + "get.porter.sh/porter/pkg/yaml" "get.porter.sh/porter/tests" "get.porter.sh/porter/tests/tester" "github.com/stretchr/testify/require" @@ -20,14 +22,28 @@ func TestPublish(t *testing.T) { test.Chdir(test.TestDir) test.RequirePorter("create") + // Try to publish with autobuild disabled, it should fail + _, _, err = test.RunPorter("publish", "--autobuild-disabled") + require.ErrorContains(t, err, "Skipping autobuild because --autobuild-disabled was specified") + + // Try again with autobuild disabled via a config setting instead of a flag + // This is a regression test for https://github.com/getporter/porter/issues/2735 + test.EditYaml(path.Join(test.PorterHomeDir, "config.yaml"), func(yq *yaml.Editor) error { + return yq.SetValue("autobuild-disabled", "true") + }) + _, output, err := test.RunPorter("publish") + fmt.Println(output) + require.ErrorContains(t, err, "Skipping autobuild because --autobuild-disabled was specified") + // Build with version override test.RequirePorter("build", "--version=0.0.0") // Start up an insecure registry with self-signed TLS certificates reg := test.StartTestRegistry(tester.TestRegistryOptions{UseTLS: true}) + defer reg.Close() // Confirm that publish picks up the version override // Use an insecure registry to validate that we can publish to one - _, output := test.RequirePorter("publish", "--registry", reg.String(), "--insecure-registry") + _, output = test.RequirePorter("publish", "--registry", reg.String(), "--insecure-registry") tests.RequireOutputContains(t, output, fmt.Sprintf("Bundle %s/porter-hello:v0.0.0 pushed successfully", reg)) }