Fix dry-run still loading kubeconfig issue
If this is implemented, it will not assume that access to a kubeconfig is guaranteed even if just for retrieving configured namespace. Signed-off-by: Soule BA <soule@weave.works>
This commit is contained in:
@@ -88,12 +88,22 @@ func buildKsCmdRun(cmd *cobra.Command, args []string) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder, err := build.NewBuilder(name, buildKsArgs.path,
|
var builder *build.Builder
|
||||||
build.WithClientConfig(kubeconfigArgs, kubeclientOptions),
|
if buildKsArgs.dryRun {
|
||||||
build.WithTimeout(rootArgs.timeout),
|
builder, err = build.NewBuilder(name, buildKsArgs.path,
|
||||||
build.WithKustomizationFile(buildKsArgs.kustomizationFile),
|
build.WithTimeout(rootArgs.timeout),
|
||||||
build.WithDryRun(buildKsArgs.dryRun),
|
build.WithKustomizationFile(buildKsArgs.kustomizationFile),
|
||||||
)
|
build.WithDryRun(buildKsArgs.dryRun),
|
||||||
|
build.WithNamespace(*kubeconfigArgs.Namespace),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
builder, err = build.NewBuilder(name, buildKsArgs.path,
|
||||||
|
build.WithClientConfig(kubeconfigArgs, kubeclientOptions),
|
||||||
|
build.WithTimeout(rootArgs.timeout),
|
||||||
|
build.WithKustomizationFile(buildKsArgs.kustomizationFile),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: autoscaling/v2beta2
|
apiVersion: autoscaling/v2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
name: podinfo
|
name: podinfo
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ spec:
|
|||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 64Mi
|
memory: 64Mi
|
||||||
---
|
---
|
||||||
apiVersion: autoscaling/v2beta2
|
apiVersion: autoscaling/v2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ spec:
|
|||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 64Mi
|
memory: 64Mi
|
||||||
---
|
---
|
||||||
apiVersion: autoscaling/v2beta2
|
apiVersion: autoscaling/v2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: autoscaling/v2beta2
|
apiVersion: autoscaling/v2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
name: podinfo
|
name: podinfo
|
||||||
|
|||||||
@@ -139,6 +139,14 @@ func WithClientConfig(rcg *genericclioptions.ConfigFlags, clientOpts *runclient.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithNamespace sets the namespace
|
||||||
|
func WithNamespace(namespace string) BuilderOptionFunc {
|
||||||
|
return func(b *Builder) error {
|
||||||
|
b.namespace = namespace
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithDryRun sets the dry-run flag
|
// WithDryRun sets the dry-run flag
|
||||||
func WithDryRun(dryRun bool) BuilderOptionFunc {
|
func WithDryRun(dryRun bool) BuilderOptionFunc {
|
||||||
return func(b *Builder) error {
|
return func(b *Builder) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user