Use NewVFSContext in examples

This commit is contained in:
John Gardiner Myers 2023-07-15 16:00:52 -07:00
parent e04fc1314f
commit 373cd4220f
3 changed files with 11 additions and 9 deletions

View File

@ -24,8 +24,8 @@ import (
"k8s.io/kops/util/pkg/vfs"
)
func apply(ctx context.Context) error {
clientset := vfsclientset.NewVFSClientset(vfs.Context, registryBase)
func apply(vfsContext *vfs.VFSContext, ctx context.Context) error {
clientset := vfsclientset.NewVFSClientset(vfsContext, registryBase)
cluster, err := clientset.GetCluster(ctx, clusterName)
if err != nil {

View File

@ -51,7 +51,9 @@ var (
func main() {
flag.Parse()
err := parseFlags()
vfsContext := vfs.NewVFSContext()
err := parseFlags(vfsContext)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
@ -59,23 +61,23 @@ func main() {
ctx := context.TODO()
err = up(ctx)
err = up(vfsContext, ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "error from up: %v\n", err)
os.Exit(1)
}
err = apply(ctx)
err = apply(vfsContext, ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "error from apply: %v\n", err)
os.Exit(1)
}
}
func parseFlags() error {
func parseFlags(vfsContext *vfs.VFSContext) error {
var err error
registryBase, err = vfs.Context.BuildVfsPath(*flagRegistryBase)
registryBase, err = vfsContext.BuildVfsPath(*flagRegistryBase)
if err != nil {
return fmt.Errorf("error parsing registry path %q: %v", *flagRegistryBase, err)
}

View File

@ -30,8 +30,8 @@ import (
"k8s.io/kops/util/pkg/vfs"
)
func up(ctx context.Context) error {
clientset := vfsclientset.NewVFSClientset(vfs.Context, registryBase)
func up(vfsContext *vfs.VFSContext, ctx context.Context) error {
clientset := vfsclientset.NewVFSClientset(vfsContext, registryBase)
cluster := &api.Cluster{}
cluster.ObjectMeta.Name = clusterName