示例#1
0
func main() {
	// initialize logger
	log := logger.Logger()
	defer log.Close()
	defer log.Flush()

	// parse input parameters
	parseFlags(log)

	// run agent
	run(log)
}
示例#2
0
// ManagedInstanceCredentialsInstance returns a singleton instance of
// Crednetials which provides credentials of a managed instance.
func ManagedInstanceCredentialsInstance() *credentials.Credentials {
	lock.Lock()
	defer lock.Unlock()
	logger = log.Logger()
	shareCreds = true
	if config, err := appconfig.Config(false); err == nil {
		shareCreds = config.Profile.ShareCreds
		shareProfile = config.Profile.ShareProfile
	}

	if credentialsSingleton == nil {
		credentialsSingleton = newManagedInstanceCredentials()
	}
	return credentialsSingleton
}
示例#3
0
func Marshalling(t *testing.T) {
	logger := log.Logger()
	defer logger.Flush()
	result := contracts.PluginResult{}

	resultbytes, err := json.Marshal(result)
	if err != nil {
		logger.Info("failed to marshall", err)
	}
	logger.Info("pluginResult=", string(resultbytes))

	result1 := contracts.PluginRuntimeStatus{}

	resultbytes1, err := json.Marshal(result1)
	if err != nil {
		logger.Info("failed to marshall", err)
	}
	logger.Info("PluginRuntimeStatus=", string(resultbytes1))

}
//Test loadContextFromFile file with valid context files
func TestParseContext(t *testing.T) {
	// generate test cases
	var testCases []testCase
	for _, contextFile := range sampleFiles {
		testCases = append(testCases, testCase{
			Input:    string(loadFile(t, contextFile)),
			Output:   loadContextFromFile(t, contextFile),
			FileName: contextFile,
		})
	}

	// run tests
	for _, tst := range testCases {
		// call method
		parsedContext, err := parseContext(log.Logger(), tst.FileName)

		// check results
		assert.Nil(t, err)
		assert.Equal(t, parsedContext.Current.SourceVersion, "")
		assert.Equal(t, len(parsedContext.Histories), 1)
		assert.Equal(t, parsedContext.Histories[0].SourceVersion, "0.0.3.0")
	}
}
示例#5
0
func main() {
	// initialize logger
	log := logger.Logger()
	defer log.Close()
	defer log.Flush()

	// parse input parameters
	parseFlags(log)

	// check whether this is an interactive session
	isIntSess, err := svc.IsAnInteractiveSession()
	if err != nil {
		log.Warnf("Failed to determine if we are running in an interactive session: %v", err)
	}

	// isIntSess is false by default (after declaration), this fits the use
	// case that agent is running as Windows service most of times
	switch isIntSess {
	case true:
		run(log)
	case false:
		svc.Run(serviceName, &amazonSSMAgentService{log: log})
	}
}
示例#6
0
func init() {
	log = logger.Logger()
	defer log.Flush()
}