@@ -92,47 +92,42 @@ func IsEmpty() (isEmpty bool) {
9292// requested. The updated configuration is saved to file.
9393func AddContextWithContainer (
9494 contextName string ,
95- imageName string ,
96- portNumber int ,
97- containerId string ,
98- username string ,
99- password string ,
100- passwordEncryption string ,
95+ options ContextOptions ,
10196) {
102- if containerId == "" {
97+ if options . ContainerId == "" {
10398 panic ("containerId must be provided" )
10499 }
105- if imageName == "" {
100+ if options . ImageName == "" {
106101 panic ("imageName must be provided" )
107102 }
108- if portNumber == 0 {
103+ if options . PortNumber == 0 {
109104 panic ("portNumber must be non-zero" )
110105 }
111- if username == "" {
106+ if options . Username == "" {
112107 panic ("username must be provided" )
113108 }
114- if password == "" {
109+ if options . Password == "" {
115110 panic ("password must be provided" )
116111 }
117112 if contextName == "" {
118113 panic ("contextName must be provided" )
119114 }
120115
121- contextName = FindUniqueContextName (contextName , username )
116+ contextName = FindUniqueContextName (contextName , options . Username )
122117 endPointName := FindUniqueEndpointName (contextName )
123- userName := username + "@" + contextName
118+ userName := options . Username + "@" + contextName
124119
125120 config .CurrentContext = contextName
126121
127122 config .Endpoints = append (config .Endpoints , Endpoint {
128123 AssetDetails : & AssetDetails {
129124 ContainerDetails : & ContainerDetails {
130- Id : containerId ,
131- Image : imageName },
125+ Id : options . ContainerId ,
126+ Image : options . ImageName },
132127 },
133128 EndpointDetails : EndpointDetails {
134129 Address : "127.0.0.1" ,
135- Port : portNumber ,
130+ Port : options . PortNumber ,
136131 },
137132 Name : endPointName ,
138133 })
@@ -148,9 +143,9 @@ func AddContextWithContainer(
148143 user := User {
149144 AuthenticationType : "basic" ,
150145 BasicAuth : & BasicAuthDetails {
151- Username : username ,
152- PasswordEncryption : passwordEncryption ,
153- Password : encryptCallback (password , passwordEncryption ),
146+ Username : options . Username ,
147+ PasswordEncryption : options . PasswordEncryption ,
148+ Password : encryptCallback (options . Password , options . PasswordEncryption ),
154149 },
155150 Name : userName ,
156151 }
0 commit comments