|
@@ -109,90 +109,4 @@ func (c *APIContractUpdateHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ
|
|
|
|
|
|
|
|
w.WriteHeader(http.StatusCreated)
|
|
w.WriteHeader(http.StatusCreated)
|
|
|
c.WriteResult(w, r, revision)
|
|
c.WriteResult(w, r, revision)
|
|
|
-
|
|
|
|
|
- // if apiContract.Cluster == nil {
|
|
|
|
|
- // e := errors.New("missing cluster object")
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // cl := apiContract.Cluster
|
|
|
|
|
-
|
|
|
|
|
- // if cl.CloudProviderCredentialsId == "" {
|
|
|
|
|
- // e := errors.New("missing cloud_provider_credential_identifier")
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // if cl.GetEksKind() == nil {
|
|
|
|
|
- // e := errors.New("missing eks_kind_values")
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // if cl.ClusterId == 0 {
|
|
|
|
|
- // dbClusterInput := models.Cluster{
|
|
|
|
|
- // ProjectID: uint(cl.ProjectId),
|
|
|
|
|
- // Status: types.UpdatingUnavailable,
|
|
|
|
|
- // ProvisionedBy: "CAPI",
|
|
|
|
|
- // CloudProvider: "AWS",
|
|
|
|
|
- // CloudProviderCredentialIdentifier: cl.CloudProviderCredentialsId,
|
|
|
|
|
- // Name: cl.GetEksKind().ClusterName,
|
|
|
|
|
- // VanityName: cl.GetEksKind().ClusterName,
|
|
|
|
|
- // }
|
|
|
|
|
- // dbCluster, err := c.Config().Repo.Cluster().CreateCluster(&dbClusterInput)
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // e := fmt.Errorf("error creating new cluster: %w", err)
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // apiContract.Cluster.ClusterId = int32(dbCluster.ID)
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // by, err := helpers.MarshalContractObject(ctx, &apiContract)
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // e := fmt.Errorf("error marshalling api contract: %w", err)
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // b64 := base64.StdEncoding.EncodeToString([]byte(by))
|
|
|
|
|
-
|
|
|
|
|
- // apiContractRevision := models.APIContractRevision{
|
|
|
|
|
- // ClusterID: int(cl.ClusterId),
|
|
|
|
|
- // ProjectID: int(cl.ProjectId),
|
|
|
|
|
- // Base64Contract: string(b64),
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // contractRevision, err := c.Config().Repo.APIContractRevisioner().Insert(ctx, apiContractRevision)
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // e := fmt.Errorf("error creating new capi config: %w", err)
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // // This gates the cluster actually being provisioned by CAPI
|
|
|
|
|
- // // This can be removed whenever we are able to run NATS and CCP locally, easier
|
|
|
|
|
- // if !c.Config().DisableCAPIProvisioner {
|
|
|
|
|
- // resp := porterv1.ContractRevision{
|
|
|
|
|
- // ProjectId: cl.ProjectId,
|
|
|
|
|
- // ClusterId: cl.ClusterId,
|
|
|
|
|
- // RevisionId: contractRevision.ID.String(),
|
|
|
|
|
- // }
|
|
|
|
|
- // kubeBy, err := helpers.MarshalContractObject(ctx, &resp)
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // e := fmt.Errorf("error marshalling api contract: %w", err)
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // subject := "porter.system.infrastructure.update"
|
|
|
|
|
- // _, err = c.Config().NATS.JetStream.Publish(subject, kubeBy, nats.Context(ctx))
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // e := fmt.Errorf("error publishing cluster for creation: %w", err)
|
|
|
|
|
- // c.HandleAPIError(w, r, apierrors.NewErrInternal(e))
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // w.WriteHeader(http.StatusCreated)
|
|
|
|
|
- // c.WriteResult(w, r, contractRevision)
|
|
|
|
|
}
|
|
}
|