package services import ( "net/http" "github.com/gin-gonic/gin" "edge-infra.dev/pkg/edge/device-registrar/config" ) // swagger:route GET /bootstrap/{activationCode} legacy bootstrap // Bootstraps a device // // Bootstraps a device and returns the device's external application and device configuration details // responses: // // 200: DeviceConnectResponse Success // 400: description:Bad Request func BootstrapDevice(c *gin.Context) { k8sClient, ctx, cancel := config.GetClientandContext(c) defer cancel() // verify the deviceBinding device, err := retrieveDeviceRegistration(ctx, k8sClient, c) if err == errActivationCodeNotFound { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } else if err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": err.Error()}) return } // bootstrap the device err = bootstrap(ctx, k8sClient, c, device) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } }