提交 2e6a54cf 编写于 作者: S Sebastian Florek 提交者: GitHub

Fix gulp serve auth (#2060)

* Remove unused code

* Fix gulp serve auth issue

* Run gulp format

* Fix test
上级 9843d991
......@@ -108,9 +108,9 @@ func (self *clientManager) ClientCmdConfig(req *restful.Request) (clientcmd.Clie
return nil, err
}
// Use token in cfg if there is no token in authInfo
// Use auth data provided in cfg if there is no token in header
if len(authInfo.Token) == 0 {
authInfo.Token = cfg.BearerToken
authInfo = self.buildAuthInfoFromConfig(cfg)
}
cmdCfg := api.NewConfig()
......@@ -176,6 +176,19 @@ func (self *clientManager) buildConfigFromFlags(apiserverHost, kubeConfigPath st
return nil, errors.New("Could not create client config. Check logs for more information")
}
// Based on rest config creates auth info structure.
func (self *clientManager) buildAuthInfoFromConfig(cfg *rest.Config) api.AuthInfo {
return api.AuthInfo{
Token: cfg.BearerToken,
ClientCertificate: cfg.CertFile,
ClientKey: cfg.KeyFile,
ClientCertificateData: cfg.CertData,
ClientKeyData: cfg.KeyData,
Username: cfg.Username,
Password: cfg.Password,
}
}
// Extracts authentication information from request header
func (self *clientManager) extractAuthInfo(req *restful.Request) api.AuthInfo {
if req == nil {
......
......@@ -23,20 +23,6 @@ export default class MiddleEllipsisController {
constructor() {
/** @export {string} Initialized from the scope. */
this.displayString;
/** @export {number} Calculated during directive linking phase. */
this.maxLength;
}
/**
* Checks whether text fulfills length restrictions. If it is too long then returns true, false
* otherwise.
*
* @return {boolean}
* @export
*/
shouldTruncate() {
return this.displayString.length > this.maxLength;
}
}
......
......@@ -14,8 +14,4 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<md-tooltip md-direction="top"
ng-if="ellipsisCtrl.shouldTruncate()">
{{ellipsisCtrl.displayString}}
</md-tooltip>
<div class="kd-middleellipsis">{{ellipsisCtrl.displayString}}</div>
......@@ -29,21 +29,7 @@ describe('Middle ellipsis controller', () => {
});
});
it('should truncate display string', () => {
// given
ctrl.displayString = new Array(32).join('x');
ctrl.maxLength = 16;
// then
expect(ctrl.shouldTruncate()).toBe(true);
});
it('should not truncate display string', () => {
// given
ctrl.displayString = new Array(16).join('x');
ctrl.maxLength = 32;
// then
expect(ctrl.shouldTruncate()).toBe(false);
it('should initialize controller', () => {
expect(ctrl).not.toBeNull();
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册