Skip to content
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ linters:
- unparam
- usestdlibvars
- wastedassign
- whitespace
- whitespace
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ etcd:
$(MAKE) -C etcd

.PHONY: verify verify-images verify-assets licensecheck
verify: verify-images verify-assets verify-sh verify-py verify-container licensecheck
verify: verify-images verify-assets verify-sh verify-go verify-py verify-container licensecheck

verify-images:
./hack/verify_images.sh
Expand All @@ -125,15 +125,15 @@ verify-assets:
./scripts/auto-rebase/presubmit.py

.PHONY: verify-go verify-golangci verify-govulncheck
verify-go: verify-golangci verify-govulncheck
verify-go: verify-golangci # verify-govulncheck # TODO temporarily disabled

verify-golangci:
./scripts/fetch_tools.sh golangci-lint && \
./_output/bin/golangci-lint run --verbose
./_output/bin/golangci-lint run --verbose --timeout 20m0s

verify-govulncheck:
@if ! command -v govulncheck &>/dev/null; then \
go install golang.org/x/vuln/cmd/govulncheck@latest ; \
go install -mod=mod golang.org/x/vuln/cmd/govulncheck@latest ; \
fi
govulncheck ./...

Expand Down
2 changes: 1 addition & 1 deletion cmd/microshift/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newCommand() *cobra.Command {
Use: "microshift",
Short: "MicroShift, a minimal OpenShift",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help() // err is always nil
os.Exit(1)
},
}
Expand Down
3 changes: 1 addition & 2 deletions etcd/cmd/microshift-etcd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ func main() {
cmd := &cobra.Command{
Use: "microshift-etcd",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help() // err is always nil
os.Exit(1)
},
}

cmd.AddCommand(NewRunEtcdCommand())
cmd.AddCommand(NewVersionCommand(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}))

os.Exit(cli.Run(cmd))
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions etcd/vendor/github.com/openshift/microshift/pkg/config/flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 4 additions & 13 deletions etcd/vendor/github.com/openshift/microshift/pkg/util/cert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion etcd/vendor/github.com/openshift/microshift/pkg/util/net.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/assets/applier.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package assets

import (
"context"
"sync"

"github.com/openshift/library-go/pkg/operator/events"
Expand All @@ -18,5 +19,5 @@ type RenderFunc func([]byte, RenderParams) ([]byte, error)

type readerApplier interface {
Reader([]byte, RenderFunc, RenderParams)
Applier() error
Applier(ctx context.Context) error
}
20 changes: 10 additions & 10 deletions pkg/assets/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func (d *dpApplier) Reader(objBytes []byte, render RenderFunc, params RenderPara
d.dp = obj.(*appsv1.Deployment)
}

func (d *dpApplier) Applier() error {
_, _, err := resourceapply.ApplyDeployment(context.TODO(), d.Client, assetsEventRecorder, d.dp, 0)
func (d *dpApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyDeployment(ctx, d.Client, assetsEventRecorder, d.dp, 0)
return err
}

Expand All @@ -81,12 +81,12 @@ func (d *dsApplier) Reader(objBytes []byte, render RenderFunc, params RenderPara
}
d.ds = obj.(*appsv1.DaemonSet)
}
func (d *dsApplier) Applier() error {
_, _, err := resourceapply.ApplyDaemonSet(context.TODO(), d.Client, assetsEventRecorder, d.ds, 0)
func (d *dsApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyDaemonSet(ctx, d.Client, assetsEventRecorder, d.ds, 0)
return err
}

func applyApps(apps []string, applier readerApplier, render RenderFunc, params RenderParams) error {
func applyApps(ctx context.Context, apps []string, applier readerApplier, render RenderFunc, params RenderParams) error {
lock.Lock()
defer lock.Unlock()

Expand All @@ -97,7 +97,7 @@ func applyApps(apps []string, applier readerApplier, render RenderFunc, params R
return fmt.Errorf("error getting asset %s: %v", app, err)
}
applier.Reader(objBytes, render, params)
if err := applier.Applier(); err != nil {
if err := applier.Applier(ctx); err != nil {
klog.Warningf("Failed to apply apps api %s: %v", app, err)
return err
}
Expand All @@ -106,14 +106,14 @@ func applyApps(apps []string, applier readerApplier, render RenderFunc, params R
return nil
}

func ApplyDeployments(dps []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
func ApplyDeployments(ctx context.Context, dps []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
dp := &dpApplier{}
dp.Client = appsClient(kubeconfigPath)
return applyApps(dps, dp, render, params)
return applyApps(ctx, dps, dp, render, params)
}

func ApplyDaemonSets(apps []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
func ApplyDaemonSets(ctx context.Context, apps []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
ds := &dsApplier{}
ds.Client = appsClient(kubeconfigPath)
return applyApps(apps, ds, render, params)
return applyApps(ctx, apps, ds, render, params)
}
48 changes: 24 additions & 24 deletions pkg/assets/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func (ns *nsApplier) Reader(objBytes []byte, render RenderFunc, params RenderPar
ns.ns = obj.(*corev1.Namespace)
}

func (ns *nsApplier) Applier() error {
_, _, err := resourceapply.ApplyNamespace(context.TODO(), ns.Client, assetsEventRecorder, ns.ns)
func (ns *nsApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyNamespace(ctx, ns.Client, assetsEventRecorder, ns.ns)
return err
}

Expand All @@ -82,8 +82,8 @@ func (secret *secretApplier) Reader(objBytes []byte, render RenderFunc, params R
secret.secret = obj.(*corev1.Secret)
}

func (secret *secretApplier) Applier() error {
_, _, err := resourceapply.ApplySecret(context.TODO(), secret.Client, assetsEventRecorder, secret.secret)
func (secret *secretApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplySecret(ctx, secret.Client, assetsEventRecorder, secret.secret)
return err
}

Expand All @@ -107,8 +107,8 @@ func (svc *svcApplier) Reader(objBytes []byte, render RenderFunc, params RenderP
svc.svc = obj.(*corev1.Service)
}

func (svc *svcApplier) Applier() error {
_, _, err := resourceapply.ApplyService(context.TODO(), svc.Client, assetsEventRecorder, svc.svc)
func (svc *svcApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyService(ctx, svc.Client, assetsEventRecorder, svc.svc)
return err
}

Expand All @@ -132,8 +132,8 @@ func (sa *saApplier) Reader(objBytes []byte, render RenderFunc, params RenderPar
sa.sa = obj.(*corev1.ServiceAccount)
}

func (sa *saApplier) Applier() error {
_, _, err := resourceapply.ApplyServiceAccount(context.TODO(), sa.Client, assetsEventRecorder, sa.sa)
func (sa *saApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyServiceAccount(ctx, sa.Client, assetsEventRecorder, sa.sa)
return err
}

Expand All @@ -157,12 +157,12 @@ func (cm *cmApplier) Reader(objBytes []byte, render RenderFunc, params RenderPar
cm.cm = obj.(*corev1.ConfigMap)
}

func (cm *cmApplier) Applier() error {
_, _, err := resourceapply.ApplyConfigMap(context.TODO(), cm.Client, assetsEventRecorder, cm.cm)
func (cm *cmApplier) Applier(ctx context.Context) error {
_, _, err := resourceapply.ApplyConfigMap(ctx, cm.Client, assetsEventRecorder, cm.cm)
return err
}

func applyCore(cores []string, applier readerApplier, render RenderFunc, params RenderParams) error {
func applyCore(ctx context.Context, cores []string, applier readerApplier, render RenderFunc, params RenderParams) error {
lock.Lock()
defer lock.Unlock()

Expand All @@ -173,7 +173,7 @@ func applyCore(cores []string, applier readerApplier, render RenderFunc, params
return fmt.Errorf("error getting asset %s: %v", core, err)
}
applier.Reader(objBytes, render, params)
if err := applier.Applier(); err != nil {
if err := applier.Applier(ctx); err != nil {
klog.Warningf("Failed to apply corev1 api %s: %v", core, err)
return err
}
Expand All @@ -182,31 +182,31 @@ func applyCore(cores []string, applier readerApplier, render RenderFunc, params
return nil
}

func ApplyNamespaces(cores []string, kubeconfigPath string) error {
func ApplyNamespaces(ctx context.Context, cores []string, kubeconfigPath string) error {
ns := &nsApplier{}
ns.Client = coreClient(kubeconfigPath)
return applyCore(cores, ns, nil, nil)
return applyCore(ctx, cores, ns, nil, nil)
}

func ApplyServices(cores []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
func ApplyServices(ctx context.Context, cores []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
svc := &svcApplier{}
svc.Client = coreClient(kubeconfigPath)
return applyCore(cores, svc, render, params)
return applyCore(ctx, cores, svc, render, params)
}

func ApplyServiceAccounts(cores []string, kubeconfigPath string) error {
func ApplyServiceAccounts(ctx context.Context, cores []string, kubeconfigPath string) error {
sa := &saApplier{}
sa.Client = coreClient(kubeconfigPath)
return applyCore(cores, sa, nil, nil)
return applyCore(ctx, cores, sa, nil, nil)
}

func ApplyConfigMaps(cores []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
func ApplyConfigMaps(ctx context.Context, cores []string, render RenderFunc, params RenderParams, kubeconfigPath string) error {
cm := &cmApplier{}
cm.Client = coreClient(kubeconfigPath)
return applyCore(cores, cm, render, params)
return applyCore(ctx, cores, cm, render, params)
}

func ApplyConfigMapWithData(cmPath string, data map[string]string, kubeconfigPath string) error {
func ApplyConfigMapWithData(ctx context.Context, cmPath string, data map[string]string, kubeconfigPath string) error {
cm := &cmApplier{}
cm.Client = coreClient(kubeconfigPath)
cmBytes, err := embedded.Asset(cmPath)
Expand All @@ -215,11 +215,11 @@ func ApplyConfigMapWithData(cmPath string, data map[string]string, kubeconfigPat
}
cm.Reader(cmBytes, nil, nil)
cm.cm.Data = data
_, _, err = resourceapply.ApplyConfigMap(context.TODO(), cm.Client, assetsEventRecorder, cm.cm)
_, _, err = resourceapply.ApplyConfigMap(ctx, cm.Client, assetsEventRecorder, cm.cm)
return err
}

func ApplySecretWithData(secretPath string, data map[string][]byte, kubeconfigPath string) error {
func ApplySecretWithData(ctx context.Context, secretPath string, data map[string][]byte, kubeconfigPath string) error {
secret := &secretApplier{}
secret.Client = coreClient(kubeconfigPath)
secretBytes, err := embedded.Asset(secretPath)
Expand All @@ -228,6 +228,6 @@ func ApplySecretWithData(secretPath string, data map[string][]byte, kubeconfigPa
}
secret.Reader(secretBytes, nil, nil)
secret.secret.Data = data
_, _, err = resourceapply.ApplySecret(context.TODO(), secret.Client, assetsEventRecorder, secret.secret)
_, _, err = resourceapply.ApplySecret(ctx, secret.Client, assetsEventRecorder, secret.secret)
return err
}
Loading