-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui): add deferred config loading, use request context (#140)
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
- Loading branch information
1 parent
c5ccf94
commit 1fe219c
Showing
11 changed files
with
202 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package web | ||
|
||
import "k8s.io/client-go/tools/clientcmd" | ||
|
||
type ServerConfigError interface { | ||
error | ||
KubeconfigDefaultLocation() string | ||
KubeconfigMissing() bool | ||
BootstrapMissing() bool | ||
} | ||
|
||
type defaultKubeConfigAccessor struct{} | ||
|
||
func (defaultKubeConfigAccessor) KubeconfigDefaultLocation() string { | ||
return clientcmd.RecommendedHomeFile | ||
} | ||
|
||
type wrappedErr struct { | ||
Cause error | ||
} | ||
|
||
func (err wrappedErr) Error() string { | ||
return err.Cause.Error() | ||
} | ||
|
||
func (err wrappedErr) Unwrap() error { | ||
return err.Cause | ||
} | ||
|
||
type bootstrapErr struct { | ||
defaultKubeConfigAccessor | ||
wrappedErr | ||
} | ||
|
||
func (bootstrapErr) BootstrapMissing() bool { | ||
return true | ||
} | ||
|
||
func (bootstrapErr) KubeconfigMissing() bool { | ||
return false | ||
} | ||
|
||
func bootstrapError(err error) ServerConfigError { | ||
return &bootstrapErr{wrappedErr: wrappedErr{Cause: err}} | ||
} | ||
|
||
type kubeconfigErr struct { | ||
defaultKubeConfigAccessor | ||
wrappedErr | ||
} | ||
|
||
func (kubeconfigErr) BootstrapMissing() bool { | ||
return false | ||
} | ||
|
||
func (err kubeconfigErr) KubeconfigMissing() bool { | ||
return clientcmd.IsEmptyConfig(err.Cause) | ||
} | ||
|
||
func kubeconfigError(err error) ServerConfigError { | ||
return &kubeconfigErr{wrappedErr: wrappedErr{Cause: err}} | ||
} |
Oops, something went wrong.