github.com/GoogleContainerTools/kpt@v1.0.0-beta.50.0.20240520170205-c25345ffcbee/firebase/functions/index.js (about)

     1  /**
     2   * Copyright 2022 The kpt Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *      http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  const functions = require("firebase-functions");
    18  
    19  
    20  // Return meta tag for remote go import path
    21  // See: https://pkg.go.dev/cmd/go#hdr-Remote_import_paths
    22  const remoteGoImport = ({ importPrefix, vcs, repoRoot }) => {
    23    return `<meta name="go-import" content="${importPrefix} ${vcs} ${repoRoot}">`;
    24  }
    25  
    26  // Creates a firebase endpoint which implements a golang vanity server
    27  const vanityGoEndpoint = ({ importPrefix, vcs, repoRoot }) =>
    28      functions.https.onRequest((request, response) => {
    29        if (request.query["go-get"] === "1") {
    30          return response.send(
    31              remoteGoImport({ importPrefix, vcs, repoRoot })
    32          );
    33        }
    34        return response.redirect(repoRoot);
    35      });
    36  
    37  exports.configsync = vanityGoEndpoint({
    38    importPrefix: 'kpt.dev/configsync',
    39    vcs: 'git',
    40    repoRoot: 'https://github.com/GoogleContainerTools/kpt-config-sync.git'
    41  });
    42  
    43  exports.resourcegroup = vanityGoEndpoint({
    44    importPrefix: "kpt.dev/resourcegroup",
    45    vcs: "git",
    46    repoRoot: "https://github.com/GoogleContainerTools/kpt-resource-group.git",
    47  });