Docker 搭建 GitLab 添加用户
想要使用 Docker 来搭建 GitLab 的话需要先安装 Docker, 官方的说法Desktop版本是最方便的部署方式,安装非常简单就官网下载即可,另外可以设置一下免sudo使用docker也挺方便的。
"""
Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.
"""
import abc
class AbstractFactory(metaclass=abc.ABCMeta):
"""
Declare an interface for operations that create abstract product
objects.
"""
@abc.abstractmethod
def create_product_a(self):
pass
@abc.abstractmethod
def create_product_b(self):
pass
class ConcreteFactory1(AbstractFactory):
"""
Implement the operations to create concrete product objects.
"""
def create_product_a(self):
return ConcreteProductA1()
def create_product_b(self):
return ConcreteProductB1()
class ConcreteFactory2(AbstractFactory):
"""
Implement the operations to create concrete product objects.
"""
def create_product_a(self):
return ConcreteProductA2()
def create_product_b(self):
return ConcreteProductB2()
class AbstractProductA(metaclass=abc.ABCMeta):
"""
Declare an interface for a type of product object.
"""
@abc.abstractmethod
def interface_a(self):
pass
class ConcreteProductA1(AbstractProductA):
"""
Define a product object to be created by the corresponding concrete
factory.
Implement the AbstractProduct interface.
"""
def interface_a(self):
pass
class ConcreteProductA2(AbstractProductA):
"""
Define a product object to be created by the corresponding concrete
factory.
Implement the AbstractProduct interface.
"""
def interface_a(self):
pass
class AbstractProductB(metaclass=abc.ABCMeta):
"""
Declare an interface for a type of product object.
"""
@abc.abstractmethod
def interface_b(self):
pass
class ConcreteProductB1(AbstractProductB):
"""
Define a product object to be created by the corresponding concrete
factory.
Implement the AbstractProduct interface.
"""
def interface_b(self):
pass
class ConcreteProductB2(AbstractProductB):
"""
Define a product object to be created by the corresponding concrete
factory.
Implement the AbstractProduct interface.
"""
def interface_b(self):
pass
def main():
for factory in (ConcreteFactory1(), ConcreteFactory2()):
product_a = factory.create_product_a()
product_b = factory.create_product_b()
product_a.interface_a()
product_b.interface_b()
if __name__ == "__main__":
main()
Code above:Abstract Factory in Python
Leave a Comment