@@ -117,7 +117,7 @@ func (c *Cluster) GetService(input string, insertDefaults bool) (types.Service,
117117}
118118
119119// CreateService creates a new service in a managed swarm cluster.
120- func (c * Cluster ) CreateService (s types.ServiceSpec , encodedAuth string ) (* apitypes.ServiceCreateResponse , error ) {
120+ func (c * Cluster ) CreateService (s types.ServiceSpec , encodedAuth string , queryRegistry bool ) (* apitypes.ServiceCreateResponse , error ) {
121121 var resp * apitypes.ServiceCreateResponse
122122 err := c .lockedManagerAction (func (ctx context.Context , state nodeState ) error {
123123 err := c .populateNetworkID (ctx , state .controlClient , & s )
@@ -151,8 +151,11 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string) (*apity
151151 }
152152 }
153153
154- // pin image by digest
155- if os .Getenv ("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE" ) != "1" {
154+ // pin image by digest for API versions < 1.30
155+ // TODO(nishanttotla): The check on "DOCKER_SERVICE_PREFER_OFFLINE_IMAGE"
156+ // should be removed in the future. Since integration tests only use the
157+ // latest API version, so this is no longer required.
158+ if os .Getenv ("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE" ) != "1" && queryRegistry {
156159 digestImage , err := c .imageWithDigestString (ctx , ctnr .Image , authConfig )
157160 if err != nil {
158161 logrus .Warnf ("unable to pin image %s to digest: %s" , ctnr .Image , err .Error ())
@@ -193,7 +196,7 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string) (*apity
193196}
194197
195198// UpdateService updates existing service to match new properties.
196- func (c * Cluster ) UpdateService (serviceIDOrName string , version uint64 , spec types.ServiceSpec , flags apitypes.ServiceUpdateOptions ) (* apitypes.ServiceUpdateResponse , error ) {
199+ func (c * Cluster ) UpdateService (serviceIDOrName string , version uint64 , spec types.ServiceSpec , flags apitypes.ServiceUpdateOptions , queryRegistry bool ) (* apitypes.ServiceUpdateResponse , error ) {
197200 var resp * apitypes.ServiceUpdateResponse
198201
199202 err := c .lockedManagerAction (func (ctx context.Context , state nodeState ) error {
@@ -256,8 +259,11 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec typ
256259
257260 resp = & apitypes.ServiceUpdateResponse {}
258261
259- // pin image by digest
260- if os .Getenv ("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE" ) != "1" {
262+ // pin image by digest for API versions < 1.30
263+ // TODO(nishanttotla): The check on "DOCKER_SERVICE_PREFER_OFFLINE_IMAGE"
264+ // should be removed in the future. Since integration tests only use the
265+ // latest API version, so this is no longer required.
266+ if os .Getenv ("DOCKER_SERVICE_PREFER_OFFLINE_IMAGE" ) != "1" && queryRegistry {
261267 digestImage , err := c .imageWithDigestString (ctx , newCtnr .Image , authConfig )
262268 if err != nil {
263269 logrus .Warnf ("unable to pin image %s to digest: %s" , newCtnr .Image , err .Error ())
0 commit comments