@spinnaker/docker
Advanced tools
Comparing version 0.0.43 to 0.0.44
@@ -1,2 +0,2 @@ | ||
!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("@spinnaker/core")):"function"==typeof define&&define.amd?define("@spinnaker/docker",["@spinnaker/core"],factory):"object"==typeof exports?exports["@spinnaker/docker"]=factory(require("@spinnaker/core")):root["@spinnaker/docker"]=factory(root["@spinnaker/core"])}(window,function(__WEBPACK_EXTERNAL_MODULE__1__){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=13)}([function(module,exports){module.exports=require("react")},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE__1__},function(module,exports){module.exports=require("lodash")},function(module,exports){module.exports=require("react-select")},function(module,exports){module.exports=require("angular")},function(module,exports){module.exports=require("rxjs")},function(module,exports){var path="docker/src/pipeline/stages/bake/bakeExecutionDetails.html";window.angular.module("ng").run(["$templateCache",function(c){c.put(path,'<div ng-controller="dockerBakeExecutionDetailsCtrl">\n <execution-details-section-nav sections="configSections"></execution-details-section-nav>\n <div class="step-section-details" ng-if="detailsSection === \'bakeConfig\'">\n <div class="row">\n <div class="col-md-6">\n <dl class="dl-narrow dl-horizontal">\n <dt if-multiple-providers>Provider</dt>\n <dd if-multiple-providers>Docker</dd>\n <dt>Organization</dt>\n <dd>{{stage.context.organization}}</dd>\n <dt>Image Name</dt>\n <dd>{{stage.context.ami_name}}</dd>\n <dt>Image Tag</dt>\n <dd>{{stage.context.extendedAttributes[\'docker_target_image_tag\']}}</dd>\n <dt>Image</dt>\n <dd>{{stage.context.ami}}</dd>\n </dl>\n </div>\n <div class="col-md-6">\n <dl class="dl-narrow dl-horizontal">\n <dt>Base OS</dt>\n <dd>{{stage.context.baseOs}}</dd>\n <dt>Region</dt>\n <dd>{{stage.context.region}}</dd>\n <dt>Package</dt>\n <dd>{{stage.context.package}}</dd>\n <dt>Label</dt>\n <dd>{{stage.context.baseLabel}}</dd>\n </dl>\n </div>\n </div>\n <stage-failure-message stage="stage" message="stage.failureMessage"></stage-failure-message>\n\n <div class="row" ng-if="stage.context.region && stage.context.status.resourceId">\n <div class="col-md-12">\n <div class="alert alert-{{stage.isFailed ? \'danger\' : \'info\'}}">\n <a target="_blank" href="{{ bakeryDetailUrl(stage) }}">\n View Bakery Details\n </a>\n </div>\n </div>\n </div>\n </div>\n <div class="step-section-details" ng-if="detailsSection === \'taskStatus\'">\n <div class="row">\n <execution-step-details item="stage"></execution-step-details>\n </div>\n </div>\n</div>\n')}]),module.exports=path},function(module,exports){var path="docker/src/pipeline/stages/bake/bakeStage.html";window.angular.module("ng").run(["$templateCache",function(c){c.put(path,'<div ng-controller="dockerBakeStageCtrl as bakeStageCtrl">\n <stage-config-field label="Package" help-key="pipeline.config.bake.package">\n <input type="text" class="form-control input-sm" ng-model="stage.package" />\n </stage-config-field>\n <stage-config-field label="Organization" help-key="pipeline.config.docker.bake.organization">\n <input type="text" class="form-control input-sm" ng-model="stage.organization" />\n </stage-config-field>\n <stage-config-field label="Image Name" help-key="pipeline.config.docker.bake.targetImage">\n <input type="text" class="form-control input-sm" ng-model="stage.ami_name" />\n </stage-config-field>\n <stage-config-field label="Image tag" help-key="pipeline.config.docker.bake.targetImageTag">\n <input type="text" class="form-control input-sm" ng-model="stage.extendedAttributes[\'docker_target_image_tag\']" />\n </stage-config-field>\n <stage-config-field label="Base OS">\n <bake-stage-choose-os model="stage.baseOs" base-os-options="baseOsOptions"></bake-stage-choose-os>\n </stage-config-field>\n\n <stage-config-field label="Base Label">\n <label class="radio-inline" ng-repeat="baseLabel in baseLabelOptions">\n <input type="radio" ng-model="stage.baseLabel" ng-value="baseLabel" />\n {{baseLabel}}\n </label>\n </stage-config-field>\n <stage-config-field label="Rebake">\n <div class="checkbox" style="margin-bottom: 0">\n <label>\n <input type="checkbox" ng-model="stage.rebake" />\n Rebake image without regard to the status of any existing bake\n </label>\n </div>\n </stage-config-field>\n</div>\n')}]),module.exports=path},function(module,exports){module.exports=require("ngimport")},function(module,exports,__webpack_require__){var map={"./pipeline/stages/bake/bakeExecutionDetails.html":6,"./pipeline/stages/bake/bakeStage.html":7};function webpackContext(req){var id=webpackContextResolve(req);return __webpack_require__(id)}function webpackContextResolve(req){var id=map[req];if(!(id+1)){var e=new Error("Cannot find module '"+req+"'");throw e.code="MODULE_NOT_FOUND",e}return id}webpackContext.keys=function(){return Object.keys(map)},webpackContext.resolve=webpackContextResolve,module.exports=webpackContext,webpackContext.id=9},function(module,exports,__webpack_require__){"use strict";var obj,_lodash=__webpack_require__(2),_lodash2=(obj=_lodash)&&obj.__esModule?obj:{default:obj},_core=__webpack_require__(1);const angular=__webpack_require__(4);module.exports=angular.module("spinnaker.docker.pipeline.stage.bakeStage",[__webpack_require__(11).name]).config(function(){_core.Registry.pipeline.registerStage({provides:"bake",cloudProvider:"docker",label:"Bake",description:"Bakes an image",templateUrl:__webpack_require__(7),executionDetailsUrl:__webpack_require__(6),executionLabelComponent:_core.BakeExecutionLabel,extraLabelLines:stage=>stage.masterStage.context.allPreviouslyBaked||stage.masterStage.context.somePreviouslyBaked?1:0,defaultTimeoutMs:36e5,validators:[{type:"requiredField",fieldName:"package"}],restartable:!0})}).controller("dockerBakeStageCtrl",["$scope","$q",function($scope,$q){$scope.stage.region="global",$scope.stage.user||($scope.stage.user=_core.AuthenticationService.getAuthenticatedUser().name),$scope.viewState={loading:!0},$scope.$watch("stage",function(){_lodash2.default.forOwn($scope.stage,function(val,key){""===val&&delete $scope.stage[key]})},!0),$scope.viewState.providerSelected=!0,$q.all({baseOsOptions:_core.BakeryReader.getBaseOsOptions("docker"),baseLabelOptions:_core.BakeryReader.getBaseLabelOptions()}).then(function(results){$scope.baseOsOptions=results.baseOsOptions.baseImages,$scope.baseLabelOptions=results.baseLabelOptions,!$scope.stage.baseOs&&$scope.baseOsOptions&&$scope.baseOsOptions.length&&($scope.stage.baseOs=$scope.baseOsOptions[0].id),!$scope.stage.baseLabel&&$scope.baseLabelOptions&&$scope.baseLabelOptions.length&&($scope.stage.baseLabel=$scope.baseLabelOptions[0]),$scope.viewState.loading=!1})}])},function(module,exports,__webpack_require__){"use strict";var _core=__webpack_require__(1);const angular=__webpack_require__(4);module.exports=angular.module("spinnaker.docker.pipeline.stage.bake.executionDetails.controller",[__webpack_require__(12).default]).controller("dockerBakeExecutionDetailsCtrl",["$scope","$stateParams","executionDetailsSectionService","$interpolate",function($scope,$stateParams,executionDetailsSectionService,$interpolate){$scope.configSections=["bakeConfig","taskStatus"];let initialized=()=>{$scope.detailsSection=$stateParams.details,$scope.provider=$scope.stage.context.cloudProviderType||"docker",$scope.bakeryDetailUrl=$interpolate(_core.SETTINGS.bakeryDetailUrl)},initialize=()=>executionDetailsSectionService.synchronizeSection($scope.configSections,initialized);initialize(),$scope.$on("$stateChangeSuccess",initialize)}])},function(module,exports){module.exports=require("@uirouter/angularjs")},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);var core_=__webpack_require__(1);class DockerImageReader_DockerImageReader{static getImage(imageName,region,credentials){return core_.API.all("images").one(credentials).one(region).one(imageName).withParams({provider:"docker"}).get().then(results=>results&&results.length?results[0]:null).catch(()=>null)}static findImages(params){return core_.RetryService.buildRetrySequence(()=>core_.API.all("images/find").getList(params),results=>results.length>0,10,1e3).then(results=>results).catch(()=>[])}static findTags(params){return core_.RetryService.buildRetrySequence(()=>core_.API.all("images/tags").getList(params),results=>results.length>0,10,1e3).then(results=>results).catch(()=>[])}}var external_react_=__webpack_require__(0),external_react_select_=__webpack_require__(3),external_react_select_default=__webpack_require__.n(external_react_select_),external_lodash_=__webpack_require__(2);class DockerImageUtils{static splitImageId(imageId=""){const imageParts=imageId.split(":"),repository=imageParts[0],organization=repository.split("/").slice(0,-1).join("/"),lookup=imageParts.length>1?imageParts.slice(1).join(":"):"";let tag,digest;return lookup&&(lookup.startsWith("sha256:")?digest=lookup:tag=lookup),{organization,repository,digest,tag}}static generateImageId(parts){if(parts.repository&&(parts.digest||parts.tag))return`${parts.repository}:${parts.digest?parts.digest:parts.tag}`}}const imageFields=["organization","repository","tag","digest"],defineOptions=[{label:"Manually",value:!0},{label:"Select from list",value:!1}];class DockerImageAndTagSelector_DockerImageAndTagSelector extends external_react_.Component{constructor(props){super(props),this.cachedValues={},this.handleRefreshImages=(()=>{this.refreshImages(this.props)}),this.lookupTypeChanged=(o=>{const newType=o.value,oldType=this.state.lookupType,oldValue=this.props[oldType],cachedValue=this.cachedValues[newType];this.valueChanged(oldType,void 0),this.cachedValues[newType]&&this.valueChanged(newType,cachedValue),this.setState({lookupType:newType}),this.cachedValues[oldType]=oldValue}),this.showManualInput=(defineManually=>{if(!defineManually){const newFields=DockerImageUtils.splitImageId(this.props.imageId||"");this.props.onChange(newFields),this.state.switchedManualWarning&&this.setState({switchedManualWarning:void 0,missingFields:void 0})}this.setState({defineManually})});const accountOptions=props.account?[{label:props.account,value:props.account}]:[],organizationOptions=props.organization&&props.organization.length?[{label:props.organization,value:props.organization}]:[],repositoryOptions=props.repository&&props.repository.length?[{label:props.repository,value:props.repository}]:[],tagOptions=props.tag&&props.tag.length?[{label:props.tag,value:props.tag}]:[],parsedImageId=DockerImageUtils.splitImageId(props.imageId),defineManually=Boolean(props.imageId&&props.imageId.includes("${"));this.state={accountOptions,switchedManualWarning:void 0,imagesLoaded:!1,imagesLoading:!1,organizationOptions,repositoryOptions,defineManually,tagOptions,lookupType:props.digest||parsedImageId.digest?"digest":"tag"}}getAccountMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.account),"account");return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>`${i.repository.split("/").slice(0,-1).join("/")}`)),acc),{})}getRegistryMap(images){return images.reduce((m,image)=>(m[image.account]=image.registry,m),{})}getOrganizationMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.repository),image=>`${image.account}/${image.repository.split("/").slice(0,-1).join("/")}`);return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>i.repository)),acc),{})}getRepositoryMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.account),"repository");return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>i.tag)),acc),{})}getOrganizationsList(accountMap){return accountMap&&accountMap[this.props.showRegistry?this.props.account:this.props.registry]||[]}getRepositoryList(organizationMap,organization,registry){if(organizationMap){return organizationMap[`${this.props.showRegistry?this.props.account:registry}/${organization||""}`]||[]}return[]}getTags(tag,repositoryMap,repository){let tags=[];return this.props.specifyTagByRegex?tag&&""===Object(external_lodash_.trim)(tag)&&(tag=void 0):repositoryMap&&((tags=repositoryMap[repository]||[]).includes(tag)||!tag||tag.includes("${")||(tag=void 0)),{tag,tags}}componentWillReceiveProps(nextProps){!this.images||["account","showRegistry"].some(key=>this.props[key]!==nextProps[key])?this.refreshImages(nextProps):["organization","registry","repository"].some(key=>this.props[key]!==nextProps[key])&&this.updateThings(nextProps),nextProps.imageId&&nextProps.imageId.includes("${")&&this.setState({defineManually:!0})}synchronizeChanges(values,registry){const{organization,repository,tag,digest}=values;if(this.props.onChange){const imageId=DockerImageUtils.generateImageId({organization,repository,tag,digest}),changes={};tag!==this.props.tag&&(changes.tag=tag),imageId!==this.props.imageId&&(changes.imageId=imageId),organization!==this.props.organization&&(changes.organization=organization),registry!==this.props.registry&&(changes.registry=registry),repository!==this.props.repository&&(changes.repository=repository),digest!==this.props.digest&&(changes.digest=digest),Object.keys(changes).length>0&&this.props.onChange(changes)}}updateThings(props,allowAutoSwitchToManualEntry=!1){if(!this.repositoryMap)return;let{imageId,organization,registry,repository,specifyTagByRegex}=props;props.showRegistry&&(registry=this.registryMap[props.account]);const organizationFound=!organization||this.organizations.includes(organization)||organization.includes("${");organizationFound||(organization="");const repositories=this.getRepositoryList(this.organizationMap,organization,registry),repositoryFound=!repository||repository.includes("${")||repositories.includes(repository);repositoryFound||(repository="");const{tag,tags}=this.getTags(props.tag,this.repositoryMap,repository),tagFound=tag===props.tag||specifyTagByRegex,newState={accountOptions:this.newAccounts.sort().map(a=>({label:a,value:a})),organizationOptions:this.organizations.filter(o=>o).sort().map(o=>({label:o,value:o})),imagesLoaded:!0,repositoryOptions:repositories.sort().map(r=>({label:r,value:r})),tagOptions:tags.sort().map(t=>({label:t,value:t}))};if(!imageId||this.state.imagesLoaded&&!allowAutoSwitchToManualEntry||organizationFound&&repositoryFound&&tagFound)imageId&&imageId.includes("${")||this.synchronizeChanges(this.state.defineManually?DockerImageUtils.splitImageId(imageId):{organization,repository,tag,digest:this.props.digest},registry);else{newState.defineManually=!0;const missingFields=[];organizationFound||missingFields.push("organization"),repositoryFound||missingFields.push("image"),tagFound||missingFields.push("tag"),newState.missingFields=missingFields,newState.switchedManualWarning=`Could not find ${missingFields.join(" or ")}, switched to manual entry`}this.setState(newState)}initializeImages(props){if(this.state.imagesLoading)return;const{showRegistry,account,registry}=props,imageConfig={provider:"dockerRegistry",account:showRegistry?account:registry};this.setState({imagesLoading:!0}),DockerImageReader_DockerImageReader.findImages(imageConfig).then(images=>{this.images=images,this.registryMap=this.getRegistryMap(this.images),this.accountMap=this.getAccountMap(this.images),this.newAccounts=this.accounts||Object.keys(this.accountMap),this.organizationMap=this.getOrganizationMap(this.images),this.repositoryMap=this.getRepositoryMap(this.images),this.organizations=this.getOrganizationsList(this.accountMap),this.updateThings(props,!0)}).finally(()=>{this.setState({imagesLoading:!1})})}refreshImages(props){this.initializeImages(props)}initializeAccounts(props){let{account}=props;core_.AccountService.listAccounts("dockerRegistry").then(allAccounts=>{const accounts=allAccounts.map(a=>a.name);this.props.showRegistry&&!account&&(account=accounts[0]),this.accounts=accounts,this.refreshImages(Object.assign({},props,{account}))})}isNew(){const{account,organization,registry,repository,tag}=this.props;return!(account||organization||registry||repository||tag)}componentDidMount(){this.props.deferInitialization||!this.props.registry&&!this.isNew()||this.initializeAccounts(this.props)}valueChanged(name,value){const changes={[name]:value};if(imageFields.some(n=>n===name)){const{organization,repository,tag,digest}=this.props,imageParts=Object.assign({organization,repository,tag,digest},changes),imageId=DockerImageUtils.generateImageId(imageParts);changes.imageId=imageId}this.props.onChange&&this.props.onChange(changes)}render(){const{account,digest,fieldClass,imageId,labelClass,organization,repository,showDigest,showRegistry,specifyTagByRegex,tag}=this.props,{accountOptions,switchedManualWarning,missingFields,imagesLoading,lookupType,organizationOptions,repositoryOptions,defineManually,tagOptions}=this.state,parsedImageId=DockerImageUtils.splitImageId(imageId),manualInputToggle=external_react_.createElement("div",{className:"sp-formItem groupHeader"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Define Image ID"),external_react_.createElement("div",{className:"sp-formActions sp-formActions--mobile"},external_react_.createElement("span",{className:"action"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{value:defineManually,disabled:imagesLoading,onChange:o=>this.showManualInput(o.value),options:defineOptions,clearable:!1}))))),warning=switchedManualWarning?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"}),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"messageContainer warningMessage"},external_react_.createElement("i",{className:"fa icon-alert-triangle"}),external_react_.createElement("div",{className:"message"},switchedManualWarning,(missingFields||[]).map(f=>external_react_.createElement("div",null,external_react_.createElement(core_.HelpField,{expand:!0,key:f,id:`pipeline.config.docker.trigger.missing.${f}`}))))))):null;if(defineManually)return external_react_.createElement("div",{className:"sp-formGroup"},manualInputToggle,external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Image ID"),external_react_.createElement("div",{className:"sp-formActions sp-formActions--mobile"},external_react_.createElement("span",{className:"action"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement("input",{className:"form-control input-sm",value:imageId||"",onChange:e=>this.valueChanged("imageId",e.target.value)}))))),warning);const Registry=showRegistry?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Registry Name")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{value:account,disabled:imagesLoading,onChange:o=>this.valueChanged("account",o?o.value:""),options:accountOptions,isLoading:imagesLoading})),external_react_.createElement("span",{className:"sp-formActions sp-formActions--web"},external_react_.createElement("span",{className:"action"},external_react_.createElement(core_.Tooltip,{value:imagesLoading?"Images refreshing":"Refresh images list"},external_react_.createElement("i",{className:`fa icon-button-refresh-arrows ${imagesLoading?"fa-spin":""}`,onClick:this.handleRefreshImages}))))))):null,Organization=external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Organization")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},organization.includes("${")?external_react_.createElement("input",{disabled:imagesLoading,className:"form-control input-sm",value:organization||"",onChange:e=>this.valueChanged("organization",e.target.value)}):external_react_.createElement(external_react_select_default.a,{value:organization||"",disabled:imagesLoading,onChange:o=>this.valueChanged("organization",o&&o.value||""),placeholder:"No organization",options:organizationOptions,isLoading:imagesLoading}))))),Image=external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Image")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},repository.includes("${")?external_react_.createElement("input",{className:"form-control input-sm",disabled:imagesLoading,value:repository||"",onChange:e=>this.valueChanged("repository",e.target.value)}):external_react_.createElement(external_react_select_default.a,{value:repository||"",disabled:imagesLoading,onChange:o=>this.valueChanged("repository",o&&o.value||""),options:repositoryOptions,required:!0,isLoading:imagesLoading}))))),Tag="tag"===lookupType?specifyTagByRegex?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Tag ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.tag"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement("input",{type:"text",className:"form-control input-sm",value:tag||"",disabled:imagesLoading||!repository,onChange:e=>this.valueChanged("tag",e.target.value)}))))):external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Tag")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},tag&&tag.includes("${")?external_react_.createElement("input",{className:"form-control input-sm",disabled:imagesLoading,value:tag||"",onChange:e=>this.valueChanged("tag",e.target.value),required:!0}):external_react_.createElement(external_react_.Fragment,null,external_react_.createElement(external_react_select_default.a,{value:tag||"",disabled:imagesLoading||!repository,isLoading:imagesLoading,onChange:o=>this.valueChanged("tag",o?o.value:void 0),options:tagOptions,placeholder:"No tag",required:!0}),external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.tag.additionalInfo",expand:!0})))))):null,Digest="digest"===lookupType?external_react_.createElement("div",{className:"form-group"},external_react_.createElement("div",{className:`sm-label-right ${labelClass}`},"Digest ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.digest"})),external_react_.createElement("div",{className:fieldClass},external_react_.createElement("input",{className:"form-control input-sm",placeholder:"sha256:abc123",value:digest||parsedImageId.digest||"",onChange:e=>this.valueChanged("digest",e.target.value),required:!0}))):null,LookupTypeSelector=showDigest?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Type")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{clearable:!1,value:lookupType,options:[{value:"digest",label:"Digest"},{value:"tag",label:"Tag"}],onChange:this.lookupTypeChanged}))))):null;return external_react_.createElement("div",{className:"sp-formGroup"},manualInputToggle,Registry,Organization,Image,LookupTypeSelector,Digest,Tag)}}DockerImageAndTagSelector_DockerImageAndTagSelector.defaultProps={fieldClass:"col-md-8",labelClass:"col-md-3",organization:"",registry:"",repository:"",showDigest:!0};var external_angular_=__webpack_require__(4),external_ngimport_=__webpack_require__(8),external_rxjs_=__webpack_require__(5);const lookupTypeOptions=[{value:"digest",label:"Digest"},{value:"tag",label:"Tag"}];var __rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(null!=s&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&(t[p[i]]=s[p[i]])}return t};core_.Registry.pipeline.registerTrigger({label:"Docker Registry",description:"Executes the pipeline on an image update",key:"docker",component:class extends external_react_.Component{constructor(props){super(props),this.dockerChanged=(changes=>{const{imageId}=changes,rest=__rest(changes,["imageId"]);this.onUpdateTrigger(Object.assign({},rest))}),this.onUpdateTrigger=(update=>{this.props.triggerUpdated&&this.props.triggerUpdated(Object.assign({},this.props.trigger,update))}),this.DockerTriggerContents=(()=>{const{trigger}=this.props;return external_react_.createElement("div",{className:"form-horizontal"},external_react_.createElement(DockerImageAndTagSelector_DockerImageAndTagSelector,{specifyTagByRegex:!0,account:trigger.account,organization:trigger.organization,registry:trigger.registry,repository:trigger.repository,tag:trigger.tag,showRegistry:!0,onChange:this.dockerChanged,showDigest:!1}))})}render(){const{DockerTriggerContents}=this;return external_react_.createElement(core_.BaseTrigger,Object.assign({},this.props,{triggerContents:external_react_.createElement(DockerTriggerContents,null)}))}},manualExecutionComponent:class extends external_react_.Component{constructor(props){super(props),this.queryStream=new external_rxjs_.Subject,this.handleQuery=(()=>{const trigger=this.props.command.trigger;return external_rxjs_.Observable.fromPromise(DockerImageReader_DockerImageReader.findTags({provider:"dockerRegistry",account:trigger.account,repository:trigger.repository}))}),this.lookupTypeChanged=(o=>{const newType=o.value;this.props.command.extraFields.tag="tag"===newType?this.state.selectedTag:this.state.digest,this.setState({lookupType:newType})}),this.updateSelectedTag=(tag=>{this.updateArtifact(this.props.command,tag),this.setState({selectedTag:tag}),this.props.command.triggerInvalid=!1}),this.updateDigest=(digest=>{this.updateArtifact(this.props.command,digest),this.setState({digest})}),this.tagLoadSuccess=(tags=>{const{command}=this.props,trigger=command.trigger,newState={};if(newState.tags=tags,newState.tags.length){const defaultSelection=newState.tags.find(t=>t===trigger.tag)||newState.tags[0];newState.selectedTag=defaultSelection,this.updateSelectedTag(defaultSelection)}newState.tagsLoading=!1,this.setState(newState)}),this.tagLoadFailure=(()=>{this.setState({tagsLoading:!1,loadError:!0})}),this.initialize=(()=>{const{command}=this.props;command.triggerInvalid=!0,command.extraFields={},this.subscription&&this.subscription.unsubscribe(),"docker"===command.trigger.type&&(this.subscription=this.queryStream.debounceTime(250).switchMap(this.handleQuery).subscribe(this.tagLoadSuccess,this.tagLoadFailure),this.searchTags())}),this.searchTags=((query="")=>{this.setState({tags:[`<span>Finding tags${query&&` matching ${query}`}...</span>`]}),this.queryStream.next()}),this.state={digest:"",tags:[],tagsLoading:!0,loadError:!1,lookupType:"tag",selectedTag:""}}static formatLabel(trigger){return external_ngimport_.$q.when(`(Docker Registry) ${trigger.account?trigger.account+":":""} ${trigger.repository||""}`)}updateArtifact(command,tag){command.extraFields.tag=tag;const trigger=command.trigger;if(trigger&&trigger.repository){let imageName="";trigger.registry&&(imageName+=trigger.registry+"/"),imageName+=trigger.repository,command.extraFields.artifacts=[{type:"docker/image",name:imageName,version:tag,reference:imageName+":"+tag}]}}componentWillReceiveProps(nextProps){nextProps.command!==this.props.command&&this.initialize()}componentDidMount(){this.initialize()}componentWillUnmount(){this.subscription&&this.subscription.unsubscribe()}render(){const{digest,tags,tagsLoading,loadError,selectedTag,lookupType}=this.state,options=tags.map(tag=>({value:tag}));return external_react_.createElement(external_react_.Fragment,null,external_react_.createElement("div",{className:"form-group"},external_react_.createElement("div",{className:"sm-label-right col-md-4"},"Type"),external_react_.createElement("div",{className:"col-md-3"},external_react_.createElement(core_.TetheredSelect,{clearable:!1,value:lookupType,options:lookupTypeOptions,onChange:this.lookupTypeChanged}))),"tag"===lookupType&&external_react_.createElement("div",{className:"form-group"},external_react_.createElement("label",{className:"col-md-4 sm-label-right"},"Tag"),tagsLoading&&external_react_.createElement("div",{className:"col-md-6"},external_react_.createElement("div",{className:"form-control-static text-center"},external_react_.createElement(core_.Spinner,{size:"small"}))),loadError&&external_react_.createElement("div",{className:"col-md-6"},"Error loading tags!"),!tagsLoading&&external_react_.createElement("div",{className:"col-md-6"},0===tags.length&&external_react_.createElement("div",null,external_react_.createElement("p",{className:"form-control-static"},"No tags found")),tags.length>0&&external_react_.createElement(core_.TetheredSelect,{options,optionRenderer:o=>external_react_.createElement("span",null,o.value),clearable:!1,value:selectedTag,valueRenderer:o=>external_react_.createElement("span",null,external_react_.createElement("strong",null,o.value)),onChange:o=>this.updateSelectedTag(o.value)}))),"digest"===lookupType&&external_react_.createElement("div",{className:"form-group"},external_react_.createElement("label",{className:"col-md-4 sm-label-right"},"Digest ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.digest"})),external_react_.createElement("div",{className:"col-md-6"},external_react_.createElement("input",{value:digest,onChange:e=>this.updateDigest(e.target.value),className:"form-control input-sm",required:!0}))))}},executionStatusComponent:props=>{const trigger=props.trigger;return external_react_.createElement("li",null,trigger.repository,":",trigger.tag)},executionTriggerLabel:()=>"Docker Registry",validators:[{type:"requiredField",fieldName:"account",message:"<strong>Registry</strong> is a required field for Docker Registry triggers."},{type:"requiredField",fieldName:"repository",message:"<strong>Image</strong> is a required field for Docker Registry triggers."},{type:"serviceAccountAccess",preventSave:!0,message:"You do not have access to the service account configured in this pipeline's Docker Registry trigger.\n You will not be able to save your edits to this pipeline."}]});const templates=__webpack_require__(9);templates.keys().forEach(function(key){templates(key)});Object(external_angular_.module)("spinnaker.docker",[__webpack_require__(10).name]),__webpack_require__.d(__webpack_exports__,"DockerImageReader",function(){return DockerImageReader_DockerImageReader}),__webpack_require__.d(__webpack_exports__,"DockerImageAndTagSelector",function(){return DockerImageAndTagSelector_DockerImageAndTagSelector}),__webpack_require__.d(__webpack_exports__,"DockerImageUtils",function(){return DockerImageUtils}),__webpack_require__.d(__webpack_exports__,"DOCKER_MODULE",function(){return"spinnaker.docker"})}])}); | ||
!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("@spinnaker/core")):"function"==typeof define&&define.amd?define("@spinnaker/docker",["@spinnaker/core"],factory):"object"==typeof exports?exports["@spinnaker/docker"]=factory(require("@spinnaker/core")):root["@spinnaker/docker"]=factory(root["@spinnaker/core"])}(window,function(__WEBPACK_EXTERNAL_MODULE__1__){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=13)}([function(module,exports){module.exports=require("react")},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE__1__},function(module,exports){module.exports=require("lodash")},function(module,exports){module.exports=require("react-select")},function(module,exports){module.exports=require("angular")},function(module,exports){module.exports=require("rxjs")},function(module,exports){var path="docker/src/pipeline/stages/bake/bakeExecutionDetails.html";window.angular.module("ng").run(["$templateCache",function(c){c.put(path,'<div ng-controller="dockerBakeExecutionDetailsCtrl">\n <execution-details-section-nav sections="configSections"></execution-details-section-nav>\n <div class="step-section-details" ng-if="detailsSection === \'bakeConfig\'">\n <div class="row">\n <div class="col-md-6">\n <dl class="dl-narrow dl-horizontal">\n <dt if-multiple-providers>Provider</dt>\n <dd if-multiple-providers>Docker</dd>\n <dt>Organization</dt>\n <dd>{{stage.context.organization}}</dd>\n <dt>Image Name</dt>\n <dd>{{stage.context.ami_name}}</dd>\n <dt>Image Tag</dt>\n <dd>{{stage.context.extendedAttributes[\'docker_target_image_tag\']}}</dd>\n <dt>Image</dt>\n <dd>{{stage.context.ami}}</dd>\n </dl>\n </div>\n <div class="col-md-6">\n <dl class="dl-narrow dl-horizontal">\n <dt>Base OS</dt>\n <dd>{{stage.context.baseOs}}</dd>\n <dt>Region</dt>\n <dd>{{stage.context.region}}</dd>\n <dt>Package</dt>\n <dd>{{stage.context.package}}</dd>\n <dt>Label</dt>\n <dd>{{stage.context.baseLabel}}</dd>\n </dl>\n </div>\n </div>\n <stage-failure-message stage="stage" message="stage.failureMessage"></stage-failure-message>\n\n <div class="row" ng-if="stage.context.region && stage.context.status.resourceId">\n <div class="col-md-12">\n <div class="alert alert-{{stage.isFailed ? \'danger\' : \'info\'}}">\n <a target="_blank" href="{{ bakeryDetailUrl(stage) }}">\n View Bakery Details\n </a>\n </div>\n </div>\n </div>\n </div>\n <div class="step-section-details" ng-if="detailsSection === \'taskStatus\'">\n <div class="row">\n <execution-step-details item="stage"></execution-step-details>\n </div>\n </div>\n</div>\n')}]),module.exports=path},function(module,exports){var path="docker/src/pipeline/stages/bake/bakeStage.html";window.angular.module("ng").run(["$templateCache",function(c){c.put(path,'<div ng-controller="dockerBakeStageCtrl as bakeStageCtrl">\n <stage-config-field label="Package" help-key="pipeline.config.bake.package">\n <input type="text" class="form-control input-sm" ng-model="stage.package" />\n </stage-config-field>\n <stage-config-field label="Organization" help-key="pipeline.config.docker.bake.organization">\n <input type="text" class="form-control input-sm" ng-model="stage.organization" />\n </stage-config-field>\n <stage-config-field label="Image Name" help-key="pipeline.config.docker.bake.targetImage">\n <input type="text" class="form-control input-sm" ng-model="stage.ami_name" />\n </stage-config-field>\n <stage-config-field label="Image tag" help-key="pipeline.config.docker.bake.targetImageTag">\n <input type="text" class="form-control input-sm" ng-model="stage.extendedAttributes[\'docker_target_image_tag\']" />\n </stage-config-field>\n <stage-config-field label="Base OS">\n <bake-stage-choose-os model="stage.baseOs" base-os-options="baseOsOptions"></bake-stage-choose-os>\n </stage-config-field>\n\n <stage-config-field label="Base Label">\n <label class="radio-inline" ng-repeat="baseLabel in baseLabelOptions">\n <input type="radio" ng-model="stage.baseLabel" ng-value="baseLabel" />\n {{baseLabel}}\n </label>\n </stage-config-field>\n <stage-config-field label="Rebake">\n <div class="checkbox" style="margin-bottom: 0">\n <label>\n <input type="checkbox" ng-model="stage.rebake" />\n Rebake image without regard to the status of any existing bake\n </label>\n </div>\n </stage-config-field>\n</div>\n')}]),module.exports=path},function(module,exports){module.exports=require("ngimport")},function(module,exports,__webpack_require__){var map={"./pipeline/stages/bake/bakeExecutionDetails.html":6,"./pipeline/stages/bake/bakeStage.html":7};function webpackContext(req){var id=webpackContextResolve(req);return __webpack_require__(id)}function webpackContextResolve(req){var id=map[req];if(!(id+1)){var e=new Error("Cannot find module '"+req+"'");throw e.code="MODULE_NOT_FOUND",e}return id}webpackContext.keys=function(){return Object.keys(map)},webpackContext.resolve=webpackContextResolve,module.exports=webpackContext,webpackContext.id=9},function(module,exports,__webpack_require__){"use strict";var obj,_lodash=__webpack_require__(2),_lodash2=(obj=_lodash)&&obj.__esModule?obj:{default:obj},_core=__webpack_require__(1);const angular=__webpack_require__(4);module.exports=angular.module("spinnaker.docker.pipeline.stage.bakeStage",[__webpack_require__(11).name]).config(function(){_core.Registry.pipeline.registerStage({provides:"bake",cloudProvider:"docker",label:"Bake",description:"Bakes an image",templateUrl:__webpack_require__(7),executionDetailsUrl:__webpack_require__(6),executionLabelComponent:_core.BakeExecutionLabel,extraLabelLines:stage=>stage.masterStage.context.allPreviouslyBaked||stage.masterStage.context.somePreviouslyBaked?1:0,defaultTimeoutMs:36e5,validators:[{type:"requiredField",fieldName:"package"}],restartable:!0})}).controller("dockerBakeStageCtrl",["$scope","$q",function($scope,$q){$scope.stage.region="global",$scope.stage.user||($scope.stage.user=_core.AuthenticationService.getAuthenticatedUser().name),$scope.viewState={loading:!0},$scope.$watch("stage",function(){_lodash2.default.forOwn($scope.stage,function(val,key){""===val&&delete $scope.stage[key]})},!0),$scope.viewState.providerSelected=!0,$q.all({baseOsOptions:_core.BakeryReader.getBaseOsOptions("docker"),baseLabelOptions:_core.BakeryReader.getBaseLabelOptions()}).then(function(results){$scope.baseOsOptions=results.baseOsOptions.baseImages,$scope.baseLabelOptions=results.baseLabelOptions,!$scope.stage.baseOs&&$scope.baseOsOptions&&$scope.baseOsOptions.length&&($scope.stage.baseOs=$scope.baseOsOptions[0].id),!$scope.stage.baseLabel&&$scope.baseLabelOptions&&$scope.baseLabelOptions.length&&($scope.stage.baseLabel=$scope.baseLabelOptions[0]),$scope.viewState.loading=!1})}])},function(module,exports,__webpack_require__){"use strict";var _core=__webpack_require__(1);const angular=__webpack_require__(4);module.exports=angular.module("spinnaker.docker.pipeline.stage.bake.executionDetails.controller",[__webpack_require__(12).default]).controller("dockerBakeExecutionDetailsCtrl",["$scope","$stateParams","executionDetailsSectionService","$interpolate",function($scope,$stateParams,executionDetailsSectionService,$interpolate){$scope.configSections=["bakeConfig","taskStatus"];let initialized=()=>{$scope.detailsSection=$stateParams.details,$scope.provider=$scope.stage.context.cloudProviderType||"docker",$scope.bakeryDetailUrl=$interpolate(_core.SETTINGS.bakeryDetailUrl)},initialize=()=>executionDetailsSectionService.synchronizeSection($scope.configSections,initialized);initialize(),$scope.$on("$stateChangeSuccess",initialize)}])},function(module,exports){module.exports=require("@uirouter/angularjs")},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);var core_=__webpack_require__(1);class DockerImageReader_DockerImageReader{static getImage(imageName,region,credentials){return core_.API.all("images").one(credentials).one(region).one(imageName).withParams({provider:"docker"}).get().then(results=>results&&results.length?results[0]:null).catch(()=>null)}static findImages(params){return core_.RetryService.buildRetrySequence(()=>core_.API.all("images/find").getList(params),results=>results.length>0,10,1e3).then(results=>results).catch(()=>[])}static findTags(params){return core_.RetryService.buildRetrySequence(()=>core_.API.all("images/tags").getList(params),results=>results.length>0,10,1e3).then(results=>results).catch(()=>[])}}var external_react_=__webpack_require__(0),external_react_select_=__webpack_require__(3),external_react_select_default=__webpack_require__.n(external_react_select_),external_lodash_=__webpack_require__(2);class DockerImageUtils{static splitImageId(imageId=""){const imageParts=imageId.split(":"),repository=imageParts[0],organization=repository.split("/").slice(0,-1).join("/"),lookup=imageParts.length>1?imageParts.slice(1).join(":"):"";let tag,digest;return lookup&&(lookup.startsWith("sha256:")?digest=lookup:tag=lookup),{organization,repository,digest,tag}}static generateImageId(parts){if(parts.repository&&(parts.digest||parts.tag))return`${parts.repository}:${parts.digest?parts.digest:parts.tag}`}}const imageFields=["organization","repository","tag","digest"],defineOptions=[{label:"Manually",value:!0},{label:"Select from list",value:!1}];class DockerImageAndTagSelector_DockerImageAndTagSelector extends external_react_.Component{constructor(props){super(props),this.cachedValues={},this.handleRefreshImages=(()=>{this.refreshImages(this.props)}),this.lookupTypeChanged=(o=>{const newType=o.value,oldType=this.state.lookupType,oldValue=this.props[oldType],cachedValue=this.cachedValues[newType];this.valueChanged(oldType,void 0),this.cachedValues[newType]&&this.valueChanged(newType,cachedValue),this.setState({lookupType:newType}),this.cachedValues[oldType]=oldValue}),this.showManualInput=(defineManually=>{if(!defineManually){const newFields=DockerImageUtils.splitImageId(this.props.imageId||"");this.props.onChange(newFields),this.state.switchedManualWarning&&this.setState({switchedManualWarning:void 0,missingFields:void 0})}this.setState({defineManually})});const accountOptions=props.account?[{label:props.account,value:props.account}]:[],organizationOptions=props.organization&&props.organization.length?[{label:props.organization,value:props.organization}]:[],repositoryOptions=props.repository&&props.repository.length?[{label:props.repository,value:props.repository}]:[],tagOptions=props.tag&&props.tag.length?[{label:props.tag,value:props.tag}]:[],parsedImageId=DockerImageUtils.splitImageId(props.imageId),defineManually=Boolean(props.imageId&&props.imageId.includes("${"));this.state={accountOptions,switchedManualWarning:void 0,imagesLoaded:!1,imagesLoading:!1,organizationOptions,repositoryOptions,defineManually,tagOptions,lookupType:props.digest||parsedImageId.digest?"digest":"tag"}}getAccountMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.account),"account");return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>`${i.repository.split("/").slice(0,-1).join("/")}`)),acc),{})}getRegistryMap(images){return images.reduce((m,image)=>(m[image.account]=image.registry,m),{})}getOrganizationMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.repository),image=>`${image.account}/${image.repository.split("/").slice(0,-1).join("/")}`);return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>i.repository)),acc),{})}getRepositoryMap(images){const groupedImages=Object(external_lodash_.groupBy)(images.filter(image=>image.account),"repository");return Object(external_lodash_.reduce)(groupedImages,(acc,image,key)=>(acc[key]=Object(external_lodash_.uniq)(image.map(i=>i.tag)),acc),{})}getOrganizationsList(accountMap){return accountMap&&accountMap[this.props.showRegistry?this.props.account:this.props.registry]||[]}getRepositoryList(organizationMap,organization,registry){if(organizationMap){return organizationMap[`${this.props.showRegistry?this.props.account:registry}/${organization||""}`]||[]}return[]}getTags(tag,repositoryMap,repository){let tags=[];return this.props.specifyTagByRegex?tag&&""===Object(external_lodash_.trim)(tag)&&(tag=void 0):repositoryMap&&((tags=repositoryMap[repository]||[]).includes(tag)||!tag||tag.includes("${")||(tag=void 0)),{tag,tags}}componentWillReceiveProps(nextProps){!this.images||["account","showRegistry"].some(key=>this.props[key]!==nextProps[key])?this.refreshImages(nextProps):["organization","registry","repository"].some(key=>this.props[key]!==nextProps[key])&&this.updateThings(nextProps),nextProps.imageId&&nextProps.imageId.includes("${")&&this.setState({defineManually:!0})}synchronizeChanges(values,registry){const{organization,repository,tag,digest}=values;if(this.props.onChange){const imageId=DockerImageUtils.generateImageId({organization,repository,tag,digest}),changes={};tag!==this.props.tag&&(changes.tag=tag),imageId!==this.props.imageId&&(changes.imageId=imageId),organization!==this.props.organization&&(changes.organization=organization),registry!==this.props.registry&&(changes.registry=registry),repository!==this.props.repository&&(changes.repository=repository),digest!==this.props.digest&&(changes.digest=digest),Object.keys(changes).length>0&&this.props.onChange(changes)}}updateThings(props,allowAutoSwitchToManualEntry=!1){if(!this.repositoryMap)return;let{imageId,organization,registry,repository,specifyTagByRegex}=props;props.showRegistry&&(registry=this.registryMap[props.account]);const organizationFound=!organization||this.organizations.includes(organization)||organization.includes("${");organizationFound||(organization="");const repositories=this.getRepositoryList(this.organizationMap,organization,registry),repositoryFound=!repository||repository.includes("${")||repositories.includes(repository);repositoryFound||(repository="");const{tag,tags}=this.getTags(props.tag,this.repositoryMap,repository),tagFound=tag===props.tag||specifyTagByRegex,newState={accountOptions:this.newAccounts.sort().map(a=>({label:a,value:a})),organizationOptions:this.organizations.filter(o=>o).sort().map(o=>({label:o,value:o})),imagesLoaded:!0,repositoryOptions:repositories.sort().map(r=>({label:r,value:r})),tagOptions:tags.sort().map(t=>({label:t,value:t}))};if(!imageId||this.state.imagesLoaded&&!allowAutoSwitchToManualEntry||organizationFound&&repositoryFound&&tagFound)imageId&&imageId.includes("${")||this.synchronizeChanges(this.state.defineManually?DockerImageUtils.splitImageId(imageId):{organization,repository,tag,digest:this.props.digest},registry);else{newState.defineManually=!0;const missingFields=[];organizationFound||missingFields.push("organization"),repositoryFound||missingFields.push("image"),tagFound||missingFields.push("tag"),newState.missingFields=missingFields,newState.switchedManualWarning=`Could not find ${missingFields.join(" or ")}, switched to manual entry`}this.setState(newState)}initializeImages(props){if(this.state.imagesLoading)return;const{showRegistry,account,registry}=props,imageConfig={provider:"dockerRegistry",account:showRegistry?account:registry};this.setState({imagesLoading:!0}),DockerImageReader_DockerImageReader.findImages(imageConfig).then(images=>{this.images=images,this.registryMap=this.getRegistryMap(this.images),this.accountMap=this.getAccountMap(this.images),this.newAccounts=this.accounts||Object.keys(this.accountMap),this.organizationMap=this.getOrganizationMap(this.images),this.repositoryMap=this.getRepositoryMap(this.images),this.organizations=this.getOrganizationsList(this.accountMap),this.updateThings(props,!0)}).finally(()=>{this.setState({imagesLoading:!1})})}refreshImages(props){this.initializeImages(props)}initializeAccounts(props){let{account}=props;core_.AccountService.listAccounts("dockerRegistry").then(allAccounts=>{const accounts=allAccounts.map(a=>a.name);this.props.showRegistry&&!account&&(account=accounts[0]),this.accounts=accounts,this.refreshImages(Object.assign({},props,{account}))})}isNew(){const{account,organization,registry,repository,tag}=this.props;return!(account||organization||registry||repository||tag)}componentDidMount(){this.props.deferInitialization||!this.props.registry&&!this.isNew()||this.initializeAccounts(this.props)}valueChanged(name,value){const changes={[name]:value};if(imageFields.some(n=>n===name)){const{organization,repository,tag,digest}=this.props,imageParts=Object.assign({organization,repository,tag,digest},changes),imageId=DockerImageUtils.generateImageId(imageParts);changes.imageId=imageId}this.props.onChange&&this.props.onChange(changes)}render(){const{account,digest,fieldClass,imageId,labelClass,organization,repository,showDigest,showRegistry,specifyTagByRegex,tag}=this.props,{accountOptions,switchedManualWarning,missingFields,imagesLoading,lookupType,organizationOptions,repositoryOptions,defineManually,tagOptions}=this.state,parsedImageId=DockerImageUtils.splitImageId(imageId),manualInputToggle=external_react_.createElement("div",{className:"sp-formItem groupHeader"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Define Image ID"),external_react_.createElement("div",{className:"sp-formActions sp-formActions--mobile"},external_react_.createElement("span",{className:"action"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{value:defineManually,disabled:imagesLoading,onChange:o=>this.showManualInput(o.value),options:defineOptions,clearable:!1}))))),warning=switchedManualWarning?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"}),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"messageContainer warningMessage"},external_react_.createElement("i",{className:"fa icon-alert-triangle"}),external_react_.createElement("div",{className:"message"},switchedManualWarning,(missingFields||[]).map(f=>external_react_.createElement("div",null,external_react_.createElement(core_.HelpField,{expand:!0,key:f,id:`pipeline.config.docker.trigger.missing.${f}`}))))))):null;if(defineManually)return external_react_.createElement("div",{className:"sp-formGroup"},manualInputToggle,external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Image ID"),external_react_.createElement("div",{className:"sp-formActions sp-formActions--mobile"},external_react_.createElement("span",{className:"action"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement("input",{className:"form-control input-sm",value:imageId||"",onChange:e=>this.valueChanged("imageId",e.target.value)}))))),warning);const Registry=showRegistry?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Registry Name")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{value:account,disabled:imagesLoading,onChange:o=>this.valueChanged("account",o?o.value:""),options:accountOptions,isLoading:imagesLoading})),external_react_.createElement("span",{className:"sp-formActions sp-formActions--web"},external_react_.createElement("span",{className:"action"},external_react_.createElement(core_.Tooltip,{value:imagesLoading?"Images refreshing":"Refresh images list"},external_react_.createElement("i",{className:`fa icon-button-refresh-arrows ${imagesLoading?"fa-spin":""}`,onClick:this.handleRefreshImages}))))))):null,Organization=external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Organization")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},organization.includes("${")?external_react_.createElement("input",{disabled:imagesLoading,className:"form-control input-sm",value:organization||"",onChange:e=>this.valueChanged("organization",e.target.value)}):external_react_.createElement(external_react_select_default.a,{value:organization||"",disabled:imagesLoading,onChange:o=>this.valueChanged("organization",o&&o.value||""),placeholder:"No organization",options:organizationOptions,isLoading:imagesLoading}))))),Image=external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Image")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},repository.includes("${")?external_react_.createElement("input",{className:"form-control input-sm",disabled:imagesLoading,value:repository||"",onChange:e=>this.valueChanged("repository",e.target.value)}):external_react_.createElement(external_react_select_default.a,{value:repository||"",disabled:imagesLoading,onChange:o=>this.valueChanged("repository",o&&o.value||""),options:repositoryOptions,required:!0,isLoading:imagesLoading}))))),Tag="tag"===lookupType?specifyTagByRegex?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Tag ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.tag"}))),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement("input",{type:"text",className:"form-control input-sm",value:tag||"",disabled:imagesLoading||!repository,onChange:e=>this.valueChanged("tag",e.target.value)}))))):external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Tag")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},tag&&tag.includes("${")?external_react_.createElement("input",{className:"form-control input-sm",disabled:imagesLoading,value:tag||"",onChange:e=>this.valueChanged("tag",e.target.value),required:!0}):external_react_.createElement(external_react_.Fragment,null,external_react_.createElement(external_react_select_default.a,{value:tag||"",disabled:imagesLoading||!repository,isLoading:imagesLoading,onChange:o=>this.valueChanged("tag",o?o.value:void 0),options:tagOptions,placeholder:"No tag",required:!0}),external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.tag.additionalInfo",expand:!0})))))):null,Digest="digest"===lookupType?external_react_.createElement("div",{className:"form-group"},external_react_.createElement("div",{className:`sm-label-right ${labelClass}`},"Digest ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.digest"})),external_react_.createElement("div",{className:fieldClass},external_react_.createElement("input",{className:"form-control input-sm",placeholder:"sha256:abc123",value:digest||parsedImageId.digest||"",onChange:e=>this.valueChanged("digest",e.target.value),required:!0}))):null,LookupTypeSelector=showDigest?external_react_.createElement("div",{className:"sp-formItem"},external_react_.createElement("div",{className:"sp-formItem__left"},external_react_.createElement("div",{className:"sp-formLabel"},"Type")),external_react_.createElement("div",{className:"sp-formItem__right"},external_react_.createElement("div",{className:"sp-form"},external_react_.createElement("span",{className:"field"},external_react_.createElement(external_react_select_default.a,{clearable:!1,value:lookupType,options:[{value:"digest",label:"Digest"},{value:"tag",label:"Tag"}],onChange:this.lookupTypeChanged}))))):null;return external_react_.createElement("div",{className:"sp-formGroup"},manualInputToggle,Registry,Organization,Image,LookupTypeSelector,Digest,Tag)}}DockerImageAndTagSelector_DockerImageAndTagSelector.defaultProps={fieldClass:"col-md-8",labelClass:"col-md-3",organization:"",registry:"",repository:"",showDigest:!0};var external_angular_=__webpack_require__(4),external_ngimport_=__webpack_require__(8),external_rxjs_=__webpack_require__(5);const lookupTypeOptions=[{value:"digest",label:"Digest"},{value:"tag",label:"Tag"}];var __rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(null!=s&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&(t[p[i]]=s[p[i]])}return t};core_.Registry.pipeline.registerTrigger({label:"Docker Registry",description:"Executes the pipeline on an image update",key:"docker",component:class extends external_react_.Component{constructor(props){super(props),this.dockerChanged=(changes=>{const{imageId}=changes,rest=__rest(changes,["imageId"]);this.onUpdateTrigger(Object.assign({},rest))}),this.onUpdateTrigger=(update=>{this.props.triggerUpdated&&this.props.triggerUpdated(Object.assign({},this.props.trigger,update))})}render(){const{trigger}=this.props;return external_react_.createElement("div",{className:"form-horizontal"},external_react_.createElement(DockerImageAndTagSelector_DockerImageAndTagSelector,{specifyTagByRegex:!0,account:trigger.account,organization:trigger.organization,registry:trigger.registry,repository:trigger.repository,tag:trigger.tag,showRegistry:!0,onChange:this.dockerChanged,showDigest:!1}))}},manualExecutionComponent:class extends external_react_.Component{constructor(props){super(props),this.queryStream=new external_rxjs_.Subject,this.handleQuery=(()=>{const trigger=this.props.command.trigger;return external_rxjs_.Observable.fromPromise(DockerImageReader_DockerImageReader.findTags({provider:"dockerRegistry",account:trigger.account,repository:trigger.repository}))}),this.lookupTypeChanged=(o=>{const newType=o.value;this.props.updateCommand("extraFields.tag","tag"===newType?this.state.selectedTag:this.state.digest),this.setState({lookupType:newType})}),this.updateSelectedTag=(tag=>{this.updateArtifact(this.props.command,tag),this.setState({selectedTag:tag}),this.props.command.triggerInvalid=!1}),this.updateDigest=(digest=>{this.updateArtifact(this.props.command,digest),this.setState({digest})}),this.tagLoadSuccess=(tags=>{const{command}=this.props,trigger=command.trigger,newState={};if(newState.tags=tags,newState.tags.length){const defaultSelection=newState.tags.find(t=>t===trigger.tag)||newState.tags[0];newState.selectedTag=defaultSelection,this.updateSelectedTag(defaultSelection)}newState.tagsLoading=!1,this.setState(newState)}),this.tagLoadFailure=(()=>{this.setState({tagsLoading:!1,loadError:!0})}),this.initialize=(()=>{const{command}=this.props;this.props.updateCommand("triggerInvalid",!0),this.props.updateCommand("extraFields",{tag:Object(external_lodash_.get)(command,"extraFields.tag",""),artifacts:Object(external_lodash_.get)(command,"extraFields.artifacts","")}),this.subscription&&this.subscription.unsubscribe(),"docker"===command.trigger.type&&(this.subscription=this.queryStream.debounceTime(250).switchMap(this.handleQuery).subscribe(this.tagLoadSuccess,this.tagLoadFailure),this.searchTags())}),this.searchTags=((query="")=>{this.setState({tags:[`<span>Finding tags${query&&` matching ${query}`}...</span>`]}),this.queryStream.next()}),this.state={digest:"",tags:[],tagsLoading:!0,loadError:!1,lookupType:"tag",selectedTag:""}}static formatLabel(trigger){return external_ngimport_.$q.when(`(Docker Registry) ${trigger.account?trigger.account+":":""} ${trigger.repository||""}`)}updateArtifact(command,tag){this.props.updateCommand("extraFields.tag",tag);const trigger=command.trigger;if(trigger&&trigger.repository){let imageName="";trigger.registry&&(imageName+=trigger.registry+"/"),imageName+=trigger.repository,this.props.updateCommand("extraFields.artifacts",[{type:"docker/image",name:imageName,version:tag,reference:imageName+":"+tag}])}}componentDidMount(){this.initialize()}componentWillUnmount(){this.subscription&&this.subscription.unsubscribe()}render(){const{digest,tags,tagsLoading,loadError,selectedTag,lookupType}=this.state,options=tags.map(tag=>({value:tag}));return external_react_.createElement(external_react_.Fragment,null,external_react_.createElement("div",{className:"form-group"},external_react_.createElement("div",{className:"sm-label-right col-md-4"},"Type"),external_react_.createElement("div",{className:"col-md-3"},external_react_.createElement(core_.TetheredSelect,{clearable:!1,value:lookupType,options:lookupTypeOptions,onChange:this.lookupTypeChanged}))),"tag"===lookupType&&external_react_.createElement("div",{className:"form-group"},external_react_.createElement("label",{className:"col-md-4 sm-label-right"},"Tag"),tagsLoading&&external_react_.createElement("div",{className:"col-md-6"},external_react_.createElement("div",{className:"form-control-static text-center"},external_react_.createElement(core_.Spinner,{size:"small"}))),loadError&&external_react_.createElement("div",{className:"col-md-6"},"Error loading tags!"),!tagsLoading&&external_react_.createElement("div",{className:"col-md-6"},0===tags.length&&external_react_.createElement("div",null,external_react_.createElement("p",{className:"form-control-static"},"No tags found")),tags.length>0&&external_react_.createElement(core_.TetheredSelect,{options,optionRenderer:o=>external_react_.createElement("span",null,o.value),clearable:!1,value:selectedTag,valueRenderer:o=>external_react_.createElement("span",null,external_react_.createElement("strong",null,o.value)),onChange:o=>this.updateSelectedTag(o.value)}))),"digest"===lookupType&&external_react_.createElement("div",{className:"form-group"},external_react_.createElement("label",{className:"col-md-4 sm-label-right"},"Digest ",external_react_.createElement(core_.HelpField,{id:"pipeline.config.docker.trigger.digest"})),external_react_.createElement("div",{className:"col-md-6"},external_react_.createElement("input",{value:digest,onChange:e=>this.updateDigest(e.target.value),className:"form-control input-sm",required:!0}))))}},executionStatusComponent:props=>{const trigger=props.trigger;return external_react_.createElement("li",null,trigger.repository,":",trigger.tag)},executionTriggerLabel:()=>"Docker Registry",validators:[{type:"requiredField",fieldName:"account",message:"<strong>Registry</strong> is a required field for Docker Registry triggers."},{type:"requiredField",fieldName:"repository",message:"<strong>Image</strong> is a required field for Docker Registry triggers."},{type:"serviceAccountAccess",preventSave:!0,message:"You do not have access to the service account configured in this pipeline's Docker Registry trigger.\n You will not be able to save your edits to this pipeline."}]});const templates=__webpack_require__(9);templates.keys().forEach(function(key){templates(key)});Object(external_angular_.module)("spinnaker.docker",[__webpack_require__(10).name]),__webpack_require__.d(__webpack_exports__,"DockerImageReader",function(){return DockerImageReader_DockerImageReader}),__webpack_require__.d(__webpack_exports__,"DockerImageAndTagSelector",function(){return DockerImageAndTagSelector_DockerImageAndTagSelector}),__webpack_require__.d(__webpack_exports__,"DockerImageUtils",function(){return DockerImageUtils}),__webpack_require__.d(__webpack_exports__,"DOCKER_MODULE",function(){return"spinnaker.docker"})}])}); | ||
//# sourceMappingURL=lib.js.map |
@@ -11,4 +11,3 @@ import * as React from 'react'; | ||
private onUpdateTrigger; | ||
private DockerTriggerContents; | ||
render(): JSX.Element; | ||
} |
@@ -11,3 +11,2 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import * as React from 'react'; | ||
import { BaseTrigger } from '@spinnaker/core'; | ||
import { DockerImageAndTagSelector } from '../../image'; | ||
@@ -26,13 +25,9 @@ export class DockerTriggerConfig extends React.Component { | ||
}; | ||
this.DockerTriggerContents = () => { | ||
const { trigger } = this.props; | ||
return (React.createElement("div", { className: "form-horizontal" }, | ||
React.createElement(DockerImageAndTagSelector, { specifyTagByRegex: true, account: trigger.account, organization: trigger.organization, registry: trigger.registry, repository: trigger.repository, tag: trigger.tag, showRegistry: true, onChange: this.dockerChanged, showDigest: false }))); | ||
}; | ||
} | ||
render() { | ||
const { DockerTriggerContents } = this; | ||
return React.createElement(BaseTrigger, Object.assign({}, this.props, { triggerContents: React.createElement(DockerTriggerContents, null) })); | ||
const { trigger } = this.props; | ||
return (React.createElement("div", { className: "form-horizontal" }, | ||
React.createElement(DockerImageAndTagSelector, { specifyTagByRegex: true, account: trigger.account, organization: trigger.organization, registry: trigger.registry, repository: trigger.repository, tag: trigger.tag, showRegistry: true, onChange: this.dockerChanged, showDigest: false }))); | ||
} | ||
} | ||
//# sourceMappingURL=DockerTriggerConfig.js.map |
@@ -26,3 +26,2 @@ import * as React from 'react'; | ||
private initialize; | ||
componentWillReceiveProps(nextProps: ITriggerTemplateComponentProps): void; | ||
componentDidMount(): void; | ||
@@ -29,0 +28,0 @@ componentWillUnmount(): void; |
import * as React from 'react'; | ||
import { get } from 'lodash'; | ||
import { $q } from 'ngimport'; | ||
@@ -21,3 +22,3 @@ import { Observable, Subject } from 'rxjs'; | ||
const newType = o.value; | ||
this.props.command.extraFields.tag = newType === 'tag' ? this.state.selectedTag : this.state.digest; | ||
this.props.updateCommand('extraFields.tag', newType === 'tag' ? this.state.selectedTag : this.state.digest); | ||
this.setState({ lookupType: newType }); | ||
@@ -56,5 +57,8 @@ }; | ||
const { command } = this.props; | ||
command.triggerInvalid = true; | ||
this.props.updateCommand('triggerInvalid', true); | ||
// These fields will be added to the trigger when the form is submitted | ||
command.extraFields = {}; | ||
this.props.updateCommand('extraFields', { | ||
tag: get(command, 'extraFields.tag', ''), | ||
artifacts: get(command, 'extraFields.artifacts', ''), | ||
}); | ||
if (this.subscription) { | ||
@@ -90,3 +94,3 @@ this.subscription.unsubscribe(); | ||
updateArtifact(command, tag) { | ||
command.extraFields.tag = tag; | ||
this.props.updateCommand('extraFields.tag', tag); | ||
const trigger = command.trigger; | ||
@@ -99,3 +103,3 @@ if (trigger && trigger.repository) { | ||
imageName += trigger.repository; | ||
command.extraFields.artifacts = [ | ||
this.props.updateCommand('extraFields.artifacts', [ | ||
{ | ||
@@ -107,10 +111,5 @@ type: 'docker/image', | ||
}, | ||
]; | ||
]); | ||
} | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
if (nextProps.command !== this.props.command) { | ||
this.initialize(); | ||
} | ||
} | ||
componentDidMount() { | ||
@@ -117,0 +116,0 @@ this.initialize(); |
{ | ||
"name": "@spinnaker/docker", | ||
"version": "0.0.43", | ||
"version": "0.0.44", | ||
"main": "lib/lib.js", | ||
@@ -5,0 +5,0 @@ "typings": "lib/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
265298
2167