Skip to content

Commit

Permalink
Get VFSContext from caller in misc. places
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Jul 18, 2023
1 parent 5c343b0 commit 850abfb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
}

for _, p := range c.AddonPaths {
addon, err := clusteraddons.LoadClusterAddon(p)
addon, err := clusteraddons.LoadClusterAddon(clientset.VFSContext(), p)
if err != nil {
return fmt.Errorf("error loading cluster addon %s: %v", p, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/clusteraddons/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ClusterAddon struct {
}

// LoadClusterAddon loads a set of objects from the specified VFS location
func LoadClusterAddon(location string) (*ClusterAddon, error) {
func LoadClusterAddon(vfsContext *vfs.VFSContext, location string) (*ClusterAddon, error) {
u, err := url.Parse(location)
if err != nil {
return nil, fmt.Errorf("invalid addon location: %q", location)
Expand All @@ -41,7 +41,7 @@ func LoadClusterAddon(location string) (*ClusterAddon, error) {

resolved := u.String()
klog.V(2).Infof("Loading addon from %q", resolved)
addonBytes, err := vfs.Context.ReadFile(resolved)
addonBytes, err := vfsContext.ReadFile(resolved)
if err != nil {
return nil, fmt.Errorf("error reading addon %q: %v", resolved, err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/wellknownoperators/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type Package struct {
}

type Builder struct {
Cluster *kops.Cluster
VFSContext *vfs.VFSContext
Cluster *kops.Cluster
}

func (b *Builder) Build(objects kubemanifest.ObjectList) ([]*Package, kubemanifest.ObjectList, error) {
Expand Down Expand Up @@ -94,7 +95,7 @@ func (b *Builder) loadClusterPackage(u *unstructured.Unstructured) (*Package, er

locationURL := channelURL.ResolveReference(&url.URL{Path: location}).String()

manifestBytes, err := vfs.Context.ReadFile(locationURL)
manifestBytes, err := b.VFSContext.ReadFile(locationURL)
if err != nil {
return nil, fmt.Errorf("error reading operator manifest %q: %v", locationURL, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/klog/v2"

channelsapi "k8s.io/kops/channels/pkg/api"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/assets"
Expand All @@ -47,6 +46,7 @@ import (
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/fitasks"
"k8s.io/kops/upup/pkg/fi/utils"
"k8s.io/kops/util/pkg/vfs"
)

// BootstrapChannelBuilder is responsible for handling the addons in channels
Expand Down Expand Up @@ -162,7 +162,8 @@ func (b *BootstrapChannelBuilder) Build(c *fi.CloudupModelBuilderContext) error

if featureflag.UseAddonOperators.Enabled() {
ob := &wellknownoperators.Builder{
Cluster: b.Cluster,
VFSContext: vfs.Context,
Cluster: b.Cluster,
}

addonPackages, clusterAddons, err := ob.Build(b.ClusterAddons)
Expand Down

0 comments on commit 850abfb

Please sign in to comment.