// AddDeployKey add new deploy key to database and authorized_keys file.
172528
func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
	if err := checkKeyContent(content); err != nil {
		return nil, err
	}

	pkey := &PublicKey{
		Content: content,
		Mode:    ACCESS_MODE_READ,
		Type:    KEY_TYPE_DEPLOY,
	}
	has, err := x.Get(pkey)
	if err != nil {
		return nil, err
	}

	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return nil, err
	}

	// First time use this deploy key.
	if !has {
		if err = addKey(sess, pkey); err != nil {
			return nil, fmt.Errorf("addKey: %v", err)
		}
	}

	key, err := addDeployKey(sess, pkey.ID, repoID, name, pkey.Fingerprint)
	if err != nil {
		return nil, fmt.Errorf("addDeployKey: %v", err)
	}

	return key, sess.Commit()
}
549947
func (sc *Client) AddPrivateKey(ctx context.Context, key []byte) (string, error) {
	var id string
	return id, sc.c.CallContext(ctx, &id, "shh_addPrivateKey", hexutil.Bytes(key))
}
253962
func (a *LocalKeyAgent) AddKey(key *Key) (*agent.AddedKey, error) {
	// save it to disk (usually into ~/.tsh)
	err := a.keyStore.AddKey(a.proxyHost, a.username, key)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// load key into the teleport agent and system agent
	return a.LoadKey(*key)
}
1121058
func (k *KeyManager) InstallKey(key string) (*KeyResponse, error) {
	return k.InstallKeyWithOptions(key, nil)
}
555895
func (e *Ed25519) AddKey(role data.RoleName, gun data.GUN, k data.PrivateKey) error {
	e.addKey(role, k)
	return nil
}
453062
func (s *CreateDeploymentInput) SetDeploymentType(v string) *CreateDeploymentInput {
	s.DeploymentType = &v
	return s
}
1062519
func (s *Deployment) SetDeploymentId(v string) *Deployment {
	s.DeploymentId = &v
	return s
}
682761
func StackDeploy(name, content string, authes map[string]string) error {
	ctx, cli, err := mgr.Client()
	if err != nil {
		return err
	}

	cfg, err := compose.Parse(name, content)
	if err != nil {
		return err
	}

	namespace := compose.NewNamespace(name)

	serviceNetworks := compose.GetServicesDeclaredNetworks(cfg.Services)
	networks, externalNetworks := compose.Networks(namespace, cfg.Networks, serviceNetworks)
	if err = validateExternalNetworks(ctx, cli, externalNetworks); err != nil {
		return err
	}
	if err = createNetworks(ctx, cli, namespace, networks); err != nil {
		return err
	}

	secrets, err := compose.Secrets(namespace, cfg.Secrets)
	if err != nil {
		return err
	}
	if err = createSecrets(ctx, cli, secrets); err != nil {
		return err
	}

	configs, err := compose.Configs(namespace, cfg.Configs)
	if err != nil {
		return err
	}
	if err = createConfigs(ctx, cli, configs); err != nil {
		return err
	}

	services, err := compose.Services(namespace, cfg, cli)
	if err != nil {
		return err
	}
	return deployServices(ctx, cli, services, namespace, authes)
}
475755
func (s *DescribeExpressionsInput) SetDeployed(v bool) *DescribeExpressionsInput {
	s.Deployed = &v
	return s
}
319302
func (s *SkipWaitTimeForInstanceTerminationInput) SetDeploymentId(v string) *SkipWaitTimeForInstanceTerminationInput {
	s.DeploymentId = &v
	return s
}
398023
func (s *UpdateDeploymentInput) SetDeploymentId(v string) *UpdateDeploymentInput {
	s.DeploymentId = &v
	return s
}
427577
func (s *UpdateDeploymentOutput) SetDeploymentId(v string) *UpdateDeploymentOutput {
	s.DeploymentId = &v
	return s
}
306379
func UpdateDeployKey(key *DeployKey) error {
	_, err := x.Id(key.ID).AllCols().Update(key)
	return err
}
1226880
func (f *Function) hookDeploy() error {
	for _, name := range f.Plugins {
		if p, ok := plugins[name].(Deployer); ok {
			if err := p.Deploy(f); err != nil {
				return err
			}
		}
	}
	return nil
}
281663
func (g *Gitlab) ProjectDeployKeys(id string) ([]*SshKey, *ResponseMeta, error) {
	u := g.ResourceUrl(ProjectDeployKeysApiPath, map[string]string{":id": id})

	var deployKeys []*SshKey

	contents, meta, err := g.buildAndExecRequest("GET", u.String(), nil)
	if err == nil {
		err = json.Unmarshal(contents, &deployKeys)
	}

	return deployKeys, meta, err
}
1233321
func GetDeployKey(c *context.APIContext) {
	key, err := models.GetDeployKeyByID(c.ParamsInt64(":id"))
	if err != nil {
		if models.IsErrDeployKeyNotExist(err) {
			c.Status(404)
		} else {
			c.Error(500, "GetDeployKeyByID", err)
		}
		return
	}

	if err = key.GetContent(); err != nil {
		c.Error(500, "GetContent", err)
		return
	}

	apiLink := composeDeployKeysAPILink(c.Repo.Owner.Name + "/" + c.Repo.Repository.Name)
	c.JSON(200, convert.ToDeployKey(apiLink, key))
}
594148
func (s *CreateBrokerRequest) SetDeploymentMode(v string) *CreateBrokerRequest {
	s.DeploymentMode = &v
	return s
}