// runClusterDeprovisionHook runs cluster provisioning hook defined by user
// application manifest
runClusterDeprovisionHook runs cluster provisioning hook defined by user
application manifest
// runClusterDeprovisionHook runs cluster provisioning hook defined by user // application manifest
func (s *site) runClusterDeprovisionHook(ctx *operationContext) error {
	s.reportProgress(ctx, ops.ProgressEntry{
		State:      ops.ProgressStateInProgress,
		Completion: 50,
		Message:    "Running cluster deprovisioning hook",
	})
	site, err := s.service.GetSite(s.key)
	if err != nil {
		return trace.Wrap(err)
	}
	vars := ctx.operation.Uninstall.Vars
	env := map[string]string{
		constants.EnvTelekubeClusterName: vars.System.ClusterName,
	}
	job, err := s.app.Manifest.Hooks.ClusterDeprovision.GetJob()
	if err != nil {
		return trace.Wrap(err)
	}
	request := app.HookRunRequest{
		Application: s.app.Package,
		Hook:        schema.HookClusterDeprovision,
		Env:         env,
	}
	secretParams := secretParams{
		token: vars.System.Token,
	}
	var profiles []string
	for profileName, servers := range site.ClusterState.ProfileMap() {
		profiles = append(profiles, profileName)
		env[fmt.Sprintf(constants.EnvTelekubeNodeProfileCountTemplate, profileName)] = fmt.Sprintf("%v", len(servers))
	}
	env[constants.EnvTelekubeNodeProfiles] = strings.Join(profiles, ",")
	switch provider := s.cloudProvider().(type) {
	case *aws:
		env[constants.EnvCloudProvider] = schema.ProviderAWS
		env[constants.EnvAWSRegion] = vars.AWS.Region
		env[constants.EnvAWSVPCID] = vars.AWS.VPCID
		secretParams.aws = &awsSecrets{
			accessKeyID:     provider.accessKey,
			secretAccessKey: provider.secretKey,
			sessionToken:    provider.sessionToken,
		}
	}
	return s.runIntegrationHook(ctx, job, request, secretParams)
}
func ( s * site ) runClusterDeprovisionHook ( ctx * operationContext ) error { s . reportProgress ( ctx , ops . ProgressEntry { State : ops . ProgressStateInProgress , Completion : 50 , Message : " " , } ) site , err := s . service . GetSite ( s . key ) if err != nil { return trace . Wrap ( err ) } vars := ctx . operation . Uninstall . Vars env := map [ string ] string { constants . EnvTelekubeClusterName : vars . System . ClusterName , } job , err := s . app . Manifest . Hooks . ClusterDeprovision . GetJob ( ) if err != nil { return trace . Wrap ( err ) } request := app . HookRunRequest { Application : s . app . Package , Hook : schema . HookClusterDeprovision , Env : env , } secretParams := secretParams { token : vars . System . Token , } var profiles [ ] string for profileName , servers := range site . ClusterState . ProfileMap ( ) { profiles = append ( profiles , profileName ) env [ fmt . Sprintf ( constants . EnvTelekubeNodeProfileCountTemplate , profileName ) ] = fmt . Sprintf ( " " , len ( servers ) ) } env [ constants . EnvTelekubeNodeProfiles ] = strings . Join ( profiles , " " ) switch provider := s . cloudProvider ( ) . ( type ) { case * aws : env [ constants . EnvCloudProvider ] = schema . ProviderAWS env [ constants . EnvAWSRegion ] = vars . AWS . Region env [ constants . EnvAWSVPCID ] = vars . AWS . VPCID secretParams . aws = & awsSecrets { accessKeyID : provider . accessKey , secretAccessKey : provider . secretKey , sessionToken : provider . sessionToken , } } return s . runIntegrationHook ( ctx , job , request , secretParams ) }
runClusterDeprovisionHook runs cluster provisioning hook defined by user
application manifest
runClusterDeprovisionHook runs cluster provisioning hook defined by user application manifest
// these are common environment variables valid for all deprovisioners // set profiles and roles // access parameters // setup parameters for VPC // pass provider as mounted secrets