Compare commits

...

17 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
92390eabe4 Merge pull request #1663 from chaosteil/pluginloadfail
Refactor exec plugin load to error if plugin isn't executable
2019-10-24 11:55:41 -07:00
Jeff Regan
7b8fa51ec5 More fixes to releasing instructions. 2019-10-24 11:50:34 -07:00
Jeff Regan
af8e17a1ed Fix curl command in INSTALL.md 2019-10-24 11:34:09 -07:00
Jeff Regan
e2eeb90639 Update INSTALL.md 2019-10-24 11:23:21 -07:00
Jeff Regan
1704977a4b Explain using go to install kustomize. 2019-10-24 11:08:21 -07:00
Kubernetes Prow Robot
7050c6a7b6 Merge pull request #1688 from monopole/moveKustBackToV3
Move kustomize back to v3
2019-10-24 10:45:13 -07:00
Jeffrey Regan
02f9b98b5a Move kustomize back to v3 2019-10-24 10:32:11 -07:00
Jeff Regan
ce7ebe3299 Make all releases draft by default 2019-10-23 17:03:01 -07:00
Jeff Regan
0a8faced8f Merge pull request #1679 from monopole/updateCloudbuildAgain
Improve the release process instructions
2019-10-22 16:16:36 -07:00
Jeff Regan
3c06debf98 Merge pull request #1678 from monopole/fixCliInternalDeps
Fix internal kustomize CLI deps
2019-10-22 16:14:39 -07:00
Jeff Regan
fcee91eafd Merge pull request #1678 from monopole/fixCliInternalDeps
Fix internal kustomize CLI deps
2019-10-22 15:37:37 -07:00
Jeffrey Regan
b0b3a705f4 Fix internal kustomize CLI deps 2019-10-22 15:27:57 -07:00
Jeff Regan
67c8fbcc3c Merge pull request #1676 from monopole/useLatestCloudbuilderSigh
Use latest cloudbuilder image.
2019-10-22 12:50:33 -07:00
Jeffrey Regan
9b50b78ec8 Use latest cloudbuilder image. 2019-10-22 12:49:38 -07:00
Jeff Regan
943a1b0195 Merge pull request #1675 from monopole/pinKustomizeToApiV011
Pin kustomize CLI to API v0.1.1
2019-10-22 12:40:12 -07:00
Jeffrey Regan
f77143cd34 Pin kustomize CLI to API v0.1.1 2019-10-22 12:32:05 -07:00
Dominykas Djacenko
a4784ee5ec Refactor exec plugin load to error if plugin isn't executable 2019-10-21 19:49:27 -07:00
39 changed files with 156 additions and 123 deletions

View File

@@ -44,8 +44,15 @@ type ExecPlugin struct {
h *resmap.PluginHelpers
}
func NewExecPlugin(p string) *ExecPlugin {
return &ExecPlugin{path: p}
func NewExecPlugin(p string) (*ExecPlugin, error) {
f, err := os.Stat(p)
if err != nil {
return nil, err
}
if f.Mode()&0111 == 0000 {
return nil, fmt.Errorf("unable to execute plugin on path: %s", p)
}
return &ExecPlugin{path: p}, nil
}
func (p *ExecPlugin) Path() string {
@@ -60,15 +67,6 @@ func (p *ExecPlugin) Cfg() []byte {
return p.cfg
}
// isAvailable checks to see if the plugin is available
func (p *ExecPlugin) IsAvailable() bool {
f, err := os.Stat(p.path)
if os.IsNotExist(err) {
return false
}
return f.Mode()&0111 != 0000
}
func (p *ExecPlugin) Config(h *resmap.PluginHelpers, config []byte) error {
p.h = h
p.cfg = config

View File

@@ -5,6 +5,7 @@ package execplugin_test
import (
"fmt"
"os"
"strings"
"testing"
@@ -15,7 +16,7 @@ import (
"sigs.k8s.io/kustomize/api/plugins/loader"
"sigs.k8s.io/kustomize/api/resmap"
"sigs.k8s.io/kustomize/api/resource"
"sigs.k8s.io/kustomize/api/testutils/valtest"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/types"
)
@@ -43,10 +44,13 @@ s/$BAR/bar/g
\ \ \
`))
p := NewExecPlugin(
p, err := NewExecPlugin(
loader.AbsolutePluginPath(
config.DefaultPluginConfig(),
pluginConfig.OrgId()))
if err != nil {
t.Fatalf("unexpected error: %v", err.Error())
}
yaml, err := pluginConfig.AsYAML()
if err != nil {
@@ -114,7 +118,10 @@ func strptr(s string) *string {
}
func TestUpdateResourceOptions(t *testing.T) {
p := NewExecPlugin("")
p, err := NewExecPlugin("")
if !os.IsNotExist(err) {
t.Fatalf("unexpected error: %v", err.Error())
}
rf := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
in := resmap.New()
expected := resmap.New()
@@ -159,7 +166,10 @@ func TestUpdateResourceOptions(t *testing.T) {
}
func TestUpdateResourceOptionsWithInvalidHashAnnotationValues(t *testing.T) {
p := NewExecPlugin("")
p, err := NewExecPlugin("")
if !os.IsNotExist(err) {
t.Fatalf("unexpected error: %v", err.Error())
}
rf := resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl())
cases := []string{
"",

View File

@@ -5,6 +5,7 @@ package loader
import (
"fmt"
"os"
"path/filepath"
"plugin"
"reflect"
@@ -145,10 +146,13 @@ func (l *Loader) makeBuiltinPlugin(r resid.Gvk) (resmap.Configurable, error) {
}
func (l *Loader) loadPlugin(resId resid.ResId) (resmap.Configurable, error) {
p := execplugin.NewExecPlugin(l.absolutePluginPath(resId))
if p.IsAvailable() {
p, err := execplugin.NewExecPlugin(l.absolutePluginPath(resId))
if err == nil {
return p, nil
}
if err != nil && !os.IsNotExist(err) {
return nil, err
}
c, err := l.loadGoPlugin(resId)
if err != nil {
return nil, err

View File

@@ -21,8 +21,25 @@ curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |
grep $opsys |\
cut -d '"' -f 4 |\
xargs curl -O -L
mv kustomize_kustomize\.v*_${opsys}_amd64 kustomize
chmod u+x kustomize
tar xzf ./kustomize_v*_${opsys}_amd64.tar.gz
./kustomize version
```
## Try `go`
This method is more to show off how the `go` tool works,
than for any practical purpose. A kustomize developer should
clone the repo (see next section), and CI/CD scripts should
download a specific ready-to-run executable rather than
rely on the `go` tool.
Install the latest kustomize binary in the v3 series to `$GOPATH/bin`:
```
go install sigs.k8s.io/kustomize/kustomize/v3
```
Install a specific version:
```
go get sigs.k8s.io/kustomize/kustomize/v3@v3.3.0
```
## Build the kustomize CLI from local source
@@ -50,15 +67,6 @@ git checkout kustomize/v3.2.3
### Other methods
#### Use go get
This works poorly with existing `Go` package installations at the
moment, since kustomize switched over to Go modules but hasn't
historically followed semver with respect to its API.
This is being [fixed](versioningPolicy.md), after which
`go get` should work correctly.
#### macOS
```

View File

@@ -8,8 +8,6 @@ require (
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
sigs.k8s.io/kustomize/api v0.0.1
sigs.k8s.io/kustomize/api v0.1.1
sigs.k8s.io/yaml v1.1.0
)
replace sigs.k8s.io/kustomize/api v0.0.1 => ../api

View File

@@ -202,7 +202,8 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d h1:Xpe6sK+RY4ZgCTyZ3y273UmFmURhjtoJiwOMbQsXitY=
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize/api v0.1.1 h1:W2dWXex2MhF4/EZNokZllvet2RejCHqdAFklufN7VTg=
sigs.k8s.io/kustomize/api v0.1.1/go.mod h1:FyfJD1q1QMjC/TvK78b6cCtZB+mbpnGIo9YOvbucJes=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

View File

@@ -9,8 +9,8 @@ import (
"strings"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
)
type addBaseOptions struct {

View File

@@ -7,9 +7,9 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -7,11 +7,11 @@ import (
"fmt"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
)
// kindOfAdd is the kind of metadata being added: label or annotation

View File

@@ -6,11 +6,11 @@ package add
import (
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/testutils/valtest"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func makeKustomization(t *testing.T) *types.Kustomization {
@@ -73,7 +73,7 @@ func TestAddAnnotationInvalidFormat(t *testing.T) {
if err == nil {
t.Errorf("expected an error")
}
if err.Error() != validators.SAD {
if err.Error() != valtest_test.SAD {
t.Errorf("incorrect error: %v", err.Error())
}
}
@@ -254,7 +254,7 @@ func TestAddLabelInvalidFormat(t *testing.T) {
if err == nil {
t.Errorf("expected an error")
}
if err.Error() != validators.SAD {
if err.Error() != valtest_test.SAD {
t.Errorf("incorrect error: %v", err.Error())
}
}

View File

@@ -8,10 +8,10 @@ import (
"log"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/patch"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
"sigs.k8s.io/kustomize/api/filesys"
)
type addPatchOptions struct {

View File

@@ -7,8 +7,8 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -8,9 +8,9 @@ import (
"log"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
"sigs.k8s.io/kustomize/api/filesys"
)
type addResourceOptions struct {

View File

@@ -7,8 +7,8 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -5,10 +5,10 @@ package add
import (
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/ifc"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
)
// newCmdAddConfigMap returns a new command.

View File

@@ -9,7 +9,7 @@ import (
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/kv"
"sigs.k8s.io/kustomize/api/loader"
"sigs.k8s.io/kustomize/api/testutils/valtest"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/types"
)

View File

@@ -7,8 +7,8 @@ import (
"fmt"
"strings"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
)
// flagsAndArgs encapsulates the options for add secret/configmap commands.

View File

@@ -5,10 +5,10 @@ package add
import (
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/ifc"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
)
// newCmdAddSecret returns a new command.

View File

@@ -7,10 +7,10 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/kv"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/loader"
"sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/types"
)

View File

@@ -8,7 +8,7 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func TestFix(t *testing.T) {

View File

@@ -8,10 +8,10 @@ import (
"strings"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
)
// kindOfAdd is the kind of metadata being added: label or annotation

View File

@@ -8,11 +8,11 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/testutils/valtest"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func makeKustomizationFS() filesys.FileSystem {
@@ -147,7 +147,7 @@ func TestRemoveAnnotationInvalidFormat(t *testing.T) {
if err == nil {
t.Errorf("expected an error")
}
if err.Error() != validators.SAD {
if err.Error() != valtest_test.SAD {
t.Errorf("incorrect error: %v", err.Error())
}
}
@@ -295,7 +295,7 @@ func TestRemoveLabelInvalidFormat(t *testing.T) {
if err == nil {
t.Errorf("expected an error")
}
if err.Error() != validators.SAD {
if err.Error() != valtest_test.SAD {
t.Errorf("incorrect error: %v", err.Error())
}
}

View File

@@ -8,11 +8,11 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/patch"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/util"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
)
type removePatchOptions struct {

View File

@@ -8,9 +8,9 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/patch"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/edit/patch"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -8,9 +8,9 @@ import (
"path/filepath"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/kustfile"
)
type removeResourceOptions struct {

View File

@@ -9,8 +9,8 @@ import (
"strings"
"testing"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
"sigs.k8s.io/kustomize/api/filesys"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func TestRemoveResources(t *testing.T) {

View File

@@ -8,7 +8,7 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -8,7 +8,7 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -9,7 +9,7 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func TestSetImage(t *testing.T) {

View File

@@ -9,8 +9,8 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/testutils/valtest"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
valtest_test "sigs.k8s.io/kustomize/api/testutils/valtest"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
const (

View File

@@ -9,7 +9,7 @@ import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func TestSetReplicas(t *testing.T) {

View File

@@ -11,7 +11,7 @@ import (
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/pgmconfig"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
testutils_test "sigs.k8s.io/kustomize/kustomize/v3/internal/commands/testutils"
)
func TestFieldOrder(t *testing.T) {

View File

@@ -2,6 +2,4 @@ module sigs.k8s.io/kustomize/pluginator
go 1.13
require sigs.k8s.io/kustomize/api v0.0.1
replace sigs.k8s.io/kustomize/api v0.0.1 => ../api
require sigs.k8s.io/kustomize/api v0.1.1

View File

@@ -152,6 +152,8 @@ k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUc
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
sigs.k8s.io/kustomize/api v0.1.1 h1:W2dWXex2MhF4/EZNokZllvet2RejCHqdAFklufN7VTg=
sigs.k8s.io/kustomize/api v0.1.1/go.mod h1:FyfJD1q1QMjC/TvK78b6cCtZB+mbpnGIo9YOvbucJes=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

View File

@@ -38,7 +38,8 @@ files.
#### Packages
There's only one package in this module. It's called `main`,
There's only one public package in this module.
It's called `main`, it's therefore unimportable,
and it holds the _kustomize_ executable.
@@ -69,18 +70,18 @@ Go consumers of this API will have a `go.mod` file
requiring this module at a particular tag, e.g.
```
require sigs.k8s.io/kustomize/api v0.0.1
require sigs.k8s.io/kustomize/api v0.1.0
```
#### Release artifacts
This is a Go library only release, so the only
artifact per se is the repo tag, in the form `v4.3.2`,
This is a Go library-only release, so the only
artifact per se is the repo tag, in the form `api/v1.2.3`,
that API clients can `require` from their `go.mod` file.
Release notes should appear on the [release page].
There's an executable called `api`, which, if
There's a toy executable called `api`, which, if
run, prints the API release provenance data, but it's of
no practical use to an API client.
@@ -92,14 +93,14 @@ linkable library code.
#### Packages
There's only one package in this module. It's called `main`,
There's only one package in this module.
It's called `main`, it's therefore unimportable,
and it holds the _pluginator_ executable.
At the time of writing this binary is only of
interest to someone writing a new builtin
transformer or generator. See the [plugin
documentation](../docs/plugins).
Its dependence on the API is primarily for
plugin-related constants, not logic, and will
only change if there's some change in how
@@ -113,6 +114,18 @@ The tag appears in the URL, e.g. [pluginator/v1.0.0].
## Release procedure
> TODO: script what follows, so someone can enter
> ```
> go run ./releasing/release.go kustomize minor
> # or:
> # go run ./releasing/release.go api patch
> # go run ./releasing/release.go pluginator minor
> ```
> The program would look at the existing remote tags,
> confirm sanity and increment the appropriate major/minor/patch
> component, create the right branch and tag, etc.
> No more bash please.
At any given moment, the repository's master branch is
passing all its tests and contains code one could release.
@@ -132,6 +145,18 @@ module=kustomize # The kustomize executable
module=api # The API
```
### review tags to help determine new tag
Local:
```
git tag -l | grep $module
```
Remote:
```
git ls-remote --tags upstream | grep $module
```
### determine the version
Go's [semver]-compatible version tags take the form `v{major}.{minor}.{patch}`:
@@ -139,7 +164,7 @@ Go's [semver]-compatible version tags take the form `v{major}.{minor}.{patch}`:
| major | minor | patch |
| :---: | :---: | :---: |
| API change | enhancements | bug fixes |
| manual update | OK to auto-update | OK to auto-update |
| manual update | maybe auto-update | auto-update encouraged |
- If there are only bug fixes or refactors, increment `patch` from whatever it is now.
- If there are new features, increment `minor`.
@@ -172,10 +197,17 @@ Create it:
git checkout -b $branch
```
### define the release tag
### remove API replacements from go.mod
```
tag="${module}/v${major}.${minor}.${patch}"
echo "tag=$tag"
```
Only do this if releasing one of the executables.
### pin the executable to a particular API version
Only do this if releasing one of the
executables (kustomize or pluginator).
In this repository, an executable in development
on the master branch typically depends on the API
@@ -193,22 +225,12 @@ requires.
```
# Update the following as needed, obviously.
if [ "$module" != "api" ]; then
# go mod edit -dropreplace=sigs.k8s.io/kustomize/api $module/go.mod
# go mod edit -require=sigs.k8s.io/kustomize/api@v?.0.1 $module/go.mod
# git commit -a -m "Drop API module replacement"
fi
```
### optionally build a release locally
Install [`cloud-build-local`], then run
# git checkout -b pinTheRelease
# go mod edit -dropreplace=sigs.k8s.io/kustomize/api $module/go.mod
# go mod edit -require=sigs.k8s.io/kustomize/api@v0.1.1 $module/go.mod
# git commit -a -m "Drop API module replacement"
```
./releasing/localbuild.sh $module
```
This should create release artifacts in a local directory.
### push the release branch
@@ -216,26 +238,6 @@ This should create release artifacts in a local directory.
git push -f upstream $branch
```
### optionally review tags
Local:
```
git tag -l
```
Remote:
```
git ls-remote --tags upstream
```
### define the release tag
```
tag="${module}/v${major}.${minor}.${patch}"
echo "tag=$tag"
```
### if replacing a release...
Must delete the tag before re-pushing it.
@@ -268,6 +270,16 @@ version.
git tag -a $tag -m "Release $tag on branch $branch"
```
### optionally build a release locally
Install [`cloud-build-local`], then run
```
./releasing/localbuild.sh $module
```
This should create release artifacts in a local directory.
### trigger the cloud build by pushing the tag
Push the tag:

View File

@@ -27,6 +27,8 @@ if [ "$module" != "$tModule" ]; then
exit 1
fi
cd $module
configFile=$(mktemp)
cat <<EOF >$configFile
project_name: $module
@@ -47,9 +49,9 @@ release:
github:
owner: kubernetes-sigs
name: kustomize
draft: true
builds:
- main: ./$module/main.go
ldflags: >
- ldflags: >
-s
-X sigs.k8s.io/kustomize/api/provenance.version={{.Version}}
-X sigs.k8s.io/kustomize/api/provenance.gitCommit={{.Commit}}

View File

@@ -1,5 +1,5 @@
steps:
- name: "gcr.io/cloud-builders/git@sha256:477015d9bb2bc4780f505a4497f10ee581a28fccfa553821cc540cc64bdc37b9"
- name: "gcr.io/cloud-builders/git"
args: [fetch, --tags, --depth=100]
- name: "goreleaser/goreleaser:v0.120.3"
entrypoint: /bin/sh

View File

@@ -1,5 +1,5 @@
steps:
- name: "gcr.io/cloud-builders/git@sha256:477015d9bb2bc4780f505a4497f10ee581a28fccfa553821cc540cc64bdc37b9"
- name: "gcr.io/cloud-builders/git"
args: [fetch, --tags, --depth=100]
- name: "goreleaser/goreleaser:v0.120.3"
entrypoint: /bin/sh

View File

@@ -79,5 +79,5 @@ cloud-build-local \
echo " "
echo "Result of local build:"
echo "##########################################"
tree ./dist
tree ./$module/dist
echo "##########################################"