1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00
portainer/app/portainer/models/registry.js
cong meng 6d5877ca1c
fix(registry): #4371 cannot push to quay.io registry (#4868)
Co-authored-by: Simon Meng <simon.meng@portainer.io>
2021-03-13 12:47:35 +13:00

74 lines
2.1 KiB
JavaScript

import _ from 'lodash-es';
import { RegistryTypes } from '@/portainer/models/registryTypes';
export function RegistryViewModel(data) {
this.Id = data.Id;
this.Type = data.Type;
this.Name = data.Name;
this.URL = data.URL;
this.Authentication = data.Authentication;
this.Username = data.Username;
this.Password = data.Password;
this.AuthorizedUsers = data.AuthorizedUsers;
this.AuthorizedTeams = data.AuthorizedTeams;
this.UserAccessPolicies = data.UserAccessPolicies;
this.TeamAccessPolicies = data.TeamAccessPolicies;
this.Checked = false;
this.Gitlab = data.Gitlab;
this.Quay = data.Quay;
}
export function RegistryManagementConfigurationDefaultModel(registry) {
this.Authentication = false;
this.Password = '';
this.TLS = false;
this.TLSSkipVerify = false;
this.TLSCACertFile = null;
this.TLSCertFile = null;
this.TLSKeyFile = null;
if (registry.Type === RegistryTypes.QUAY || registry.Type === RegistryTypes.AZURE) {
this.Authentication = true;
this.Username = registry.Username;
this.TLS = true;
}
if (registry.Type === RegistryTypes.CUSTOM && registry.Authentication) {
this.Authentication = true;
this.Username = registry.Username;
}
}
export function RegistryDefaultModel() {
this.Type = RegistryTypes.CUSTOM;
this.URL = '';
this.Name = '';
this.Authentication = false;
this.Username = '';
this.Password = '';
}
export function RegistryCreateRequest(model) {
this.Name = model.Name;
this.Type = model.Type;
this.URL = _.replace(model.URL, /^https?\:\/\//i, '');
this.URL = _.replace(this.URL, /\/$/, '');
this.Authentication = model.Authentication;
if (model.Authentication) {
this.Username = model.Username;
this.Password = model.Password;
}
if (model.Type === RegistryTypes.GITLAB) {
this.Gitlab = {
ProjectId: model.Gitlab.ProjectId,
InstanceURL: model.Gitlab.InstanceURL,
ProjectPath: model.Gitlab.ProjectPath,
};
}
if (model.Type === RegistryTypes.QUAY) {
this.Quay = {
useOrganisation: model.Quay.useOrganisation,
organisationName: model.Quay.organisationName,
};
}
}